Tue, 17 Sep 2013 08:21:11 -0700
Merge
src/share/classes/com/sun/tools/javac/code/Annotations.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/diags/examples/CyclicInference.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/diags/examples/MrefStat.java.rej | file | annotate | diff | comparison | revisions | |
test/tools/javac/diags/examples/MrefStat1.java.rej | file | annotate | diff | comparison | revisions | |
test/tools/javac/lambda/TargetType10.out | file | annotate | diff | comparison | revisions | |
test/tools/javac/lambda/typeInference/InferenceTest5.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/lambda/typeInference/InferenceTest_neg5.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/lambda/typeInference/InferenceTest_neg5.out | file | annotate | diff | comparison | revisions |
1.1 --- a/README Thu Sep 12 11:09:20 2013 -0700 1.2 +++ b/README Tue Sep 17 08:21:11 2013 -0700 1.3 @@ -32,7 +32,7 @@ 1.4 JLS and JVMS. 1.5 1.6 In addition, there is a substantial collection of regression and unit 1.7 -tests for all the tools in the maain langtools test/ directory. 1.8 +tests for all the tools in the main langtools test/ directory. 1.9 1.10 Finally, there is a small set of tests to do basic validation of a build 1.11 of the langtools workspace for use by JDK. These tests check the contents
2.1 --- a/make/netbeans/langtools/build.xml Thu Sep 12 11:09:20 2013 -0700 2.2 +++ b/make/netbeans/langtools/build.xml Tue Sep 17 08:21:11 2013 -0700 2.3 @@ -1,6 +1,6 @@ 2.4 <?xml version="1.0" encoding="UTF-8"?> 2.5 <!-- 2.6 - Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 2.7 + Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. 2.8 2.9 Redistribution and use in source and binary forms, with or without 2.10 modification, are permitted provided that the following conditions 2.11 @@ -55,10 +55,18 @@ 2.12 description="Build one or all langtools tools" 2.13 /> 2.14 2.15 + <condition property="bootstrap" value="bootstrap-" else=""> 2.16 + <isset property="langtools.tool.bootstrap"/> 2.17 + </condition> 2.18 + 2.19 + <condition property="bcp" value="${build.bootstrap.dir}/classes" else="${build.classes.dir}"> 2.20 + <isset property="langtools.tool.bootstrap"/> 2.21 + </condition> 2.22 + 2.23 <target name="-build-tool" if="langtools.tool.name"> 2.24 - <echo level="info" message="Building ${langtools.tool.name}"/> 2.25 + <echo level="info" message="Building ${bootstrap}${langtools.tool.name}"/> 2.26 <echo level="verbose" message="(Unset langtools.tool.name to build all tools)"/> 2.27 - <antcall target="build-${langtools.tool.name}"/> 2.28 + <antcall target="build-${bootstrap}${langtools.tool.name}"/> 2.29 </target> 2.30 2.31 <target name="-build-all" unless="langtools.tool.name"> 2.32 @@ -89,8 +97,9 @@ 2.33 2.34 <target name="run" depends="-check-target.java.home,build,-def-run,-get-tool-and-args" 2.35 description="run tool"> 2.36 - <echo level="info" message="Run ${langtools.tool.name} with args ${langtools.tool.args}"/> 2.37 - <run mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}"/> 2.38 + <echo level="info" message="${bcp}"/> 2.39 + <echo level="info" message="Run ${bootstrap}${langtools.tool.name} with args ${langtools.tool.args}"/> 2.40 + <run bcp="${bcp}" mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}"/> 2.41 </target> 2.42 2.43 <!-- Run a selected class. (action: run.single; shift-F6) --> 2.44 @@ -136,9 +145,9 @@ 2.45 <!-- Debug tool in NetBeans. --> 2.46 2.47 <target name="debug" depends="-check-target.java.home,-def-run,-def-start-debugger,-get-tool-and-args,build" if="netbeans.home"> 2.48 - <echo level="info" message="Debug ${langtools.tool.name} with args ${langtools.tool.args}"/> 2.49 + <echo level="info" message="Debug ${boostrap}${langtools.tool.name} with args ${langtools.tool.args}"/> 2.50 <start-debugger/> 2.51 - <run mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}" jpda.jvmargs="${jpda.jvmargs}"/> 2.52 + <run bcp="${bcp}" mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}" jpda.jvmargs="${jpda.jvmargs}"/> 2.53 </target> 2.54 2.55 <!-- Debug a selected class . --> 2.56 @@ -207,6 +216,7 @@ 2.57 <target name="-get-tool-if-set" depends="-def-select-tool"> 2.58 <select-tool 2.59 toolproperty="langtools.tool.name" 2.60 + bootstrapproperty="langtools.tool.bootstrap" 2.61 propertyfile="${langtools.properties}" 2.62 askIfUnset="false" 2.63 /> 2.64 @@ -216,6 +226,7 @@ 2.65 <select-tool 2.66 toolproperty="langtools.tool.name" 2.67 argsproperty="langtools.tool.args" 2.68 + bootstrapproperty="langtools.tool.bootstrap" 2.69 propertyfile="${langtools.properties}" 2.70 askIfUnset="true" 2.71 /> 2.72 @@ -226,10 +237,12 @@ 2.73 <macrodef name="run"> 2.74 <attribute name="mainclass"/> 2.75 <attribute name="args" default=""/> 2.76 + <attribute name="bcp" default="${build.classes.dir}"/> 2.77 <attribute name="jpda.jvmargs" default=""/> 2.78 + 2.79 <sequential> 2.80 <java fork="true" jvm="${target.java}" classname="@{mainclass}"> 2.81 - <jvmarg line="-Xbootclasspath/p:${build.classes.dir}"/> 2.82 + <jvmarg line="-Xbootclasspath/p:${bcp}"/> 2.83 <jvmarg line="@{jpda.jvmargs}"/> 2.84 <arg line="@{args}"/> 2.85 </java>
3.1 --- a/make/tools/anttasks/SelectToolTask.java Thu Sep 12 11:09:20 2013 -0700 3.2 +++ b/make/tools/anttasks/SelectToolTask.java Tue Sep 17 08:21:11 2013 -0700 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -43,6 +43,7 @@ 3.11 import java.io.Writer; 3.12 import java.util.ArrayList; 3.13 import java.util.Arrays; 3.14 +import java.util.EnumSet; 3.15 import java.util.List; 3.16 import java.util.Properties; 3.17 import javax.swing.JButton; 3.18 @@ -71,6 +72,31 @@ 3.19 * is invoked to allow the user to set or reset values for use in property mode. 3.20 */ 3.21 public class SelectToolTask extends Task { 3.22 + 3.23 + enum ToolChoices { 3.24 + NONE(""), 3.25 + JAVAC("javac"), 3.26 + JAVADOC("javadoc"), 3.27 + JAVAH("javah"), 3.28 + JAVAP("javap"); 3.29 + 3.30 + String toolName; 3.31 + boolean bootstrap; 3.32 + 3.33 + ToolChoices(String toolName) { 3.34 + this(toolName, false); 3.35 + } 3.36 + 3.37 + ToolChoices(String toolName, boolean boostrap) { 3.38 + this.toolName = toolName; 3.39 + } 3.40 + 3.41 + @Override 3.42 + public String toString() { 3.43 + return toolName; 3.44 + } 3.45 + } 3.46 + 3.47 /** 3.48 * Set the location of the private properties file used to keep the retain 3.49 * user preferences for this repository. 3.50 @@ -97,6 +123,14 @@ 3.51 } 3.52 3.53 /** 3.54 + * Set the name of the property which will be set to the execution args of the 3.55 + * selected tool, if any. The args default to an empty string. 3.56 + */ 3.57 + public void setBootstrapProperty(String bootstrapProperty) { 3.58 + this.bootstrapProperty = bootstrapProperty; 3.59 + } 3.60 + 3.61 + /** 3.62 * Specify whether or not to pop up a dialog if the user has not specified 3.63 * a default value for a property. 3.64 */ 3.65 @@ -110,6 +144,7 @@ 3.66 3.67 Properties props = readProperties(propertyFile); 3.68 toolName = props.getProperty("tool.name"); 3.69 + toolBootstrap = props.getProperty("tool.bootstrap") != null; 3.70 if (toolName != null) { 3.71 toolArgs = props.getProperty(toolName + ".args", ""); 3.72 } 3.73 @@ -123,6 +158,8 @@ 3.74 // finally, return required values, if any 3.75 if (toolProperty != null && !(toolName == null || toolName.equals(""))) { 3.76 p.setProperty(toolProperty, toolName); 3.77 + if (toolBootstrap) 3.78 + p.setProperty(bootstrapProperty, "true"); 3.79 3.80 if (argsProperty != null && toolArgs != null) 3.81 p.setProperty(argsProperty, toolArgs); 3.82 @@ -134,14 +171,20 @@ 3.83 JOptionPane p = createPane(guiProps); 3.84 p.createDialog("Select Tool").setVisible(true); 3.85 3.86 - toolName = (String) toolChoice.getSelectedItem(); 3.87 + toolName = ((ToolChoices)toolChoice.getSelectedItem()).toolName; 3.88 toolArgs = argsField.getText(); 3.89 - 3.90 + toolBootstrap = bootstrapCheckbox.isSelected(); 3.91 if (defaultCheck.isSelected()) { 3.92 if (toolName.equals("")) { 3.93 fileProps.remove("tool.name"); 3.94 + fileProps.remove("tool.bootstrap"); 3.95 } else { 3.96 fileProps.put("tool.name", toolName); 3.97 + if (toolBootstrap) { 3.98 + fileProps.put("tool.bootstrap", "true"); 3.99 + } else { 3.100 + fileProps.remove("tool.bootstrap"); 3.101 + } 3.102 fileProps.put(toolName + ".args", toolArgs); 3.103 } 3.104 writeProperties(propertyFile, fileProps); 3.105 @@ -154,32 +197,38 @@ 3.106 lc.insets.right = 10; 3.107 lc.insets.bottom = 3; 3.108 GridBagConstraints fc = new GridBagConstraints(); 3.109 - fc.anchor = GridBagConstraints.WEST; 3.110 fc.gridx = 1; 3.111 - fc.gridwidth = GridBagConstraints.REMAINDER; 3.112 + fc.gridwidth = GridBagConstraints.NONE; 3.113 fc.insets.bottom = 3; 3.114 3.115 + JPanel toolPane = new JPanel(new GridBagLayout()); 3.116 + 3.117 JLabel toolLabel = new JLabel("Tool:"); 3.118 body.add(toolLabel, lc); 3.119 - String[] toolChoices = { "apt", "javac", "javadoc", "javah", "javap" }; 3.120 - if (true || toolProperty == null) { 3.121 - // include empty value in setup mode 3.122 - List<String> l = new ArrayList<String>(Arrays.asList(toolChoices)); 3.123 - l.add(0, ""); 3.124 - toolChoices = l.toArray(new String[l.size()]); 3.125 - } 3.126 - toolChoice = new JComboBox(toolChoices); 3.127 + EnumSet<ToolChoices> toolChoices = toolProperty == null ? 3.128 + EnumSet.allOf(ToolChoices.class) : EnumSet.range(ToolChoices.JAVAC, ToolChoices.JAVAP); 3.129 + toolChoice = new JComboBox(toolChoices.toArray()); 3.130 if (toolName != null) 3.131 - toolChoice.setSelectedItem(toolName); 3.132 + toolChoice.setSelectedItem(ToolChoices.valueOf(toolName.toUpperCase())); 3.133 toolChoice.addItemListener(new ItemListener() { 3.134 public void itemStateChanged(ItemEvent e) { 3.135 - String tn = (String) e.getItem(); 3.136 + String tn = ((ToolChoices)e.getItem()).toolName; 3.137 argsField.setText(getDefaultArgsForTool(props, tn)); 3.138 if (toolProperty != null) 3.139 okButton.setEnabled(!tn.equals("")); 3.140 } 3.141 }); 3.142 - body.add(toolChoice, fc); 3.143 + GridBagConstraints checkConstraint = new GridBagConstraints(); 3.144 + fc.anchor = GridBagConstraints.EAST; 3.145 + 3.146 + GridBagConstraints toolConstraint = new GridBagConstraints(); 3.147 + fc.anchor = GridBagConstraints.WEST; 3.148 + 3.149 + toolPane.add(toolChoice, toolConstraint); 3.150 + bootstrapCheckbox = new JCheckBox("bootstrap", toolBootstrap); 3.151 + toolPane.add(bootstrapCheckbox, checkConstraint); 3.152 + 3.153 + body.add(toolPane, fc); 3.154 3.155 argsField = new JTextField(getDefaultArgsForTool(props, toolName), 40); 3.156 if (toolProperty == null || argsProperty != null) { 3.157 @@ -190,7 +239,7 @@ 3.158 public void focusGained(FocusEvent e) { 3.159 } 3.160 public void focusLost(FocusEvent e) { 3.161 - String toolName = (String) toolChoice.getSelectedItem(); 3.162 + String toolName = ((ToolChoices)toolChoice.getSelectedItem()).toolName; 3.163 if (toolName.length() > 0) 3.164 props.put(toolName + ".args", argsField.getText()); 3.165 } 3.166 @@ -271,16 +320,19 @@ 3.167 // Ant task parameters 3.168 private boolean askIfUnset; 3.169 private String toolProperty; 3.170 + private String bootstrapProperty; 3.171 private String argsProperty; 3.172 private File propertyFile; 3.173 3.174 // GUI components 3.175 private JComboBox toolChoice; 3.176 + private JCheckBox bootstrapCheckbox; 3.177 private JTextField argsField; 3.178 private JCheckBox defaultCheck; 3.179 private JButton okButton; 3.180 3.181 // Result values for the client 3.182 private String toolName; 3.183 + private boolean toolBootstrap; 3.184 private String toolArgs; 3.185 }
4.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java Thu Sep 12 11:09:20 2013 -0700 4.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java Tue Sep 17 08:21:11 2013 -0700 4.3 @@ -157,7 +157,7 @@ 4.4 addAllProfilesLink(div); 4.5 } 4.6 body.addContent(div); 4.7 - if (configuration.showProfiles) { 4.8 + if (configuration.showProfiles && configuration.profilePackages.size() > 0) { 4.9 Content profileSummary = configuration.getResource("doclet.Profiles"); 4.10 addProfilesList(profileSummary, body); 4.11 }
5.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java Thu Sep 12 11:09:20 2013 -0700 5.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java Tue Sep 17 08:21:11 2013 -0700 5.3 @@ -118,7 +118,7 @@ 5.4 if (prev != null) { 5.5 Content prevLink = getLink(new LinkInfoImpl(configuration, 5.6 LinkInfoImpl.Kind.CLASS, prev.asClassDoc()) 5.7 - .label(configuration.getText("doclet.Prev_Class")).strong(true)); 5.8 + .label(prevclassLabel).strong(true)); 5.9 li = HtmlTree.LI(prevLink); 5.10 } 5.11 else 5.12 @@ -136,7 +136,7 @@ 5.13 if (next != null) { 5.14 Content nextLink = getLink(new LinkInfoImpl(configuration, 5.15 LinkInfoImpl.Kind.CLASS, next.asClassDoc()) 5.16 - .label(configuration.getText("doclet.Next_Class")).strong(true)); 5.17 + .label(nextclassLabel).strong(true)); 5.18 li = HtmlTree.LI(nextLink); 5.19 } 5.20 else
6.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Thu Sep 12 11:09:20 2013 -0700 6.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Tue Sep 17 08:21:11 2013 -0700 6.3 @@ -126,7 +126,7 @@ 6.4 if (prev != null) { 6.5 Content prevLink = getLink(new LinkInfoImpl(configuration, 6.6 LinkInfoImpl.Kind.CLASS, prev) 6.7 - .label(configuration.getText("doclet.Prev_Class")).strong(true)); 6.8 + .label(prevclassLabel).strong(true)); 6.9 li = HtmlTree.LI(prevLink); 6.10 } 6.11 else 6.12 @@ -144,7 +144,7 @@ 6.13 if (next != null) { 6.14 Content nextLink = getLink(new LinkInfoImpl(configuration, 6.15 LinkInfoImpl.Kind.CLASS, next) 6.16 - .label(configuration.getText("doclet.Next_Class")).strong(true)); 6.17 + .label(nextclassLabel).strong(true)); 6.18 li = HtmlTree.LI(nextLink); 6.19 } 6.20 else
7.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java Thu Sep 12 11:09:20 2013 -0700 7.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java Tue Sep 17 08:21:11 2013 -0700 7.3 @@ -205,13 +205,20 @@ 7.4 * {@inheritDoc} 7.5 */ 7.6 protected void generateProfileFiles() throws Exception { 7.7 - if (configuration.showProfiles) { 7.8 + if (configuration.showProfiles && configuration.profilePackages.size() > 0) { 7.9 ProfileIndexFrameWriter.generate(configuration); 7.10 Profile prevProfile = null, nextProfile; 7.11 + String profileName; 7.12 for (int i = 1; i < configuration.profiles.getProfileCount(); i++) { 7.13 - ProfilePackageIndexFrameWriter.generate(configuration, Profile.lookup(i).name); 7.14 + profileName = Profile.lookup(i).name; 7.15 + // Generate profile package pages only if there are any packages 7.16 + // in a profile to be documented. The profilePackages map will not 7.17 + // contain an entry for the profile if there are no packages to be documented. 7.18 + if (!configuration.shouldDocumentProfile(profileName)) 7.19 + continue; 7.20 + ProfilePackageIndexFrameWriter.generate(configuration, profileName); 7.21 PackageDoc[] packages = configuration.profilePackages.get( 7.22 - Profile.lookup(i).name); 7.23 + profileName); 7.24 PackageDoc prev = null, next; 7.25 for (int j = 0; j < packages.length; j++) { 7.26 // if -nodeprecated option is set and the package is marked as
8.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Thu Sep 12 11:09:20 2013 -0700 8.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Tue Sep 17 08:21:11 2013 -0700 8.3 @@ -406,10 +406,7 @@ 8.4 Content htmlDocType = DocType.TRANSITIONAL; 8.5 Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); 8.6 Content head = new HtmlTree(HtmlTag.HEAD); 8.7 - if (!configuration.notimestamp) { 8.8 - Content headComment = new Comment(getGeneratedByString()); 8.9 - head.addContent(headComment); 8.10 - } 8.11 + head.addContent(getGeneratedBy(!configuration.notimestamp)); 8.12 if (configuration.charset.length() > 0) { 8.13 Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE, 8.14 configuration.charset); 8.15 @@ -502,16 +499,17 @@ 8.16 if (!configuration.nonavbar) { 8.17 String allClassesId = "allclasses_"; 8.18 HtmlTree navDiv = new HtmlTree(HtmlTag.DIV); 8.19 + Content skipNavLinks = configuration.getResource("doclet.Skip_navigation_links"); 8.20 if (header) { 8.21 body.addContent(HtmlConstants.START_OF_TOP_NAVBAR); 8.22 navDiv.addStyle(HtmlStyle.topNav); 8.23 allClassesId += "navbar_top"; 8.24 Content a = getMarkerAnchor("navbar_top"); 8.25 + //WCAG - Hyperlinks should contain text or an image with alt text - for AT tools 8.26 navDiv.addContent(a); 8.27 - Content skipLinkContent = getHyperLink(DocLink.fragment("skip-navbar_top"), 8.28 - HtmlTree.EMPTY, 8.29 - configuration.getText("doclet.Skip_navigation_links"), 8.30 - ""); 8.31 + Content skipLinkContent = HtmlTree.DIV(HtmlStyle.skipNav, getHyperLink( 8.32 + DocLink.fragment("skip-navbar_top"), skipNavLinks, 8.33 + skipNavLinks.toString(), "")); 8.34 navDiv.addContent(skipLinkContent); 8.35 } else { 8.36 body.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR); 8.37 @@ -519,10 +517,9 @@ 8.38 allClassesId += "navbar_bottom"; 8.39 Content a = getMarkerAnchor("navbar_bottom"); 8.40 navDiv.addContent(a); 8.41 - Content skipLinkContent = getHyperLink(DocLink.fragment("skip-navbar_bottom"), 8.42 - HtmlTree.EMPTY, 8.43 - configuration.getText("doclet.Skip_navigation_links"), 8.44 - ""); 8.45 + Content skipLinkContent = HtmlTree.DIV(HtmlStyle.skipNav, getHyperLink( 8.46 + DocLink.fragment("skip-navbar_bottom"), skipNavLinks, 8.47 + skipNavLinks.toString(), "")); 8.48 navDiv.addContent(skipLinkContent); 8.49 } 8.50 if (header) {
9.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java Thu Sep 12 11:09:20 2013 -0700 9.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java Tue Sep 17 08:21:11 2013 -0700 9.3 @@ -130,10 +130,14 @@ 9.4 String profileName; 9.5 for (int i = 1; i < configuration.profiles.getProfileCount(); i++) { 9.6 profileName = Profile.lookup(i).name; 9.7 - Content profileLinkContent = getTargetProfileLink("classFrame", 9.8 - new StringContent(profileName), profileName); 9.9 - Content li = HtmlTree.LI(profileLinkContent); 9.10 - ul.addContent(li); 9.11 + // If the profile has valid packages to be documented, add it to the 9.12 + // profiles list on overview-summary.html page. 9.13 + if (configuration.shouldDocumentProfile(profileName)) { 9.14 + Content profileLinkContent = getTargetProfileLink("classFrame", 9.15 + new StringContent(profileName), profileName); 9.16 + Content li = HtmlTree.LI(profileLinkContent); 9.17 + ul.addContent(li); 9.18 + } 9.19 } 9.20 profilesDiv.addContent(ul); 9.21 Content div = HtmlTree.DIV(HtmlStyle.contentContainer, profilesDiv);
10.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java Thu Sep 12 11:09:20 2013 -0700 10.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java Tue Sep 17 08:21:11 2013 -0700 10.3 @@ -88,8 +88,13 @@ 10.4 Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading); 10.5 HtmlTree ul = new HtmlTree(HtmlTag.UL); 10.6 ul.setTitle(profilesLabel); 10.7 + String profileName; 10.8 for (int i = 1; i < profiles.getProfileCount(); i++) { 10.9 - ul.addContent(getProfile(i)); 10.10 + profileName = (Profile.lookup(i)).name; 10.11 + // If the profile has valid packages to be documented, add it to the 10.12 + // left-frame generated for profile index. 10.13 + if (configuration.shouldDocumentProfile(profileName)) 10.14 + ul.addContent(getProfile(profileName)); 10.15 } 10.16 div.addContent(ul); 10.17 body.addContent(div); 10.18 @@ -98,13 +103,12 @@ 10.19 /** 10.20 * Gets each profile name as a separate link. 10.21 * 10.22 - * @param profile the profile being documented 10.23 + * @param profileName the profile being documented 10.24 * @return content for the profile link 10.25 */ 10.26 - protected Content getProfile(int profile) { 10.27 + protected Content getProfile(String profileName) { 10.28 Content profileLinkContent; 10.29 Content profileLabel; 10.30 - String profileName = (Profile.lookup(profile)).name; 10.31 profileLabel = new StringContent(profileName); 10.32 profileLinkContent = getHyperLink(DocPaths.profileFrame(profileName), profileLabel, "", 10.33 "packageListFrame");
11.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java Thu Sep 12 11:09:20 2013 -0700 11.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java Tue Sep 17 08:21:11 2013 -0700 11.3 @@ -138,6 +138,7 @@ 11.4 "classFrame", new StringContent(pkg.name()), profile.name); 11.5 Content heading = HtmlTree.HEADING(HtmlTag.H3, pkgName); 11.6 HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, heading); 11.7 + addPackageDeprecationInfo(li, pkg); 11.8 return li; 11.9 } 11.10 11.11 @@ -175,6 +176,30 @@ 11.12 } 11.13 11.14 /** 11.15 + * Add the profile package deprecation information to the documentation tree. 11.16 + * 11.17 + * @param li the content tree to which the deprecation information will be added 11.18 + * @param pkg the PackageDoc that is added 11.19 + */ 11.20 + public void addPackageDeprecationInfo(Content li, PackageDoc pkg) { 11.21 + Tag[] deprs; 11.22 + if (Util.isDeprecated(pkg)) { 11.23 + deprs = pkg.tags("deprecated"); 11.24 + HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); 11.25 + deprDiv.addStyle(HtmlStyle.deprecatedContent); 11.26 + Content deprPhrase = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase); 11.27 + deprDiv.addContent(deprPhrase); 11.28 + if (deprs.length > 0) { 11.29 + Tag[] commentTags = deprs[0].inlineTags(); 11.30 + if (commentTags.length > 0) { 11.31 + addInlineDeprecatedComment(pkg, deprs[0], deprDiv); 11.32 + } 11.33 + } 11.34 + li.addContent(deprDiv); 11.35 + } 11.36 + } 11.37 + 11.38 + /** 11.39 * Get "PREV PROFILE" link in the navigation bar. 11.40 * 11.41 * @return a content tree for the previous link
12.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java Thu Sep 12 11:09:20 2013 -0700 12.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java Tue Sep 17 08:21:11 2013 -0700 12.3 @@ -191,10 +191,7 @@ 12.4 Content htmlDocType = DocType.FRAMESET; 12.5 Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); 12.6 Content head = new HtmlTree(HtmlTag.HEAD); 12.7 - if (! noTimeStamp) { 12.8 - Content headComment = new Comment(getGeneratedByString()); 12.9 - head.addContent(headComment); 12.10 - } 12.11 + head.addContent(getGeneratedBy(!noTimeStamp)); 12.12 if (configuration.charset.length() > 0) { 12.13 Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE, 12.14 configuration.charset); 12.15 @@ -210,9 +207,13 @@ 12.16 write(htmlDocument); 12.17 } 12.18 12.19 - protected String getGeneratedByString() { 12.20 - Calendar calendar = new GregorianCalendar(TimeZone.getDefault()); 12.21 - Date today = calendar.getTime(); 12.22 - return "Generated by javadoc ("+ ConfigurationImpl.BUILD_DATE + ") on " + today; 12.23 + protected Comment getGeneratedBy(boolean timestamp) { 12.24 + String text = "Generated by javadoc"; // marker string, deliberately not localized 12.25 + if (timestamp) { 12.26 + Calendar calendar = new GregorianCalendar(TimeZone.getDefault()); 12.27 + Date today = calendar.getTime(); 12.28 + text += " ("+ ConfigurationImpl.BUILD_DATE + ") on " + today; 12.29 + } 12.30 + return new Comment(text); 12.31 } 12.32 }
13.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java Thu Sep 12 11:09:20 2013 -0700 13.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java Tue Sep 17 08:21:11 2013 -0700 13.3 @@ -68,6 +68,7 @@ 13.4 packageSummary, 13.5 rowColor, 13.6 serializedFormContainer, 13.7 + skipNav, 13.8 sourceContainer, 13.9 sourceLineNo, 13.10 strong,
14.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Thu Sep 12 11:09:20 2013 -0700 14.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Tue Sep 17 08:21:11 2013 -0700 14.3 @@ -203,27 +203,27 @@ 14.4 useLabel = getResource("doclet.navClassUse"); 14.5 prevLabel = getResource("doclet.Prev"); 14.6 nextLabel = getResource("doclet.Next"); 14.7 - prevclassLabel = getResource("doclet.Prev_Class"); 14.8 - nextclassLabel = getResource("doclet.Next_Class"); 14.9 + prevclassLabel = getNonBreakResource("doclet.Prev_Class"); 14.10 + nextclassLabel = getNonBreakResource("doclet.Next_Class"); 14.11 summaryLabel = getResource("doclet.Summary"); 14.12 detailLabel = getResource("doclet.Detail"); 14.13 framesLabel = getResource("doclet.Frames"); 14.14 - noframesLabel = getResource("doclet.No_Frames"); 14.15 + noframesLabel = getNonBreakResource("doclet.No_Frames"); 14.16 treeLabel = getResource("doclet.Tree"); 14.17 classLabel = getResource("doclet.Class"); 14.18 deprecatedLabel = getResource("doclet.navDeprecated"); 14.19 deprecatedPhrase = getResource("doclet.Deprecated"); 14.20 - allclassesLabel = getResource("doclet.All_Classes"); 14.21 - allpackagesLabel = getResource("doclet.All_Packages"); 14.22 - allprofilesLabel = getResource("doclet.All_Profiles"); 14.23 + allclassesLabel = getNonBreakResource("doclet.All_Classes"); 14.24 + allpackagesLabel = getNonBreakResource("doclet.All_Packages"); 14.25 + allprofilesLabel = getNonBreakResource("doclet.All_Profiles"); 14.26 indexLabel = getResource("doclet.Index"); 14.27 helpLabel = getResource("doclet.Help"); 14.28 seeLabel = getResource("doclet.See"); 14.29 descriptionLabel = getResource("doclet.Description"); 14.30 - prevpackageLabel = getResource("doclet.Prev_Package"); 14.31 - nextpackageLabel = getResource("doclet.Next_Package"); 14.32 - prevprofileLabel = getResource("doclet.Prev_Profile"); 14.33 - nextprofileLabel = getResource("doclet.Next_Profile"); 14.34 + prevpackageLabel = getNonBreakResource("doclet.Prev_Package"); 14.35 + nextpackageLabel = getNonBreakResource("doclet.Next_Package"); 14.36 + prevprofileLabel = getNonBreakResource("doclet.Prev_Profile"); 14.37 + nextprofileLabel = getNonBreakResource("doclet.Next_Profile"); 14.38 packagesLabel = getResource("doclet.Packages"); 14.39 profilesLabel = getResource("doclet.Profiles"); 14.40 methodDetailsLabel = getResource("doclet.Method_Detail"); 14.41 @@ -257,6 +257,27 @@ 14.42 } 14.43 14.44 /** 14.45 + * Get the configuration string as a content, replacing spaces 14.46 + * with non-breaking spaces. 14.47 + * 14.48 + * @param key the key to look for in the configuration file 14.49 + * @return a content tree for the text 14.50 + */ 14.51 + public Content getNonBreakResource(String key) { 14.52 + String text = configuration.getText(key); 14.53 + Content c = configuration.newContent(); 14.54 + int start = 0; 14.55 + int p; 14.56 + while ((p = text.indexOf(" ", start)) != -1) { 14.57 + c.addContent(text.substring(start, p)); 14.58 + c.addContent(RawHtml.nbsp); 14.59 + start = p + 1; 14.60 + } 14.61 + c.addContent(text.substring(start)); 14.62 + return c; 14.63 + } 14.64 + 14.65 + /** 14.66 * Get the configuration string as a content. 14.67 * 14.68 * @param key the key to look for in the configuration file
15.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Thu Sep 12 11:09:20 2013 -0700 15.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Tue Sep 17 08:21:11 2013 -0700 15.3 @@ -383,35 +383,52 @@ 15.4 DocErrorReporter reporter); 15.5 15.6 private void initProfiles() throws IOException { 15.7 + if (profilespath.isEmpty()) 15.8 + return; 15.9 + 15.10 profiles = Profiles.read(new File(profilespath)); 15.11 - // Generate profiles documentation only is profilespath is set and if 15.12 - // profiles is not null and profiles count is 1 or more. 15.13 - showProfiles = (!profilespath.isEmpty() && profiles != null && 15.14 - profiles.getProfileCount() > 0); 15.15 - } 15.16 15.17 - private void initProfilePackages() throws IOException { 15.18 + // Group the packages to be documented by the lowest profile (if any) 15.19 + // in which each appears 15.20 + Map<Profile, List<PackageDoc>> interimResults = 15.21 + new EnumMap<Profile, List<PackageDoc>>(Profile.class); 15.22 + for (Profile p: Profile.values()) 15.23 + interimResults.put(p, new ArrayList<PackageDoc>()); 15.24 + 15.25 + for (PackageDoc pkg: packages) { 15.26 + if (nodeprecated && Util.isDeprecated(pkg)) { 15.27 + continue; 15.28 + } 15.29 + // the getProfile method takes a type name, not a package name, 15.30 + // but isn't particularly fussy about the simple name -- so just use * 15.31 + int i = profiles.getProfile(pkg.name().replace(".", "/") + "/*"); 15.32 + Profile p = Profile.lookup(i); 15.33 + if (p != null) { 15.34 + List<PackageDoc> pkgs = interimResults.get(p); 15.35 + pkgs.add(pkg); 15.36 + } 15.37 + } 15.38 + 15.39 + // Build the profilePackages structure used by the doclet 15.40 profilePackages = new HashMap<String,PackageDoc[]>(); 15.41 - ArrayList<PackageDoc> results; 15.42 - Map<String,PackageDoc> packageIndex = new HashMap<String,PackageDoc>(); 15.43 - for (int i = 0; i < packages.length; i++) { 15.44 - PackageDoc pkg = packages[i]; 15.45 - packageIndex.put(pkg.name(), pkg); 15.46 + List<PackageDoc> prev = Collections.<PackageDoc>emptyList(); 15.47 + int size; 15.48 + for (Map.Entry<Profile,List<PackageDoc>> e: interimResults.entrySet()) { 15.49 + Profile p = e.getKey(); 15.50 + List<PackageDoc> pkgs = e.getValue(); 15.51 + pkgs.addAll(prev); // each profile contains all lower profiles 15.52 + Collections.sort(pkgs); 15.53 + size = pkgs.size(); 15.54 + // For a profile, if there are no packages to be documented, do not add 15.55 + // it to profilePackages map. 15.56 + if (size > 0) 15.57 + profilePackages.put(p.name, pkgs.toArray(new PackageDoc[pkgs.size()])); 15.58 + prev = pkgs; 15.59 } 15.60 - for (int i = 1; i < profiles.getProfileCount(); i++) { 15.61 - Set<String> profPkgs = profiles.getPackages(i); 15.62 - results = new ArrayList<PackageDoc>(); 15.63 - for (String packageName : profPkgs) { 15.64 - packageName = packageName.replace("/", "."); 15.65 - PackageDoc profPkg = packageIndex.get(packageName); 15.66 - if (profPkg != null) { 15.67 - results.add(profPkg); 15.68 - } 15.69 - } 15.70 - Collections.sort(results); 15.71 - PackageDoc[] profilePkgs = results.toArray(new PackageDoc[]{}); 15.72 - profilePackages.put(Profile.lookup(i).name, profilePkgs); 15.73 - } 15.74 + 15.75 + // Generate profiles documentation if any profile contains any 15.76 + // of the packages to be documented. 15.77 + showProfiles = !prev.isEmpty(); 15.78 } 15.79 15.80 private void initPackageArray() { 15.81 @@ -534,13 +551,10 @@ 15.82 public void setOptions() throws Fault { 15.83 initPackageArray(); 15.84 setOptions(root.options()); 15.85 - if (!profilespath.isEmpty()) { 15.86 - try { 15.87 - initProfiles(); 15.88 - initProfilePackages(); 15.89 - } catch (Exception e) { 15.90 - throw new DocletAbortException(e); 15.91 - } 15.92 + try { 15.93 + initProfiles(); 15.94 + } catch (Exception e) { 15.95 + throw new DocletAbortException(e); 15.96 } 15.97 setSpecificDocletOptions(root.options()); 15.98 } 15.99 @@ -713,6 +727,17 @@ 15.100 } 15.101 15.102 /** 15.103 + * Check the validity of the given profile. Return false if there are no 15.104 + * valid packages to be documented for the profile. 15.105 + * 15.106 + * @param profileName the profile that needs to be validated. 15.107 + * @return true if the profile has valid packages to be documented. 15.108 + */ 15.109 + public boolean shouldDocumentProfile(String profileName) { 15.110 + return profilePackages.containsKey(profileName); 15.111 + } 15.112 + 15.113 + /** 15.114 * Check the validity of the given Source or Output File encoding on this 15.115 * platform. 15.116 *
16.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css Thu Sep 12 11:09:20 2013 -0700 16.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css Tue Sep 17 08:21:11 2013 -0700 16.3 @@ -180,6 +180,12 @@ 16.4 margin: auto 5px; 16.5 border:1px solid #c9aa44; 16.6 } 16.7 +.skipNav { 16.8 + position:absolute; 16.9 + top:auto; 16.10 + left:-9999px; 16.11 + overflow:hidden; 16.12 + } 16.13 /* 16.14 Page header and footer styles 16.15 */ 16.16 @@ -372,7 +378,6 @@ 16.17 overflow:hidden; 16.18 padding:0px; 16.19 margin:0px; 16.20 - white-space:pre; 16.21 } 16.22 caption a:link, caption a:hover, caption a:active, caption a:visited { 16.23 color:#FFFFFF; 16.24 @@ -381,35 +386,32 @@ 16.25 white-space:nowrap; 16.26 padding-top:8px; 16.27 padding-left:8px; 16.28 - display:block; 16.29 + display:inline-block; 16.30 float:left; 16.31 background-image:url(resources/titlebar.gif); 16.32 - height:18px; 16.33 } 16.34 .contentContainer ul.blockList li.blockList caption span.activeTableTab span { 16.35 white-space:nowrap; 16.36 padding-top:8px; 16.37 padding-left:8px; 16.38 - display:block; 16.39 + display:inline-block; 16.40 float:left; 16.41 background-image:url(resources/activetitlebar.gif); 16.42 - height:18px; 16.43 } 16.44 .contentContainer ul.blockList li.blockList caption span.tableTab span { 16.45 white-space:nowrap; 16.46 padding-top:8px; 16.47 padding-left:8px; 16.48 - display:block; 16.49 + display:inline-block; 16.50 float:left; 16.51 background-image:url(resources/titlebar.gif); 16.52 - height:18px; 16.53 } 16.54 .contentContainer ul.blockList li.blockList caption span.tableTab, .contentContainer ul.blockList li.blockList caption span.activeTableTab { 16.55 padding-top:0px; 16.56 padding-left:0px; 16.57 background-image:none; 16.58 float:none; 16.59 - display:inline; 16.60 + display:inline-block; 16.61 } 16.62 .overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd { 16.63 width:10px;
17.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LegacyTaglet.java Thu Sep 12 11:09:20 2013 -0700 17.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LegacyTaglet.java Tue Sep 17 08:21:11 2013 -0700 17.3 @@ -130,7 +130,13 @@ 17.4 public Content getTagletOutput(Doc holder, TagletWriter writer) 17.5 throws IllegalArgumentException { 17.6 Content output = writer.getOutputInstance(); 17.7 - output.addContent(new RawHtml(legacyTaglet.toString(holder.tags(getName())))); 17.8 + Tag[] tags = holder.tags(getName()); 17.9 + if (tags.length > 0) { 17.10 + String tagString = legacyTaglet.toString(tags); 17.11 + if (tagString != null) { 17.12 + output.addContent(new RawHtml(tagString)); 17.13 + } 17.14 + } 17.15 return output; 17.16 } 17.17 }
18.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java Thu Sep 12 11:09:20 2013 -0700 18.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java Tue Sep 17 08:21:11 2013 -0700 18.3 @@ -34,6 +34,7 @@ 18.4 import java.io.OutputStreamWriter; 18.5 import java.io.UnsupportedEncodingException; 18.6 import java.io.Writer; 18.7 +import java.nio.file.DirectoryStream; 18.8 import java.nio.file.Files; 18.9 import java.nio.file.Path; 18.10 import java.util.ArrayList; 18.11 @@ -221,8 +222,10 @@ 18.12 /** If the file is a directory, list its contents. */ 18.13 public Iterable<DocFile> list() throws IOException { 18.14 List<DocFile> files = new ArrayList<DocFile>(); 18.15 - for (Path f: Files.newDirectoryStream(file)) { 18.16 - files.add(new StandardDocFile(f)); 18.17 + try (DirectoryStream<Path> ds = Files.newDirectoryStream(file)) { 18.18 + for (Path f: ds) { 18.19 + files.add(new StandardDocFile(f)); 18.20 + } 18.21 } 18.22 return files; 18.23 }
19.1 --- a/src/share/classes/com/sun/tools/javac/Main.java Thu Sep 12 11:09:20 2013 -0700 19.2 +++ b/src/share/classes/com/sun/tools/javac/Main.java Tue Sep 17 08:21:11 2013 -0700 19.3 @@ -30,14 +30,6 @@ 19.4 /** 19.5 * The programmatic interface for the Java Programming Language 19.6 * compiler, javac. 19.7 - * 19.8 - * <p>Except for the two methods 19.9 - * {@link #compile(java.lang.String[])} 19.10 - * {@link #compile(java.lang.String[],java.io.PrintWriter)}, 19.11 - * nothing described in this source file is part of any supported 19.12 - * API. If you write code that depends on this, you do so at your own 19.13 - * risk. This code and its internal interfaces are subject to change 19.14 - * or deletion without notice. 19.15 */ 19.16 @jdk.Supported 19.17 public class Main {
20.1 --- a/src/share/classes/com/sun/tools/javac/code/Annotations.java Thu Sep 12 11:09:20 2013 -0700 20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 20.3 @@ -1,451 +0,0 @@ 20.4 -/* 20.5 - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 20.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.7 - * 20.8 - * This code is free software; you can redistribute it and/or modify it 20.9 - * under the terms of the GNU General Public License version 2 only, as 20.10 - * published by the Free Software Foundation. Oracle designates this 20.11 - * particular file as subject to the "Classpath" exception as provided 20.12 - * by Oracle in the LICENSE file that accompanied this code. 20.13 - * 20.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 20.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20.17 - * version 2 for more details (a copy is included in the LICENSE file that 20.18 - * accompanied this code). 20.19 - * 20.20 - * You should have received a copy of the GNU General Public License version 20.21 - * 2 along with this work; if not, write to the Free Software Foundation, 20.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20.23 - * 20.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20.25 - * or visit www.oracle.com if you need additional information or have any 20.26 - * questions. 20.27 - */ 20.28 - 20.29 -package com.sun.tools.javac.code; 20.30 - 20.31 -import java.util.Map; 20.32 - 20.33 -import javax.tools.JavaFileObject; 20.34 - 20.35 -import com.sun.tools.javac.comp.Annotate; 20.36 -import com.sun.tools.javac.comp.AttrContext; 20.37 -import com.sun.tools.javac.comp.Env; 20.38 -import com.sun.tools.javac.util.*; 20.39 -import com.sun.tools.javac.util.Assert; 20.40 -import com.sun.tools.javac.util.List; 20.41 -import com.sun.tools.javac.util.Log; 20.42 -import com.sun.tools.javac.util.Pair; 20.43 -import static com.sun.tools.javac.code.Kinds.PCK; 20.44 - 20.45 -/** 20.46 - * Container for all annotations (attributes in javac) on a Symbol. 20.47 - * 20.48 - * This class is explicitly mutable. Its contents will change when attributes 20.49 - * are annotated onto the Symbol. However this class depends on the facts that 20.50 - * List (in javac) is immutable. 20.51 - * 20.52 - * An instance of this class can be in one of three states: 20.53 - * 20.54 - * NOT_STARTED indicates that the Symbol this instance belongs to has not been 20.55 - * annotated (yet). Specifically if the declaration is not annotated this 20.56 - * instance will never move past NOT_STARTED. You can never go back to 20.57 - * NOT_STARTED. 20.58 - * 20.59 - * IN_PROGRESS annotations have been found on the declaration. Will be processed 20.60 - * later. You can reset to IN_PROGRESS. While IN_PROGRESS you can set the list 20.61 - * of attributes (and this moves out of the IN_PROGRESS state). 20.62 - * 20.63 - * "unnamed" this Annotations contains some attributes, possibly the final set. 20.64 - * While in this state you can only prepend or append to the attributes not set 20.65 - * it directly. You can also move back to the IN_PROGRESS state using reset(). 20.66 - * 20.67 - * <p><b>This is NOT part of any supported API. If you write code that depends 20.68 - * on this, you do so at your own risk. This code and its internal interfaces 20.69 - * are subject to change or deletion without notice.</b> 20.70 - */ 20.71 -public class Annotations { 20.72 - 20.73 - private static final List<Attribute.Compound> DECL_NOT_STARTED = List.of(null); 20.74 - private static final List<Attribute.Compound> DECL_IN_PROGRESS = List.of(null); 20.75 - 20.76 - /* 20.77 - * This field should never be null 20.78 - */ 20.79 - private List<Attribute.Compound> attributes = DECL_NOT_STARTED; 20.80 - 20.81 - /* 20.82 - * Type attributes for this symbol. 20.83 - * This field should never be null. 20.84 - */ 20.85 - private List<Attribute.TypeCompound> type_attributes = List.<Attribute.TypeCompound>nil(); 20.86 - 20.87 - /* 20.88 - * Type attributes of initializers in this class. 20.89 - * Unused if the current symbol is not a ClassSymbol. 20.90 - */ 20.91 - private List<Attribute.TypeCompound> init_type_attributes = List.<Attribute.TypeCompound>nil(); 20.92 - 20.93 - /* 20.94 - * Type attributes of class initializers in this class. 20.95 - * Unused if the current symbol is not a ClassSymbol. 20.96 - */ 20.97 - private List<Attribute.TypeCompound> clinit_type_attributes = List.<Attribute.TypeCompound>nil(); 20.98 - 20.99 - /* 20.100 - * The Symbol this Annotations instance belongs to 20.101 - */ 20.102 - private final Symbol sym; 20.103 - 20.104 - public Annotations(Symbol sym) { 20.105 - this.sym = sym; 20.106 - } 20.107 - 20.108 - public List<Attribute.Compound> getDeclarationAttributes() { 20.109 - return filterDeclSentinels(attributes); 20.110 - } 20.111 - 20.112 - public List<Attribute.TypeCompound> getTypeAttributes() { 20.113 - return type_attributes; 20.114 - } 20.115 - 20.116 - public List<Attribute.TypeCompound> getInitTypeAttributes() { 20.117 - return init_type_attributes; 20.118 - } 20.119 - 20.120 - public List<Attribute.TypeCompound> getClassInitTypeAttributes() { 20.121 - return clinit_type_attributes; 20.122 - } 20.123 - 20.124 - public void setDeclarationAttributes(List<Attribute.Compound> a) { 20.125 - Assert.check(pendingCompletion() || !isStarted()); 20.126 - if (a == null) { 20.127 - throw new NullPointerException(); 20.128 - } 20.129 - attributes = a; 20.130 - } 20.131 - 20.132 - public void setTypeAttributes(List<Attribute.TypeCompound> a) { 20.133 - if (a == null) { 20.134 - throw new NullPointerException(); 20.135 - } 20.136 - type_attributes = a; 20.137 - } 20.138 - 20.139 - public void setInitTypeAttributes(List<Attribute.TypeCompound> a) { 20.140 - if (a == null) { 20.141 - throw new NullPointerException(); 20.142 - } 20.143 - init_type_attributes = a; 20.144 - } 20.145 - 20.146 - public void setClassInitTypeAttributes(List<Attribute.TypeCompound> a) { 20.147 - if (a == null) { 20.148 - throw new NullPointerException(); 20.149 - } 20.150 - clinit_type_attributes = a; 20.151 - } 20.152 - 20.153 - public void setAttributes(Annotations other) { 20.154 - if (other == null) { 20.155 - throw new NullPointerException(); 20.156 - } 20.157 - setDeclarationAttributes(other.getDeclarationAttributes()); 20.158 - setTypeAttributes(other.getTypeAttributes()); 20.159 - setInitTypeAttributes(other.getInitTypeAttributes()); 20.160 - setClassInitTypeAttributes(other.getClassInitTypeAttributes()); 20.161 - } 20.162 - 20.163 - public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) { 20.164 - Assert.check(pendingCompletion() || (!isStarted() && sym.kind == PCK)); 20.165 - this.setDeclarationAttributes(getAttributesForCompletion(ctx)); 20.166 - } 20.167 - 20.168 - public void appendTypeAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.TypeCompound> ctx) { 20.169 - this.appendUniqueTypes(getAttributesForCompletion(ctx)); 20.170 - } 20.171 - 20.172 - private <T extends Attribute.Compound> List<T> getAttributesForCompletion( 20.173 - final Annotate.AnnotateRepeatedContext<T> ctx) { 20.174 - 20.175 - Map<Symbol.TypeSymbol, ListBuffer<T>> annotated = ctx.annotated; 20.176 - boolean atLeastOneRepeated = false; 20.177 - List<T> buf = List.<T>nil(); 20.178 - for (ListBuffer<T> lb : annotated.values()) { 20.179 - if (lb.size() == 1) { 20.180 - buf = buf.prepend(lb.first()); 20.181 - } else { // repeated 20.182 - // This will break when other subtypes of Attributs.Compound 20.183 - // are introduced, because PlaceHolder is a subtype of TypeCompound. 20.184 - T res; 20.185 - @SuppressWarnings("unchecked") 20.186 - T ph = (T) new Placeholder<T>(ctx, lb.toList(), sym); 20.187 - res = ph; 20.188 - buf = buf.prepend(res); 20.189 - atLeastOneRepeated = true; 20.190 - } 20.191 - } 20.192 - 20.193 - if (atLeastOneRepeated) { 20.194 - // The Symbol s is now annotated with a combination of 20.195 - // finished non-repeating annotations and placeholders for 20.196 - // repeating annotations. 20.197 - // 20.198 - // We need to do this in two passes because when creating 20.199 - // a container for a repeating annotation we must 20.200 - // guarantee that the @Repeatable on the 20.201 - // contained annotation is fully annotated 20.202 - // 20.203 - // The way we force this order is to do all repeating 20.204 - // annotations in a pass after all non-repeating are 20.205 - // finished. This will work because @Repeatable 20.206 - // is non-repeating and therefore will be annotated in the 20.207 - // fist pass. 20.208 - 20.209 - // Queue a pass that will replace Attribute.Placeholders 20.210 - // with Attribute.Compound (made from synthesized containers). 20.211 - ctx.annotateRepeated(new Annotate.Annotator() { 20.212 - @Override 20.213 - public String toString() { 20.214 - return "repeated annotation pass of: " + sym + " in: " + sym.owner; 20.215 - } 20.216 - 20.217 - @Override 20.218 - public void enterAnnotation() { 20.219 - complete(ctx); 20.220 - } 20.221 - }); 20.222 - } 20.223 - // Add non-repeating attributes 20.224 - return buf.reverse(); 20.225 - } 20.226 - 20.227 - public Annotations reset() { 20.228 - attributes = DECL_IN_PROGRESS; 20.229 - return this; 20.230 - } 20.231 - 20.232 - public boolean isEmpty() { 20.233 - return !isStarted() 20.234 - || pendingCompletion() 20.235 - || attributes.isEmpty(); 20.236 - } 20.237 - 20.238 - public boolean isTypesEmpty() { 20.239 - return type_attributes.isEmpty(); 20.240 - } 20.241 - 20.242 - public boolean pendingCompletion() { 20.243 - return attributes == DECL_IN_PROGRESS; 20.244 - } 20.245 - 20.246 - public Annotations append(List<Attribute.Compound> l) { 20.247 - attributes = filterDeclSentinels(attributes); 20.248 - 20.249 - if (l.isEmpty()) { 20.250 - ; // no-op 20.251 - } else if (attributes.isEmpty()) { 20.252 - attributes = l; 20.253 - } else { 20.254 - attributes = attributes.appendList(l); 20.255 - } 20.256 - return this; 20.257 - } 20.258 - 20.259 - public Annotations appendUniqueTypes(List<Attribute.TypeCompound> l) { 20.260 - if (l.isEmpty()) { 20.261 - ; // no-op 20.262 - } else if (type_attributes.isEmpty()) { 20.263 - type_attributes = l; 20.264 - } else { 20.265 - // TODO: in case we expect a large number of annotations, this 20.266 - // might be inefficient. 20.267 - for (Attribute.TypeCompound tc : l) { 20.268 - if (!type_attributes.contains(tc)) 20.269 - type_attributes = type_attributes.append(tc); 20.270 - } 20.271 - } 20.272 - return this; 20.273 - } 20.274 - 20.275 - public Annotations appendInitTypeAttributes(List<Attribute.TypeCompound> l) { 20.276 - if (l.isEmpty()) { 20.277 - ; // no-op 20.278 - } else if (init_type_attributes.isEmpty()) { 20.279 - init_type_attributes = l; 20.280 - } else { 20.281 - init_type_attributes = init_type_attributes.appendList(l); 20.282 - } 20.283 - return this; 20.284 - } 20.285 - 20.286 - public Annotations appendClassInitTypeAttributes(List<Attribute.TypeCompound> l) { 20.287 - if (l.isEmpty()) { 20.288 - ; // no-op 20.289 - } else if (clinit_type_attributes.isEmpty()) { 20.290 - clinit_type_attributes = l; 20.291 - } else { 20.292 - clinit_type_attributes = clinit_type_attributes.appendList(l); 20.293 - } 20.294 - return this; 20.295 - } 20.296 - 20.297 - public Annotations prepend(List<Attribute.Compound> l) { 20.298 - attributes = filterDeclSentinels(attributes); 20.299 - 20.300 - if (l.isEmpty()) { 20.301 - ; // no-op 20.302 - } else if (attributes.isEmpty()) { 20.303 - attributes = l; 20.304 - } else { 20.305 - attributes = attributes.prependList(l); 20.306 - } 20.307 - return this; 20.308 - } 20.309 - 20.310 - private List<Attribute.Compound> filterDeclSentinels(List<Attribute.Compound> a) { 20.311 - return (a == DECL_IN_PROGRESS || a == DECL_NOT_STARTED) 20.312 - ? List.<Attribute.Compound>nil() 20.313 - : a; 20.314 - } 20.315 - 20.316 - private boolean isStarted() { 20.317 - return attributes != DECL_NOT_STARTED; 20.318 - } 20.319 - 20.320 - private List<Attribute.Compound> getPlaceholders() { 20.321 - List<Attribute.Compound> res = List.<Attribute.Compound>nil(); 20.322 - for (Attribute.Compound a : filterDeclSentinels(attributes)) { 20.323 - if (a instanceof Placeholder) { 20.324 - res = res.prepend(a); 20.325 - } 20.326 - } 20.327 - return res.reverse(); 20.328 - } 20.329 - 20.330 - private List<Attribute.TypeCompound> getTypePlaceholders() { 20.331 - List<Attribute.TypeCompound> res = List.<Attribute.TypeCompound>nil(); 20.332 - for (Attribute.TypeCompound a : type_attributes) { 20.333 - if (a instanceof Placeholder) { 20.334 - res = res.prepend(a); 20.335 - } 20.336 - } 20.337 - return res.reverse(); 20.338 - } 20.339 - 20.340 - /* 20.341 - * Replace Placeholders for repeating annotations with their containers 20.342 - */ 20.343 - private <T extends Attribute.Compound> void complete(Annotate.AnnotateRepeatedContext<T> ctx) { 20.344 - Log log = ctx.log; 20.345 - Env<AttrContext> env = ctx.env; 20.346 - JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile); 20.347 - try { 20.348 - // TODO: can we reduce duplication in the following branches? 20.349 - if (ctx.isTypeCompound) { 20.350 - Assert.check(!isTypesEmpty()); 20.351 - 20.352 - if (isTypesEmpty()) { 20.353 - return; 20.354 - } 20.355 - 20.356 - List<Attribute.TypeCompound> result = List.nil(); 20.357 - for (Attribute.TypeCompound a : getTypeAttributes()) { 20.358 - if (a instanceof Placeholder) { 20.359 - @SuppressWarnings("unchecked") 20.360 - Placeholder<Attribute.TypeCompound> ph = (Placeholder<Attribute.TypeCompound>) a; 20.361 - Attribute.TypeCompound replacement = replaceOne(ph, ph.getRepeatedContext()); 20.362 - 20.363 - if (null != replacement) { 20.364 - result = result.prepend(replacement); 20.365 - } 20.366 - } else { 20.367 - result = result.prepend(a); 20.368 - } 20.369 - } 20.370 - 20.371 - type_attributes = result.reverse(); 20.372 - 20.373 - Assert.check(Annotations.this.getTypePlaceholders().isEmpty()); 20.374 - } else { 20.375 - Assert.check(!pendingCompletion()); 20.376 - 20.377 - if (isEmpty()) { 20.378 - return; 20.379 - } 20.380 - 20.381 - List<Attribute.Compound> result = List.nil(); 20.382 - for (Attribute.Compound a : getDeclarationAttributes()) { 20.383 - if (a instanceof Placeholder) { 20.384 - @SuppressWarnings("unchecked") 20.385 - Attribute.Compound replacement = replaceOne((Placeholder<T>) a, ctx); 20.386 - 20.387 - if (null != replacement) { 20.388 - result = result.prepend(replacement); 20.389 - } 20.390 - } else { 20.391 - result = result.prepend(a); 20.392 - } 20.393 - } 20.394 - 20.395 - attributes = result.reverse(); 20.396 - 20.397 - Assert.check(Annotations.this.getPlaceholders().isEmpty()); 20.398 - } 20.399 - } finally { 20.400 - log.useSource(oldSource); 20.401 - } 20.402 - } 20.403 - 20.404 - private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder, Annotate.AnnotateRepeatedContext<T> ctx) { 20.405 - Log log = ctx.log; 20.406 - 20.407 - // Process repeated annotations 20.408 - T validRepeated = ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym); 20.409 - 20.410 - if (validRepeated != null) { 20.411 - // Check that the container isn't manually 20.412 - // present along with repeated instances of 20.413 - // its contained annotation. 20.414 - ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym); 20.415 - if (manualContainer != null) { 20.416 - log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present", 20.417 - manualContainer.first().type.tsym); 20.418 - } 20.419 - } 20.420 - 20.421 - // A null return will delete the Placeholder 20.422 - return validRepeated; 20.423 - } 20.424 - 20.425 - private static class Placeholder<T extends Attribute.Compound> extends Attribute.TypeCompound { 20.426 - 20.427 - private final Annotate.AnnotateRepeatedContext<T> ctx; 20.428 - private final List<T> placeholderFor; 20.429 - private final Symbol on; 20.430 - 20.431 - public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) { 20.432 - super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(), 20.433 - ctx.isTypeCompound ? 20.434 - ((Attribute.TypeCompound)placeholderFor.head).position : 20.435 - null); 20.436 - this.ctx = ctx; 20.437 - this.placeholderFor = placeholderFor; 20.438 - this.on = on; 20.439 - } 20.440 - 20.441 - @Override 20.442 - public String toString() { 20.443 - return "<placeholder: " + placeholderFor + " on: " + on + ">"; 20.444 - } 20.445 - 20.446 - public List<T> getPlaceholderFor() { 20.447 - return placeholderFor; 20.448 - } 20.449 - 20.450 - public Annotate.AnnotateRepeatedContext<T> getRepeatedContext() { 20.451 - return ctx; 20.452 - } 20.453 - } 20.454 -}
21.1 --- a/src/share/classes/com/sun/tools/javac/code/DeferredLintHandler.java Thu Sep 12 11:09:20 2013 -0700 21.2 +++ b/src/share/classes/com/sun/tools/javac/code/DeferredLintHandler.java Tue Sep 17 08:21:11 2013 -0700 21.3 @@ -1,5 +1,5 @@ 21.4 /* 21.5 - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 21.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 21.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.8 * 21.9 * This code is free software; you can redistribute it and/or modify it 21.10 @@ -28,6 +28,8 @@ 21.11 import java.util.HashMap; 21.12 import java.util.Map; 21.13 21.14 +import com.sun.tools.javac.tree.EndPosTable; 21.15 +import com.sun.tools.javac.tree.JCTree; 21.16 import com.sun.tools.javac.util.Assert; 21.17 import com.sun.tools.javac.util.Context; 21.18 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 21.19 @@ -53,10 +55,13 @@ 21.20 21.21 protected DeferredLintHandler(Context context) { 21.22 context.put(deferredLintHandlerKey, this); 21.23 + this.currentPos = IMMEDIATE_POSITION; 21.24 } 21.25 21.26 - private DeferredLintHandler() {} 21.27 - 21.28 + /**An interface for deferred lint reporting - loggers passed to 21.29 + * {@link #report(LintLogger) } will be called when 21.30 + * {@link #flush(DiagnosticPosition) } is invoked. 21.31 + */ 21.32 public interface LintLogger { 21.33 void report(); 21.34 } 21.35 @@ -64,12 +69,26 @@ 21.36 private DiagnosticPosition currentPos; 21.37 private Map<DiagnosticPosition, ListBuffer<LintLogger>> loggersQueue = new HashMap<DiagnosticPosition, ListBuffer<LintLogger>>(); 21.38 21.39 + /**Associate the given logger with the current position as set by {@link #setPos(DiagnosticPosition) }. 21.40 + * Will be invoked when {@link #flush(DiagnosticPosition) } will be invoked with the same position. 21.41 + * <br> 21.42 + * Will invoke the logger synchronously if {@link #immediate() } was called 21.43 + * instead of {@link #setPos(DiagnosticPosition) }. 21.44 + */ 21.45 public void report(LintLogger logger) { 21.46 - ListBuffer<LintLogger> loggers = loggersQueue.get(currentPos); 21.47 - Assert.checkNonNull(loggers); 21.48 - loggers.append(logger); 21.49 + if (currentPos == IMMEDIATE_POSITION) { 21.50 + logger.report(); 21.51 + } else { 21.52 + ListBuffer<LintLogger> loggers = loggersQueue.get(currentPos); 21.53 + if (loggers == null) { 21.54 + loggersQueue.put(currentPos, loggers = ListBuffer.<LintLogger>lb()); 21.55 + } 21.56 + loggers.append(logger); 21.57 + } 21.58 } 21.59 21.60 + /**Invoke all {@link LintLogger}s that were associated with the provided {@code pos}. 21.61 + */ 21.62 public void flush(DiagnosticPosition pos) { 21.63 ListBuffer<LintLogger> loggers = loggersQueue.get(pos); 21.64 if (loggers != null) { 21.65 @@ -80,16 +99,46 @@ 21.66 } 21.67 } 21.68 21.69 - public DeferredLintHandler setPos(DiagnosticPosition currentPos) { 21.70 + /**Sets the current position to the provided {@code currentPos}. {@link LintLogger}s 21.71 + * passed to subsequent invocations of {@link #report(LintLogger) } will be associated 21.72 + * with the given position. 21.73 + */ 21.74 + public DiagnosticPosition setPos(DiagnosticPosition currentPos) { 21.75 + DiagnosticPosition prevPosition = this.currentPos; 21.76 this.currentPos = currentPos; 21.77 - loggersQueue.put(currentPos, ListBuffer.<LintLogger>lb()); 21.78 - return this; 21.79 + return prevPosition; 21.80 } 21.81 21.82 - public static final DeferredLintHandler immediateHandler = new DeferredLintHandler() { 21.83 + /**{@link LintLogger}s passed to subsequent invocations of 21.84 + * {@link #report(LintLogger) } will be invoked immediately. 21.85 + */ 21.86 + public DiagnosticPosition immediate() { 21.87 + return setPos(IMMEDIATE_POSITION); 21.88 + } 21.89 + 21.90 + private static final DiagnosticPosition IMMEDIATE_POSITION = new DiagnosticPosition() { 21.91 @Override 21.92 - public void report(LintLogger logger) { 21.93 - logger.report(); 21.94 + public JCTree getTree() { 21.95 + Assert.error(); 21.96 + return null; 21.97 + } 21.98 + 21.99 + @Override 21.100 + public int getStartPosition() { 21.101 + Assert.error(); 21.102 + return -1; 21.103 + } 21.104 + 21.105 + @Override 21.106 + public int getPreferredPosition() { 21.107 + Assert.error(); 21.108 + return -1; 21.109 + } 21.110 + 21.111 + @Override 21.112 + public int getEndPosition(EndPosTable endPosTable) { 21.113 + Assert.error(); 21.114 + return -1; 21.115 } 21.116 }; 21.117 }
22.1 --- a/src/share/classes/com/sun/tools/javac/code/Flags.java Thu Sep 12 11:09:20 2013 -0700 22.2 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java Tue Sep 17 08:21:11 2013 -0700 22.3 @@ -97,7 +97,6 @@ 22.4 public static final int MANDATED = 1<<15; 22.5 22.6 public static final int StandardFlags = 0x0fff; 22.7 - public static final int ModifierFlags = StandardFlags & ~INTERFACE; 22.8 22.9 // Because the following access flags are overloaded with other 22.10 // bit positions, we translate them when reading and writing class 22.11 @@ -266,6 +265,11 @@ 22.12 */ 22.13 public static final long THROWS = 1L<<47; 22.14 22.15 + /** 22.16 + * Flag that marks potentially ambiguous overloads 22.17 + */ 22.18 + public static final long POTENTIALLY_AMBIGUOUS = 1L<<48; 22.19 + 22.20 /** Modifier masks. 22.21 */ 22.22 public static final int 22.23 @@ -282,7 +286,9 @@ 22.24 SYNCHRONIZED | FINAL | STRICTFP; 22.25 public static final long 22.26 ExtendedStandardFlags = (long)StandardFlags | DEFAULT, 22.27 + ModifierFlags = ((long)StandardFlags & ~INTERFACE) | DEFAULT, 22.28 InterfaceMethodMask = ABSTRACT | STATIC | PUBLIC | STRICTFP | DEFAULT, 22.29 + AnnotationTypeElementMask = FINAL | ABSTRACT | PUBLIC | STRICTFP, 22.30 LocalVarFlags = FINAL | PARAMETER; 22.31 22.32
23.1 --- a/src/share/classes/com/sun/tools/javac/code/Lint.java Thu Sep 12 11:09:20 2013 -0700 23.2 +++ b/src/share/classes/com/sun/tools/javac/code/Lint.java Tue Sep 17 08:21:11 2013 -0700 23.3 @@ -33,9 +33,6 @@ 23.4 import com.sun.tools.javac.util.Options; 23.5 import com.sun.tools.javac.util.Pair; 23.6 23.7 -import static com.sun.tools.javac.code.Flags.*; 23.8 - 23.9 - 23.10 /** 23.11 * A class for handling -Xlint suboptions and @SuppresssWarnings. 23.12 * 23.13 @@ -81,7 +78,6 @@ 23.14 return l; 23.15 } 23.16 23.17 - 23.18 private final AugmentVisitor augmentor; 23.19 23.20 private final EnumSet<LintCategory> values; 23.21 @@ -90,7 +86,6 @@ 23.22 private static final Map<String, LintCategory> map = 23.23 new java.util.concurrent.ConcurrentHashMap<String, LintCategory>(20); 23.24 23.25 - 23.26 protected Lint(Context context) { 23.27 // initialize values according to the lint options 23.28 Options options = Options.instance(context); 23.29 @@ -175,6 +170,11 @@ 23.30 OPTIONS("options"), 23.31 23.32 /** 23.33 + * Warn about issues regarding method overloads. 23.34 + */ 23.35 + OVERLOADS("overloads"), 23.36 + 23.37 + /** 23.38 * Warn about issues regarding method overrides. 23.39 */ 23.40 OVERRIDES("overrides"),
24.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Sep 12 11:09:20 2013 -0700 24.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Sep 17 08:21:11 2013 -0700 24.3 @@ -46,6 +46,7 @@ 24.4 import static com.sun.tools.javac.code.TypeTag.CLASS; 24.5 import static com.sun.tools.javac.code.TypeTag.FORALL; 24.6 import static com.sun.tools.javac.code.TypeTag.TYPEVAR; 24.7 +import com.sun.tools.javac.tree.JCTree.JCVariableDecl; 24.8 24.9 /** Root class for Java symbols. It contains subclasses 24.10 * for specific sorts of symbols, such as variables, methods and operators, 24.11 @@ -98,9 +99,9 @@ 24.12 // <editor-fold defaultstate="collapsed" desc="annotations"> 24.13 24.14 /** The attributes of this symbol are contained in this 24.15 - * Annotations. The Annotations instance is NOT immutable. 24.16 + * SymbolMetadata. The SymbolMetadata instance is NOT immutable. 24.17 */ 24.18 - protected Annotations annotations; 24.19 + protected SymbolMetadata annotations; 24.20 24.21 /** An accessor method for the attributes of this symbol. 24.22 * Attributes of class symbols should be accessed through the accessor 24.23 @@ -217,19 +218,19 @@ 24.24 public void setTypeAttributes(List<Attribute.TypeCompound> a) { 24.25 if (annotations != null || a.nonEmpty()) { 24.26 if (annotations == null) 24.27 - annotations = new Annotations(this); 24.28 + annotations = new SymbolMetadata(this); 24.29 annotations.setTypeAttributes(a); 24.30 } 24.31 } 24.32 24.33 - private Annotations initedAnnos() { 24.34 + private SymbolMetadata initedAnnos() { 24.35 if (annotations == null) 24.36 - annotations = new Annotations(this); 24.37 + annotations = new SymbolMetadata(this); 24.38 return annotations; 24.39 } 24.40 24.41 /** This method is intended for debugging only. */ 24.42 - public Annotations getAnnotations() { 24.43 + public SymbolMetadata getAnnotations() { 24.44 return annotations; 24.45 } 24.46 24.47 @@ -852,7 +853,7 @@ 24.48 private void mergeAttributes() { 24.49 if (annotations == null && 24.50 package_info.annotations != null) { 24.51 - annotations = new Annotations(this); 24.52 + annotations = new SymbolMetadata(this); 24.53 annotations.setAttributes(package_info.annotations); 24.54 } 24.55 } 24.56 @@ -1167,11 +1168,11 @@ 24.57 24.58 public void setLazyConstValue(final Env<AttrContext> env, 24.59 final Attr attr, 24.60 - final JCTree.JCExpression initializer) 24.61 + final JCVariableDecl variable) 24.62 { 24.63 setData(new Callable<Object>() { 24.64 public Object call() { 24.65 - return attr.attribLazyConstantValue(env, initializer, type); 24.66 + return attr.attribLazyConstantValue(env, variable, type); 24.67 } 24.68 }); 24.69 }
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java Tue Sep 17 08:21:11 2013 -0700 25.3 @@ -0,0 +1,451 @@ 25.4 +/* 25.5 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.7 + * 25.8 + * This code is free software; you can redistribute it and/or modify it 25.9 + * under the terms of the GNU General Public License version 2 only, as 25.10 + * published by the Free Software Foundation. Oracle designates this 25.11 + * particular file as subject to the "Classpath" exception as provided 25.12 + * by Oracle in the LICENSE file that accompanied this code. 25.13 + * 25.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 25.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 25.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25.17 + * version 2 for more details (a copy is included in the LICENSE file that 25.18 + * accompanied this code). 25.19 + * 25.20 + * You should have received a copy of the GNU General Public License version 25.21 + * 2 along with this work; if not, write to the Free Software Foundation, 25.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 25.23 + * 25.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 25.25 + * or visit www.oracle.com if you need additional information or have any 25.26 + * questions. 25.27 + */ 25.28 + 25.29 +package com.sun.tools.javac.code; 25.30 + 25.31 +import java.util.Map; 25.32 + 25.33 +import javax.tools.JavaFileObject; 25.34 + 25.35 +import com.sun.tools.javac.comp.Annotate; 25.36 +import com.sun.tools.javac.comp.AttrContext; 25.37 +import com.sun.tools.javac.comp.Env; 25.38 +import com.sun.tools.javac.util.*; 25.39 +import com.sun.tools.javac.util.Assert; 25.40 +import com.sun.tools.javac.util.List; 25.41 +import com.sun.tools.javac.util.Log; 25.42 +import com.sun.tools.javac.util.Pair; 25.43 +import static com.sun.tools.javac.code.Kinds.PCK; 25.44 + 25.45 +/** 25.46 + * Container for all annotations (attributes in javac) on a Symbol. 25.47 + * 25.48 + * This class is explicitly mutable. Its contents will change when attributes 25.49 + * are annotated onto the Symbol. However this class depends on the facts that 25.50 + * List (in javac) is immutable. 25.51 + * 25.52 + * An instance of this class can be in one of three states: 25.53 + * 25.54 + * NOT_STARTED indicates that the Symbol this instance belongs to has not been 25.55 + * annotated (yet). Specifically if the declaration is not annotated this 25.56 + * instance will never move past NOT_STARTED. You can never go back to 25.57 + * NOT_STARTED. 25.58 + * 25.59 + * IN_PROGRESS annotations have been found on the declaration. Will be processed 25.60 + * later. You can reset to IN_PROGRESS. While IN_PROGRESS you can set the list 25.61 + * of attributes (and this moves out of the IN_PROGRESS state). 25.62 + * 25.63 + * "unnamed" this SymbolMetadata contains some attributes, possibly the final set. 25.64 + * While in this state you can only prepend or append to the attributes not set 25.65 + * it directly. You can also move back to the IN_PROGRESS state using reset(). 25.66 + * 25.67 + * <p><b>This is NOT part of any supported API. If you write code that depends 25.68 + * on this, you do so at your own risk. This code and its internal interfaces 25.69 + * are subject to change or deletion without notice.</b> 25.70 + */ 25.71 +public class SymbolMetadata { 25.72 + 25.73 + private static final List<Attribute.Compound> DECL_NOT_STARTED = List.of(null); 25.74 + private static final List<Attribute.Compound> DECL_IN_PROGRESS = List.of(null); 25.75 + 25.76 + /* 25.77 + * This field should never be null 25.78 + */ 25.79 + private List<Attribute.Compound> attributes = DECL_NOT_STARTED; 25.80 + 25.81 + /* 25.82 + * Type attributes for this symbol. 25.83 + * This field should never be null. 25.84 + */ 25.85 + private List<Attribute.TypeCompound> type_attributes = List.<Attribute.TypeCompound>nil(); 25.86 + 25.87 + /* 25.88 + * Type attributes of initializers in this class. 25.89 + * Unused if the current symbol is not a ClassSymbol. 25.90 + */ 25.91 + private List<Attribute.TypeCompound> init_type_attributes = List.<Attribute.TypeCompound>nil(); 25.92 + 25.93 + /* 25.94 + * Type attributes of class initializers in this class. 25.95 + * Unused if the current symbol is not a ClassSymbol. 25.96 + */ 25.97 + private List<Attribute.TypeCompound> clinit_type_attributes = List.<Attribute.TypeCompound>nil(); 25.98 + 25.99 + /* 25.100 + * The Symbol this SymbolMetadata instance belongs to 25.101 + */ 25.102 + private final Symbol sym; 25.103 + 25.104 + public SymbolMetadata(Symbol sym) { 25.105 + this.sym = sym; 25.106 + } 25.107 + 25.108 + public List<Attribute.Compound> getDeclarationAttributes() { 25.109 + return filterDeclSentinels(attributes); 25.110 + } 25.111 + 25.112 + public List<Attribute.TypeCompound> getTypeAttributes() { 25.113 + return type_attributes; 25.114 + } 25.115 + 25.116 + public List<Attribute.TypeCompound> getInitTypeAttributes() { 25.117 + return init_type_attributes; 25.118 + } 25.119 + 25.120 + public List<Attribute.TypeCompound> getClassInitTypeAttributes() { 25.121 + return clinit_type_attributes; 25.122 + } 25.123 + 25.124 + public void setDeclarationAttributes(List<Attribute.Compound> a) { 25.125 + Assert.check(pendingCompletion() || !isStarted()); 25.126 + if (a == null) { 25.127 + throw new NullPointerException(); 25.128 + } 25.129 + attributes = a; 25.130 + } 25.131 + 25.132 + public void setTypeAttributes(List<Attribute.TypeCompound> a) { 25.133 + if (a == null) { 25.134 + throw new NullPointerException(); 25.135 + } 25.136 + type_attributes = a; 25.137 + } 25.138 + 25.139 + public void setInitTypeAttributes(List<Attribute.TypeCompound> a) { 25.140 + if (a == null) { 25.141 + throw new NullPointerException(); 25.142 + } 25.143 + init_type_attributes = a; 25.144 + } 25.145 + 25.146 + public void setClassInitTypeAttributes(List<Attribute.TypeCompound> a) { 25.147 + if (a == null) { 25.148 + throw new NullPointerException(); 25.149 + } 25.150 + clinit_type_attributes = a; 25.151 + } 25.152 + 25.153 + public void setAttributes(SymbolMetadata other) { 25.154 + if (other == null) { 25.155 + throw new NullPointerException(); 25.156 + } 25.157 + setDeclarationAttributes(other.getDeclarationAttributes()); 25.158 + setTypeAttributes(other.getTypeAttributes()); 25.159 + setInitTypeAttributes(other.getInitTypeAttributes()); 25.160 + setClassInitTypeAttributes(other.getClassInitTypeAttributes()); 25.161 + } 25.162 + 25.163 + public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) { 25.164 + Assert.check(pendingCompletion() || (!isStarted() && sym.kind == PCK)); 25.165 + this.setDeclarationAttributes(getAttributesForCompletion(ctx)); 25.166 + } 25.167 + 25.168 + public void appendTypeAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.TypeCompound> ctx) { 25.169 + this.appendUniqueTypes(getAttributesForCompletion(ctx)); 25.170 + } 25.171 + 25.172 + private <T extends Attribute.Compound> List<T> getAttributesForCompletion( 25.173 + final Annotate.AnnotateRepeatedContext<T> ctx) { 25.174 + 25.175 + Map<Symbol.TypeSymbol, ListBuffer<T>> annotated = ctx.annotated; 25.176 + boolean atLeastOneRepeated = false; 25.177 + List<T> buf = List.<T>nil(); 25.178 + for (ListBuffer<T> lb : annotated.values()) { 25.179 + if (lb.size() == 1) { 25.180 + buf = buf.prepend(lb.first()); 25.181 + } else { // repeated 25.182 + // This will break when other subtypes of Attributs.Compound 25.183 + // are introduced, because PlaceHolder is a subtype of TypeCompound. 25.184 + T res; 25.185 + @SuppressWarnings("unchecked") 25.186 + T ph = (T) new Placeholder<T>(ctx, lb.toList(), sym); 25.187 + res = ph; 25.188 + buf = buf.prepend(res); 25.189 + atLeastOneRepeated = true; 25.190 + } 25.191 + } 25.192 + 25.193 + if (atLeastOneRepeated) { 25.194 + // The Symbol s is now annotated with a combination of 25.195 + // finished non-repeating annotations and placeholders for 25.196 + // repeating annotations. 25.197 + // 25.198 + // We need to do this in two passes because when creating 25.199 + // a container for a repeating annotation we must 25.200 + // guarantee that the @Repeatable on the 25.201 + // contained annotation is fully annotated 25.202 + // 25.203 + // The way we force this order is to do all repeating 25.204 + // annotations in a pass after all non-repeating are 25.205 + // finished. This will work because @Repeatable 25.206 + // is non-repeating and therefore will be annotated in the 25.207 + // fist pass. 25.208 + 25.209 + // Queue a pass that will replace Attribute.Placeholders 25.210 + // with Attribute.Compound (made from synthesized containers). 25.211 + ctx.annotateRepeated(new Annotate.Annotator() { 25.212 + @Override 25.213 + public String toString() { 25.214 + return "repeated annotation pass of: " + sym + " in: " + sym.owner; 25.215 + } 25.216 + 25.217 + @Override 25.218 + public void enterAnnotation() { 25.219 + complete(ctx); 25.220 + } 25.221 + }); 25.222 + } 25.223 + // Add non-repeating attributes 25.224 + return buf.reverse(); 25.225 + } 25.226 + 25.227 + public SymbolMetadata reset() { 25.228 + attributes = DECL_IN_PROGRESS; 25.229 + return this; 25.230 + } 25.231 + 25.232 + public boolean isEmpty() { 25.233 + return !isStarted() 25.234 + || pendingCompletion() 25.235 + || attributes.isEmpty(); 25.236 + } 25.237 + 25.238 + public boolean isTypesEmpty() { 25.239 + return type_attributes.isEmpty(); 25.240 + } 25.241 + 25.242 + public boolean pendingCompletion() { 25.243 + return attributes == DECL_IN_PROGRESS; 25.244 + } 25.245 + 25.246 + public SymbolMetadata append(List<Attribute.Compound> l) { 25.247 + attributes = filterDeclSentinels(attributes); 25.248 + 25.249 + if (l.isEmpty()) { 25.250 + ; // no-op 25.251 + } else if (attributes.isEmpty()) { 25.252 + attributes = l; 25.253 + } else { 25.254 + attributes = attributes.appendList(l); 25.255 + } 25.256 + return this; 25.257 + } 25.258 + 25.259 + public SymbolMetadata appendUniqueTypes(List<Attribute.TypeCompound> l) { 25.260 + if (l.isEmpty()) { 25.261 + ; // no-op 25.262 + } else if (type_attributes.isEmpty()) { 25.263 + type_attributes = l; 25.264 + } else { 25.265 + // TODO: in case we expect a large number of annotations, this 25.266 + // might be inefficient. 25.267 + for (Attribute.TypeCompound tc : l) { 25.268 + if (!type_attributes.contains(tc)) 25.269 + type_attributes = type_attributes.append(tc); 25.270 + } 25.271 + } 25.272 + return this; 25.273 + } 25.274 + 25.275 + public SymbolMetadata appendInitTypeAttributes(List<Attribute.TypeCompound> l) { 25.276 + if (l.isEmpty()) { 25.277 + ; // no-op 25.278 + } else if (init_type_attributes.isEmpty()) { 25.279 + init_type_attributes = l; 25.280 + } else { 25.281 + init_type_attributes = init_type_attributes.appendList(l); 25.282 + } 25.283 + return this; 25.284 + } 25.285 + 25.286 + public SymbolMetadata appendClassInitTypeAttributes(List<Attribute.TypeCompound> l) { 25.287 + if (l.isEmpty()) { 25.288 + ; // no-op 25.289 + } else if (clinit_type_attributes.isEmpty()) { 25.290 + clinit_type_attributes = l; 25.291 + } else { 25.292 + clinit_type_attributes = clinit_type_attributes.appendList(l); 25.293 + } 25.294 + return this; 25.295 + } 25.296 + 25.297 + public SymbolMetadata prepend(List<Attribute.Compound> l) { 25.298 + attributes = filterDeclSentinels(attributes); 25.299 + 25.300 + if (l.isEmpty()) { 25.301 + ; // no-op 25.302 + } else if (attributes.isEmpty()) { 25.303 + attributes = l; 25.304 + } else { 25.305 + attributes = attributes.prependList(l); 25.306 + } 25.307 + return this; 25.308 + } 25.309 + 25.310 + private List<Attribute.Compound> filterDeclSentinels(List<Attribute.Compound> a) { 25.311 + return (a == DECL_IN_PROGRESS || a == DECL_NOT_STARTED) 25.312 + ? List.<Attribute.Compound>nil() 25.313 + : a; 25.314 + } 25.315 + 25.316 + private boolean isStarted() { 25.317 + return attributes != DECL_NOT_STARTED; 25.318 + } 25.319 + 25.320 + private List<Attribute.Compound> getPlaceholders() { 25.321 + List<Attribute.Compound> res = List.<Attribute.Compound>nil(); 25.322 + for (Attribute.Compound a : filterDeclSentinels(attributes)) { 25.323 + if (a instanceof Placeholder) { 25.324 + res = res.prepend(a); 25.325 + } 25.326 + } 25.327 + return res.reverse(); 25.328 + } 25.329 + 25.330 + private List<Attribute.TypeCompound> getTypePlaceholders() { 25.331 + List<Attribute.TypeCompound> res = List.<Attribute.TypeCompound>nil(); 25.332 + for (Attribute.TypeCompound a : type_attributes) { 25.333 + if (a instanceof Placeholder) { 25.334 + res = res.prepend(a); 25.335 + } 25.336 + } 25.337 + return res.reverse(); 25.338 + } 25.339 + 25.340 + /* 25.341 + * Replace Placeholders for repeating annotations with their containers 25.342 + */ 25.343 + private <T extends Attribute.Compound> void complete(Annotate.AnnotateRepeatedContext<T> ctx) { 25.344 + Log log = ctx.log; 25.345 + Env<AttrContext> env = ctx.env; 25.346 + JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile); 25.347 + try { 25.348 + // TODO: can we reduce duplication in the following branches? 25.349 + if (ctx.isTypeCompound) { 25.350 + Assert.check(!isTypesEmpty()); 25.351 + 25.352 + if (isTypesEmpty()) { 25.353 + return; 25.354 + } 25.355 + 25.356 + List<Attribute.TypeCompound> result = List.nil(); 25.357 + for (Attribute.TypeCompound a : getTypeAttributes()) { 25.358 + if (a instanceof Placeholder) { 25.359 + @SuppressWarnings("unchecked") 25.360 + Placeholder<Attribute.TypeCompound> ph = (Placeholder<Attribute.TypeCompound>) a; 25.361 + Attribute.TypeCompound replacement = replaceOne(ph, ph.getRepeatedContext()); 25.362 + 25.363 + if (null != replacement) { 25.364 + result = result.prepend(replacement); 25.365 + } 25.366 + } else { 25.367 + result = result.prepend(a); 25.368 + } 25.369 + } 25.370 + 25.371 + type_attributes = result.reverse(); 25.372 + 25.373 + Assert.check(SymbolMetadata.this.getTypePlaceholders().isEmpty()); 25.374 + } else { 25.375 + Assert.check(!pendingCompletion()); 25.376 + 25.377 + if (isEmpty()) { 25.378 + return; 25.379 + } 25.380 + 25.381 + List<Attribute.Compound> result = List.nil(); 25.382 + for (Attribute.Compound a : getDeclarationAttributes()) { 25.383 + if (a instanceof Placeholder) { 25.384 + @SuppressWarnings("unchecked") 25.385 + Attribute.Compound replacement = replaceOne((Placeholder<T>) a, ctx); 25.386 + 25.387 + if (null != replacement) { 25.388 + result = result.prepend(replacement); 25.389 + } 25.390 + } else { 25.391 + result = result.prepend(a); 25.392 + } 25.393 + } 25.394 + 25.395 + attributes = result.reverse(); 25.396 + 25.397 + Assert.check(SymbolMetadata.this.getPlaceholders().isEmpty()); 25.398 + } 25.399 + } finally { 25.400 + log.useSource(oldSource); 25.401 + } 25.402 + } 25.403 + 25.404 + private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder, Annotate.AnnotateRepeatedContext<T> ctx) { 25.405 + Log log = ctx.log; 25.406 + 25.407 + // Process repeated annotations 25.408 + T validRepeated = ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym); 25.409 + 25.410 + if (validRepeated != null) { 25.411 + // Check that the container isn't manually 25.412 + // present along with repeated instances of 25.413 + // its contained annotation. 25.414 + ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym); 25.415 + if (manualContainer != null) { 25.416 + log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present", 25.417 + manualContainer.first().type.tsym); 25.418 + } 25.419 + } 25.420 + 25.421 + // A null return will delete the Placeholder 25.422 + return validRepeated; 25.423 + } 25.424 + 25.425 + private static class Placeholder<T extends Attribute.Compound> extends Attribute.TypeCompound { 25.426 + 25.427 + private final Annotate.AnnotateRepeatedContext<T> ctx; 25.428 + private final List<T> placeholderFor; 25.429 + private final Symbol on; 25.430 + 25.431 + public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) { 25.432 + super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(), 25.433 + ctx.isTypeCompound ? 25.434 + ((Attribute.TypeCompound)placeholderFor.head).position : 25.435 + null); 25.436 + this.ctx = ctx; 25.437 + this.placeholderFor = placeholderFor; 25.438 + this.on = on; 25.439 + } 25.440 + 25.441 + @Override 25.442 + public String toString() { 25.443 + return "<placeholder: " + placeholderFor + " on: " + on + ">"; 25.444 + } 25.445 + 25.446 + public List<T> getPlaceholderFor() { 25.447 + return placeholderFor; 25.448 + } 25.449 + 25.450 + public Annotate.AnnotateRepeatedContext<T> getRepeatedContext() { 25.451 + return ctx; 25.452 + } 25.453 + } 25.454 +}
26.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Thu Sep 12 11:09:20 2013 -0700 26.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Tue Sep 17 08:21:11 2013 -0700 26.3 @@ -3055,7 +3055,7 @@ 26.4 /** 26.5 * Does t have the same bounds for quantified variables as s? 26.6 */ 26.7 - boolean hasSameBounds(ForAll t, ForAll s) { 26.8 + public boolean hasSameBounds(ForAll t, ForAll s) { 26.9 List<Type> l1 = t.tvars; 26.10 List<Type> l2 = s.tvars; 26.11 while (l1.nonEmpty() && l2.nonEmpty() &&
27.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Sep 12 11:09:20 2013 -0700 27.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Sep 17 08:21:11 2013 -0700 27.3 @@ -748,19 +748,11 @@ 27.4 * @see VarSymbol#setLazyConstValue 27.5 */ 27.6 public Object attribLazyConstantValue(Env<AttrContext> env, 27.7 - JCTree.JCExpression initializer, 27.8 + JCVariableDecl variable, 27.9 Type type) { 27.10 27.11 - /* When this env was created, it didn't have the correct lint nor had 27.12 - * annotations has been processed. 27.13 - * But now at this phase we have already processed annotations and the 27.14 - * correct lint must have been set in chk, so we should use that one to 27.15 - * attribute the initializer. 27.16 - */ 27.17 - Lint prevLint = env.info.lint; 27.18 - env.info.lint = chk.getLint(); 27.19 - 27.20 - JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile); 27.21 + DiagnosticPosition prevLintPos 27.22 + = deferredLintHandler.setPos(variable.pos()); 27.23 27.24 try { 27.25 // Use null as symbol to not attach the type annotation to any symbol. 27.26 @@ -768,17 +760,16 @@ 27.27 // to the symbol. 27.28 // This prevents having multiple type annotations, just because of 27.29 // lazy constant value evaluation. 27.30 - memberEnter.typeAnnotate(initializer, env, null); 27.31 + memberEnter.typeAnnotate(variable.init, env, null, variable.pos()); 27.32 annotate.flush(); 27.33 - Type itype = attribExpr(initializer, env, type); 27.34 + Type itype = attribExpr(variable.init, env, type); 27.35 if (itype.constValue() != null) { 27.36 return coerce(itype, type).constValue(); 27.37 } else { 27.38 return null; 27.39 } 27.40 } finally { 27.41 - env.info.lint = prevLint; 27.42 - log.useSource(prevSource); 27.43 + deferredLintHandler.setPos(prevLintPos); 27.44 } 27.45 } 27.46 27.47 @@ -1012,7 +1003,7 @@ 27.48 } 27.49 27.50 // Attribute all type annotations in the body 27.51 - memberEnter.typeAnnotate(tree.body, localEnv, m); 27.52 + memberEnter.typeAnnotate(tree.body, localEnv, m, null); 27.53 annotate.flush(); 27.54 27.55 // Attribute method body. 27.56 @@ -1042,7 +1033,7 @@ 27.57 } else { 27.58 if (tree.init != null) { 27.59 // Field initializer expression need to be entered. 27.60 - memberEnter.typeAnnotate(tree.init, env, tree.sym); 27.61 + memberEnter.typeAnnotate(tree.init, env, tree.sym, tree.pos()); 27.62 annotate.flush(); 27.63 } 27.64 } 27.65 @@ -1056,18 +1047,16 @@ 27.66 ((JCLambda)env.tree).paramKind == JCLambda.ParameterKind.IMPLICIT && 27.67 (tree.sym.flags() & PARAMETER) != 0; 27.68 chk.validate(tree.vartype, env, !isImplicitLambdaParameter); 27.69 - deferredLintHandler.flush(tree.pos()); 27.70 27.71 try { 27.72 + v.getConstValue(); // ensure compile-time constant initializer is evaluated 27.73 + deferredLintHandler.flush(tree.pos()); 27.74 chk.checkDeprecatedAnnotation(tree.pos(), v); 27.75 27.76 if (tree.init != null) { 27.77 - if ((v.flags_field & FINAL) != 0 && 27.78 - memberEnter.needsLazyConstValue(tree.init)) { 27.79 - // In this case, `v' is final. Ensure that it's initializer is 27.80 - // evaluated. 27.81 - v.getConstValue(); // ensure initializer is evaluated 27.82 - } else { 27.83 + if ((v.flags_field & FINAL) == 0 || 27.84 + !memberEnter.needsLazyConstValue(tree.init)) { 27.85 + // Not a compile-time constant 27.86 // Attribute initializer in a new environment 27.87 // with the declared variable as owner. 27.88 // Check that initializer conforms to variable's declared type. 27.89 @@ -1106,7 +1095,7 @@ 27.90 if ((tree.flags & STATIC) != 0) localEnv.info.staticLevel++; 27.91 27.92 // Attribute all type annotations in the block 27.93 - memberEnter.typeAnnotate(tree, localEnv, localEnv.info.scope.owner); 27.94 + memberEnter.typeAnnotate(tree, localEnv, localEnv.info.scope.owner, null); 27.95 annotate.flush(); 27.96 27.97 { 27.98 @@ -2319,30 +2308,37 @@ 27.99 boolean needsRecovery = 27.100 resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK; 27.101 try { 27.102 - Type target = pt(); 27.103 + Type currentTarget = pt(); 27.104 List<Type> explicitParamTypes = null; 27.105 if (that.paramKind == JCLambda.ParameterKind.EXPLICIT) { 27.106 //attribute lambda parameters 27.107 attribStats(that.params, localEnv); 27.108 explicitParamTypes = TreeInfo.types(that.params); 27.109 - target = infer.instantiateFunctionalInterface(that, target, explicitParamTypes, resultInfo.checkContext); 27.110 } 27.111 27.112 Type lambdaType; 27.113 if (pt() != Type.recoveryType) { 27.114 - target = targetChecker.visit(target, that); 27.115 - lambdaType = types.findDescriptorType(target); 27.116 + /* We need to adjust the target. If the target is an 27.117 + * intersection type, for example: SAM & I1 & I2 ... 27.118 + * the target will be updated to SAM 27.119 + */ 27.120 + currentTarget = targetChecker.visit(currentTarget, that); 27.121 + if (explicitParamTypes != null) { 27.122 + currentTarget = infer.instantiateFunctionalInterface(that, 27.123 + currentTarget, explicitParamTypes, resultInfo.checkContext); 27.124 + } 27.125 + lambdaType = types.findDescriptorType(currentTarget); 27.126 } else { 27.127 - target = Type.recoveryType; 27.128 + currentTarget = Type.recoveryType; 27.129 lambdaType = fallbackDescriptorType(that); 27.130 } 27.131 27.132 - setFunctionalInfo(localEnv, that, pt(), lambdaType, target, resultInfo.checkContext); 27.133 + setFunctionalInfo(localEnv, that, pt(), lambdaType, currentTarget, resultInfo.checkContext); 27.134 27.135 if (lambdaType.hasTag(FORALL)) { 27.136 //lambda expression target desc cannot be a generic method 27.137 resultInfo.checkContext.report(that, diags.fragment("invalid.generic.lambda.target", 27.138 - lambdaType, kindName(target.tsym), target.tsym)); 27.139 + lambdaType, kindName(currentTarget.tsym), currentTarget.tsym)); 27.140 result = that.type = types.createErrorType(pt()); 27.141 return; 27.142 } 27.143 @@ -2376,7 +2372,7 @@ 27.144 27.145 if (arityMismatch) { 27.146 resultInfo.checkContext.report(that, diags.fragment("incompatible.arg.types.in.lambda")); 27.147 - result = that.type = types.createErrorType(target); 27.148 + result = that.type = types.createErrorType(currentTarget); 27.149 return; 27.150 } 27.151 } 27.152 @@ -2396,38 +2392,14 @@ 27.153 new ResultInfo(VAL, lambdaType.getReturnType(), funcContext); 27.154 localEnv.info.returnResult = bodyResultInfo; 27.155 27.156 - Log.DeferredDiagnosticHandler lambdaDeferredHandler = new Log.DeferredDiagnosticHandler(log); 27.157 - try { 27.158 - if (that.getBodyKind() == JCLambda.BodyKind.EXPRESSION) { 27.159 - attribTree(that.getBody(), localEnv, bodyResultInfo); 27.160 - } else { 27.161 - JCBlock body = (JCBlock)that.body; 27.162 - attribStats(body.stats, localEnv); 27.163 - } 27.164 - 27.165 - if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) { 27.166 - //check for errors in lambda body 27.167 - for (JCDiagnostic deferredDiag : lambdaDeferredHandler.getDiagnostics()) { 27.168 - if (deferredDiag.getKind() == JCDiagnostic.Kind.ERROR) { 27.169 - resultInfo.checkContext 27.170 - .report(that, diags.fragment("bad.arg.types.in.lambda", TreeInfo.types(that.params), 27.171 - deferredDiag)); //hidden diag parameter 27.172 - //we mark the lambda as erroneous - this is crucial in the recovery step 27.173 - //as parameter-dependent type error won't be reported in that stage, 27.174 - //meaning that a lambda will be deemed erroeneous only if there is 27.175 - //a target-independent error (which will cause method diagnostic 27.176 - //to be skipped). 27.177 - result = that.type = types.createErrorType(target); 27.178 - return; 27.179 - } 27.180 - } 27.181 - } 27.182 - } finally { 27.183 - lambdaDeferredHandler.reportDeferredDiagnostics(); 27.184 - log.popDiagnosticHandler(lambdaDeferredHandler); 27.185 + if (that.getBodyKind() == JCLambda.BodyKind.EXPRESSION) { 27.186 + attribTree(that.getBody(), localEnv, bodyResultInfo); 27.187 + } else { 27.188 + JCBlock body = (JCBlock)that.body; 27.189 + attribStats(body.stats, localEnv); 27.190 } 27.191 27.192 - result = check(that, target, VAL, resultInfo); 27.193 + result = check(that, currentTarget, VAL, resultInfo); 27.194 27.195 boolean isSpeculativeRound = 27.196 resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE; 27.197 @@ -2435,12 +2407,20 @@ 27.198 preFlow(that); 27.199 flow.analyzeLambda(env, that, make, isSpeculativeRound); 27.200 27.201 - checkLambdaCompatible(that, lambdaType, resultInfo.checkContext, isSpeculativeRound); 27.202 + checkLambdaCompatible(that, lambdaType, resultInfo.checkContext); 27.203 27.204 if (!isSpeculativeRound) { 27.205 - checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType, target); 27.206 + //add thrown types as bounds to the thrown types free variables if needed: 27.207 + if (resultInfo.checkContext.inferenceContext().free(lambdaType.getThrownTypes())) { 27.208 + List<Type> inferredThrownTypes = flow.analyzeLambdaThrownTypes(env, that, make); 27.209 + List<Type> thrownTypes = resultInfo.checkContext.inferenceContext().asFree(lambdaType.getThrownTypes()); 27.210 + 27.211 + chk.unhandled(inferredThrownTypes, thrownTypes); 27.212 + } 27.213 + 27.214 + checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType, currentTarget); 27.215 } 27.216 - result = check(that, target, VAL, resultInfo); 27.217 + result = check(that, currentTarget, VAL, resultInfo); 27.218 } catch (Types.FunctionDescriptorLookupError ex) { 27.219 JCDiagnostic cause = ex.getDiagnostic(); 27.220 resultInfo.checkContext.report(that, cause); 27.221 @@ -2604,10 +2584,9 @@ 27.222 * Lambda compatibility. Check that given return types, thrown types, parameter types 27.223 * are compatible with the expected functional interface descriptor. This means that: 27.224 * (i) parameter types must be identical to those of the target descriptor; (ii) return 27.225 - * types must be compatible with the return type of the expected descriptor; 27.226 - * (iii) finish inference of thrown types if required. 27.227 + * types must be compatible with the return type of the expected descriptor. 27.228 */ 27.229 - private void checkLambdaCompatible(JCLambda tree, Type descriptor, CheckContext checkContext, boolean speculativeAttr) { 27.230 + private void checkLambdaCompatible(JCLambda tree, Type descriptor, CheckContext checkContext) { 27.231 Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType()); 27.232 27.233 //return values have already been checked - but if lambda has no return 27.234 @@ -2624,11 +2603,6 @@ 27.235 if (!types.isSameTypes(argTypes, TreeInfo.types(tree.params))) { 27.236 checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda")); 27.237 } 27.238 - 27.239 - if (!speculativeAttr) { 27.240 - List<Type> thrownTypes = checkContext.inferenceContext().asFree(descriptor.getThrownTypes()); 27.241 - chk.unhandled(tree.inferredThrownTypes == null ? List.<Type>nil() : tree.inferredThrownTypes, thrownTypes); 27.242 - } 27.243 } 27.244 27.245 private Env<AttrContext> lambdaEnv(JCLambda that, Env<AttrContext> env) { 27.246 @@ -2664,6 +2638,13 @@ 27.247 27.248 if (that.getMode() == JCMemberReference.ReferenceMode.NEW) { 27.249 exprType = chk.checkConstructorRefType(that.expr, exprType); 27.250 + if (!exprType.isErroneous() && 27.251 + exprType.isRaw() && 27.252 + that.typeargs != null) { 27.253 + log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()), 27.254 + diags.fragment("mref.infer.and.explicit.params")); 27.255 + exprType = types.createErrorType(exprType); 27.256 + } 27.257 } 27.258 27.259 if (exprType.isErroneous()) { 27.260 @@ -3731,7 +3712,7 @@ 27.261 * Check that method arguments conform to its instantiation. 27.262 **/ 27.263 public Type checkMethod(Type site, 27.264 - Symbol sym, 27.265 + final Symbol sym, 27.266 ResultInfo resultInfo, 27.267 Env<AttrContext> env, 27.268 final List<JCExpression> argtrees, 27.269 @@ -3820,8 +3801,19 @@ 27.270 resultInfo.checkContext.report(env.tree.pos(), ex.getDiagnostic()); 27.271 return types.createErrorType(site); 27.272 } catch (Resolve.InapplicableMethodException ex) { 27.273 - Assert.error(ex.getDiagnostic().getMessage(Locale.getDefault())); 27.274 - return null; 27.275 + final JCDiagnostic diag = ex.getDiagnostic(); 27.276 + Resolve.InapplicableSymbolError errSym = rs.new InapplicableSymbolError(null) { 27.277 + @Override 27.278 + protected Pair<Symbol, JCDiagnostic> errCandidate() { 27.279 + return new Pair<Symbol, JCDiagnostic>(sym, diag); 27.280 + } 27.281 + }; 27.282 + List<Type> argtypes2 = Type.map(argtypes, 27.283 + rs.new ResolveDeferredRecoveryMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase)); 27.284 + JCDiagnostic errDiag = errSym.getDiagnostic(JCDiagnostic.DiagnosticType.ERROR, 27.285 + env.tree, sym, site, sym.name, argtypes2, typeargtypes); 27.286 + log.report(errDiag); 27.287 + return types.createErrorType(site); 27.288 } 27.289 } 27.290 27.291 @@ -4206,6 +4198,7 @@ 27.292 ResultInfo prevReturnRes = env.info.returnResult; 27.293 27.294 try { 27.295 + deferredLintHandler.flush(env.tree); 27.296 env.info.returnResult = null; 27.297 // java.lang.Enum may not be subclassed by a non-enum 27.298 if (st.tsym == syms.enumSym &&
28.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Sep 12 11:09:20 2013 -0700 28.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Sep 17 08:21:11 2013 -0700 28.3 @@ -148,7 +148,7 @@ 28.4 sunApiHandler = new MandatoryWarningHandler(log, verboseSunApi, 28.5 enforceMandatoryWarnings, "sunapi", null); 28.6 28.7 - deferredLintHandler = DeferredLintHandler.immediateHandler; 28.8 + deferredLintHandler = DeferredLintHandler.instance(context); 28.9 } 28.10 28.11 /** Switch: generics enabled? 28.12 @@ -218,20 +218,6 @@ 28.13 return prev; 28.14 } 28.15 28.16 - /* This idiom should be used only in cases when it is needed to set the lint 28.17 - * of an environment that has been created in a phase previous to annotations 28.18 - * processing. 28.19 - */ 28.20 - Lint getLint() { 28.21 - return lint; 28.22 - } 28.23 - 28.24 - DeferredLintHandler setDeferredLintHandler(DeferredLintHandler newDeferredLintHandler) { 28.25 - DeferredLintHandler prev = deferredLintHandler; 28.26 - deferredLintHandler = newDeferredLintHandler; 28.27 - return prev; 28.28 - } 28.29 - 28.30 MethodSymbol setMethod(MethodSymbol newMethod) { 28.31 MethodSymbol prev = method; 28.32 method = newMethod; 28.33 @@ -582,14 +568,19 @@ 28.34 /** Check for redundant casts (i.e. where source type is a subtype of target type) 28.35 * The problem should only be reported for non-292 cast 28.36 */ 28.37 - public void checkRedundantCast(Env<AttrContext> env, JCTypeCast tree) { 28.38 - if (!tree.type.isErroneous() && 28.39 - (env.info.lint == null || env.info.lint.isEnabled(Lint.LintCategory.CAST)) 28.40 + public void checkRedundantCast(Env<AttrContext> env, final JCTypeCast tree) { 28.41 + if (!tree.type.isErroneous() 28.42 && types.isSameType(tree.expr.type, tree.clazz.type) 28.43 && !(ignoreAnnotatedCasts && TreeInfo.containsTypeAnnotation(tree.clazz)) 28.44 && !is292targetTypeCast(tree)) { 28.45 - log.warning(Lint.LintCategory.CAST, 28.46 - tree.pos(), "redundant.cast", tree.expr.type); 28.47 + deferredLintHandler.report(new DeferredLintHandler.LintLogger() { 28.48 + @Override 28.49 + public void report() { 28.50 + if (lint.isEnabled(Lint.LintCategory.CAST)) 28.51 + log.warning(Lint.LintCategory.CAST, 28.52 + tree.pos(), "redundant.cast", tree.expr.type); 28.53 + } 28.54 + }); 28.55 } 28.56 } 28.57 //where 28.58 @@ -1050,6 +1041,7 @@ 28.59 long checkFlags(DiagnosticPosition pos, long flags, Symbol sym, JCTree tree) { 28.60 long mask; 28.61 long implicit = 0; 28.62 + 28.63 switch (sym.kind) { 28.64 case VAR: 28.65 if (sym.owner.kind != TYP) 28.66 @@ -1070,7 +1062,10 @@ 28.67 } else 28.68 mask = ConstructorFlags; 28.69 } else if ((sym.owner.flags_field & INTERFACE) != 0) { 28.70 - if ((flags & (DEFAULT | STATIC)) != 0) { 28.71 + if ((sym.owner.flags_field & ANNOTATION) != 0) { 28.72 + mask = AnnotationTypeElementMask; 28.73 + implicit = PUBLIC | ABSTRACT; 28.74 + } else if ((flags & (DEFAULT | STATIC)) != 0) { 28.75 mask = InterfaceMethodMask; 28.76 implicit = PUBLIC; 28.77 if ((flags & DEFAULT) != 0) { 28.78 @@ -1079,8 +1074,7 @@ 28.79 } else { 28.80 mask = implicit = InterfaceMethodFlags; 28.81 } 28.82 - } 28.83 - else { 28.84 + } else { 28.85 mask = MethodFlags; 28.86 } 28.87 // Imply STRICTFP if owner has STRICTFP set. 28.88 @@ -2368,7 +2362,10 @@ 28.89 //for each method m1 that is overridden (directly or indirectly) 28.90 //by method 'sym' in 'site'... 28.91 for (Symbol m1 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) { 28.92 - if (!sym.overrides(m1, site.tsym, types, false)) continue; 28.93 + if (!sym.overrides(m1, site.tsym, types, false)) { 28.94 + checkPotentiallyAmbiguousOverloads(pos, site, sym, (MethodSymbol)m1); 28.95 + continue; 28.96 + } 28.97 //...check each method m2 that is a member of 'site' 28.98 for (Symbol m2 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) { 28.99 if (m2 == m1) continue; 28.100 @@ -2406,14 +2403,17 @@ 28.101 for (Symbol s : types.membersClosure(site, true).getElementsByName(sym.name, cf)) { 28.102 //if (i) the signature of 'sym' is not a subsignature of m1 (seen as 28.103 //a member of 'site') and (ii) 'sym' has the same erasure as m1, issue an error 28.104 - if (!types.isSubSignature(sym.type, types.memberType(site, s), allowStrictMethodClashCheck) && 28.105 - types.hasSameArgs(s.erasure(types), sym.erasure(types))) { 28.106 - log.error(pos, 28.107 - "name.clash.same.erasure.no.hide", 28.108 - sym, sym.location(), 28.109 - s, s.location()); 28.110 - return; 28.111 - } 28.112 + if (!types.isSubSignature(sym.type, types.memberType(site, s), allowStrictMethodClashCheck)) { 28.113 + if (types.hasSameArgs(s.erasure(types), sym.erasure(types))) { 28.114 + log.error(pos, 28.115 + "name.clash.same.erasure.no.hide", 28.116 + sym, sym.location(), 28.117 + s, s.location()); 28.118 + return; 28.119 + } else { 28.120 + checkPotentiallyAmbiguousOverloads(pos, site, sym, (MethodSymbol)s); 28.121 + } 28.122 + } 28.123 } 28.124 } 28.125 28.126 @@ -2496,6 +2496,62 @@ 28.127 } 28.128 } 28.129 28.130 + /** 28.131 + * Report warnings for potentially ambiguous method declarations. Two declarations 28.132 + * are potentially ambiguous if they feature two unrelated functional interface 28.133 + * in same argument position (in which case, a call site passing an implicit 28.134 + * lambda would be ambiguous). 28.135 + */ 28.136 + void checkPotentiallyAmbiguousOverloads(DiagnosticPosition pos, Type site, 28.137 + MethodSymbol msym1, MethodSymbol msym2) { 28.138 + if (msym1 != msym2 && 28.139 + allowDefaultMethods && 28.140 + lint.isEnabled(LintCategory.OVERLOADS) && 28.141 + (msym1.flags() & POTENTIALLY_AMBIGUOUS) == 0 && 28.142 + (msym2.flags() & POTENTIALLY_AMBIGUOUS) == 0) { 28.143 + Type mt1 = types.memberType(site, msym1); 28.144 + Type mt2 = types.memberType(site, msym2); 28.145 + //if both generic methods, adjust type variables 28.146 + if (mt1.hasTag(FORALL) && mt2.hasTag(FORALL) && 28.147 + types.hasSameBounds((ForAll)mt1, (ForAll)mt2)) { 28.148 + mt2 = types.subst(mt2, ((ForAll)mt2).tvars, ((ForAll)mt1).tvars); 28.149 + } 28.150 + //expand varargs methods if needed 28.151 + int maxLength = Math.max(mt1.getParameterTypes().length(), mt2.getParameterTypes().length()); 28.152 + List<Type> args1 = rs.adjustArgs(mt1.getParameterTypes(), msym1, maxLength, true); 28.153 + List<Type> args2 = rs.adjustArgs(mt2.getParameterTypes(), msym2, maxLength, true); 28.154 + //if arities don't match, exit 28.155 + if (args1.length() != args2.length()) return; 28.156 + boolean potentiallyAmbiguous = false; 28.157 + while (args1.nonEmpty() && args2.nonEmpty()) { 28.158 + Type s = args1.head; 28.159 + Type t = args2.head; 28.160 + if (!types.isSubtype(t, s) && !types.isSubtype(s, t)) { 28.161 + if (types.isFunctionalInterface(s) && types.isFunctionalInterface(t) && 28.162 + types.findDescriptorType(s).getParameterTypes().length() > 0 && 28.163 + types.findDescriptorType(s).getParameterTypes().length() == 28.164 + types.findDescriptorType(t).getParameterTypes().length()) { 28.165 + potentiallyAmbiguous = true; 28.166 + } else { 28.167 + break; 28.168 + } 28.169 + } 28.170 + args1 = args1.tail; 28.171 + args2 = args2.tail; 28.172 + } 28.173 + if (potentiallyAmbiguous) { 28.174 + //we found two incompatible functional interfaces with same arity 28.175 + //this means a call site passing an implicit lambda would be ambigiuous 28.176 + msym1.flags_field |= POTENTIALLY_AMBIGUOUS; 28.177 + msym2.flags_field |= POTENTIALLY_AMBIGUOUS; 28.178 + log.warning(LintCategory.OVERLOADS, pos, "potentially.ambiguous.overload", 28.179 + msym1, msym1.location(), 28.180 + msym2, msym2.location()); 28.181 + return; 28.182 + } 28.183 + } 28.184 + } 28.185 + 28.186 /** Report a conflict between a user symbol and a synthetic symbol. 28.187 */ 28.188 private void syntheticError(DiagnosticPosition pos, Symbol sym) { 28.189 @@ -3275,7 +3331,9 @@ 28.190 (e.sym.flags() & CLASH) == 0 && 28.191 sym.kind == e.sym.kind && 28.192 sym.name != names.error && 28.193 - (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) { 28.194 + (sym.kind != MTH || 28.195 + types.hasSameArgs(sym.type, e.sym.type) || 28.196 + types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) { 28.197 if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) { 28.198 varargsDuplicateError(pos, sym, e.sym); 28.199 return true;
29.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Thu Sep 12 11:09:20 2013 -0700 29.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Tue Sep 17 08:21:11 2013 -0700 29.3 @@ -25,6 +25,7 @@ 29.4 29.5 package com.sun.tools.javac.comp; 29.6 29.7 +import com.sun.source.tree.MemberReferenceTree; 29.8 import com.sun.tools.javac.code.*; 29.9 import com.sun.tools.javac.tree.*; 29.10 import com.sun.tools.javac.util.*; 29.11 @@ -39,7 +40,9 @@ 29.12 29.13 29.14 import java.util.ArrayList; 29.15 +import java.util.Collections; 29.16 import java.util.EnumSet; 29.17 +import java.util.LinkedHashMap; 29.18 import java.util.LinkedHashSet; 29.19 import java.util.Map; 29.20 import java.util.Set; 29.21 @@ -98,7 +101,7 @@ 29.22 emptyDeferredAttrContext = 29.23 new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) { 29.24 @Override 29.25 - void addDeferredAttrNode(DeferredType dt, ResultInfo ri, List<Type> stuckVars) { 29.26 + void addDeferredAttrNode(DeferredType dt, ResultInfo ri, DeferredStuckPolicy deferredStuckPolicy) { 29.27 Assert.error("Empty deferred context!"); 29.28 } 29.29 @Override 29.30 @@ -149,15 +152,15 @@ 29.31 29.32 class Entry { 29.33 JCTree speculativeTree; 29.34 - Resolve.MethodResolutionPhase phase; 29.35 + ResultInfo resultInfo; 29.36 29.37 - public Entry(JCTree speculativeTree, MethodResolutionPhase phase) { 29.38 + public Entry(JCTree speculativeTree, ResultInfo resultInfo) { 29.39 this.speculativeTree = speculativeTree; 29.40 - this.phase = phase; 29.41 + this.resultInfo = resultInfo; 29.42 } 29.43 29.44 - boolean matches(Resolve.MethodResolutionPhase phase) { 29.45 - return this.phase == phase; 29.46 + boolean matches(MethodResolutionPhase phase) { 29.47 + return resultInfo.checkContext.deferredAttrContext().phase == phase; 29.48 } 29.49 } 29.50 29.51 @@ -178,12 +181,13 @@ 29.52 * Stores a speculative cache entry corresponding to given symbol 29.53 * and resolution phase 29.54 */ 29.55 - void put(Symbol msym, JCTree speculativeTree, MethodResolutionPhase phase) { 29.56 + void put(JCTree speculativeTree, ResultInfo resultInfo) { 29.57 + Symbol msym = resultInfo.checkContext.deferredAttrContext().msym; 29.58 List<Entry> entries = cache.get(msym); 29.59 if (entries == null) { 29.60 entries = List.nil(); 29.61 } 29.62 - cache.put(msym, entries.prepend(new Entry(speculativeTree, phase))); 29.63 + cache.put(msym, entries.prepend(new Entry(speculativeTree, resultInfo))); 29.64 } 29.65 } 29.66 29.67 @@ -203,15 +207,24 @@ 29.68 * attribution round must follow one or more speculative rounds. 29.69 */ 29.70 Type check(ResultInfo resultInfo) { 29.71 - return check(resultInfo, stuckVars(tree, env, resultInfo), basicCompleter); 29.72 + DeferredStuckPolicy deferredStuckPolicy; 29.73 + if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) { 29.74 + deferredStuckPolicy = dummyStuckPolicy; 29.75 + } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) { 29.76 + deferredStuckPolicy = new OverloadStuckPolicy(resultInfo, this); 29.77 + } else { 29.78 + deferredStuckPolicy = new CheckStuckPolicy(resultInfo, this); 29.79 + } 29.80 + return check(resultInfo, deferredStuckPolicy, basicCompleter); 29.81 } 29.82 29.83 - Type check(ResultInfo resultInfo, List<Type> stuckVars, DeferredTypeCompleter deferredTypeCompleter) { 29.84 + private Type check(ResultInfo resultInfo, DeferredStuckPolicy deferredStuckPolicy, 29.85 + DeferredTypeCompleter deferredTypeCompleter) { 29.86 DeferredAttrContext deferredAttrContext = 29.87 resultInfo.checkContext.deferredAttrContext(); 29.88 Assert.check(deferredAttrContext != emptyDeferredAttrContext); 29.89 - if (stuckVars.nonEmpty()) { 29.90 - deferredAttrContext.addDeferredAttrNode(this, resultInfo, stuckVars); 29.91 + if (deferredStuckPolicy.isStuck()) { 29.92 + deferredAttrContext.addDeferredAttrNode(this, resultInfo, deferredStuckPolicy); 29.93 return Type.noType; 29.94 } else { 29.95 try { 29.96 @@ -236,6 +249,7 @@ 29.97 Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext); 29.98 } 29.99 29.100 + 29.101 /** 29.102 * A basic completer for deferred types. This completer type-checks a deferred type 29.103 * using attribution; depending on the attribution mode, this could be either standard 29.104 @@ -249,7 +263,7 @@ 29.105 //speculative rounds... 29.106 Assert.check(dt.mode == null || dt.mode == AttrMode.SPECULATIVE); 29.107 JCTree speculativeTree = attribSpeculative(dt.tree, dt.env, resultInfo); 29.108 - dt.speculativeCache.put(deferredAttrContext.msym, speculativeTree, deferredAttrContext.phase); 29.109 + dt.speculativeCache.put(speculativeTree, resultInfo); 29.110 return speculativeTree.type; 29.111 case CHECK: 29.112 Assert.check(dt.mode != null); 29.113 @@ -268,6 +282,45 @@ 29.114 }; 29.115 29.116 /** 29.117 + * Policy for detecting stuck expressions. Different criteria might cause 29.118 + * an expression to be judged as stuck, depending on whether the check 29.119 + * is performed during overload resolution or after most specific. 29.120 + */ 29.121 + interface DeferredStuckPolicy { 29.122 + /** 29.123 + * Has the policy detected that a given expression should be considered stuck? 29.124 + */ 29.125 + boolean isStuck(); 29.126 + /** 29.127 + * Get the set of inference variables a given expression depends upon. 29.128 + */ 29.129 + Set<Type> stuckVars(); 29.130 + /** 29.131 + * Get the set of inference variables which might get new constraints 29.132 + * if a given expression is being type-checked. 29.133 + */ 29.134 + Set<Type> depVars(); 29.135 + } 29.136 + 29.137 + /** 29.138 + * Basic stuck policy; an expression is never considered to be stuck. 29.139 + */ 29.140 + DeferredStuckPolicy dummyStuckPolicy = new DeferredStuckPolicy() { 29.141 + @Override 29.142 + public boolean isStuck() { 29.143 + return false; 29.144 + } 29.145 + @Override 29.146 + public Set<Type> stuckVars() { 29.147 + return Collections.emptySet(); 29.148 + } 29.149 + @Override 29.150 + public Set<Type> depVars() { 29.151 + return Collections.emptySet(); 29.152 + } 29.153 + }; 29.154 + 29.155 + /** 29.156 * The 'mode' in which the deferred type is to be type-checked 29.157 */ 29.158 public enum AttrMode { 29.159 @@ -388,8 +441,9 @@ 29.160 * Adds a node to the list of deferred attribution nodes - used by Resolve.rawCheckArgumentsApplicable 29.161 * Nodes added this way act as 'roots' for the out-of-order method checking process. 29.162 */ 29.163 - void addDeferredAttrNode(final DeferredType dt, ResultInfo resultInfo, List<Type> stuckVars) { 29.164 - deferredAttrNodes.add(new DeferredAttrNode(dt, resultInfo, stuckVars)); 29.165 + void addDeferredAttrNode(final DeferredType dt, ResultInfo resultInfo, 29.166 + DeferredStuckPolicy deferredStuckPolicy) { 29.167 + deferredAttrNodes.add(new DeferredAttrNode(dt, resultInfo, deferredStuckPolicy)); 29.168 } 29.169 29.170 /** 29.171 @@ -400,23 +454,52 @@ 29.172 */ 29.173 void complete() { 29.174 while (!deferredAttrNodes.isEmpty()) { 29.175 - Set<Type> stuckVars = new LinkedHashSet<Type>(); 29.176 + Map<Type, Set<Type>> depVarsMap = new LinkedHashMap<Type, Set<Type>>(); 29.177 + List<Type> stuckVars = List.nil(); 29.178 boolean progress = false; 29.179 //scan a defensive copy of the node list - this is because a deferred 29.180 //attribution round can add new nodes to the list 29.181 for (DeferredAttrNode deferredAttrNode : List.from(deferredAttrNodes)) { 29.182 if (!deferredAttrNode.process(this)) { 29.183 - stuckVars.addAll(deferredAttrNode.stuckVars); 29.184 + List<Type> restStuckVars = 29.185 + List.from(deferredAttrNode.deferredStuckPolicy.stuckVars()) 29.186 + .intersect(inferenceContext.restvars()); 29.187 + stuckVars = stuckVars.prependList(restStuckVars); 29.188 + //update dependency map 29.189 + for (Type t : List.from(deferredAttrNode.deferredStuckPolicy.depVars()) 29.190 + .intersect(inferenceContext.restvars())) { 29.191 + Set<Type> prevDeps = depVarsMap.get(t); 29.192 + if (prevDeps == null) { 29.193 + prevDeps = new LinkedHashSet<Type>(); 29.194 + depVarsMap.put(t, prevDeps); 29.195 + } 29.196 + prevDeps.addAll(restStuckVars); 29.197 + } 29.198 } else { 29.199 deferredAttrNodes.remove(deferredAttrNode); 29.200 progress = true; 29.201 } 29.202 } 29.203 if (!progress) { 29.204 + DeferredAttrContext dac = this; 29.205 + while (dac != emptyDeferredAttrContext) { 29.206 + if (dac.mode == AttrMode.SPECULATIVE) { 29.207 + //unsticking does not take place during overload 29.208 + break; 29.209 + } 29.210 + dac = dac.parent; 29.211 + } 29.212 //remove all variables that have already been instantiated 29.213 //from the list of stuck variables 29.214 - inferenceContext.solveAny(List.from(stuckVars), warn); 29.215 - inferenceContext.notifyChange(); 29.216 + try { 29.217 + inferenceContext.solveAny(stuckVars, depVarsMap, warn); 29.218 + inferenceContext.notifyChange(); 29.219 + } catch (Infer.GraphStrategy.NodeNotFoundException ex) { 29.220 + //this means that we are in speculative mode and the 29.221 + //set of contraints are too tight for progess to be made. 29.222 + //Just leave the remaining expressions as stuck. 29.223 + break; 29.224 + } 29.225 } 29.226 } 29.227 } 29.228 @@ -426,7 +509,7 @@ 29.229 * Class representing a deferred attribution node. It keeps track of 29.230 * a deferred type, along with the expected target type information. 29.231 */ 29.232 - class DeferredAttrNode implements Infer.FreeTypeListener { 29.233 + class DeferredAttrNode { 29.234 29.235 /** underlying deferred type */ 29.236 DeferredType dt; 29.237 @@ -434,22 +517,13 @@ 29.238 /** underlying target type information */ 29.239 ResultInfo resultInfo; 29.240 29.241 - /** list of uninferred inference variables causing this node to be stuck */ 29.242 - List<Type> stuckVars; 29.243 + /** stuck policy associated with this node */ 29.244 + DeferredStuckPolicy deferredStuckPolicy; 29.245 29.246 - DeferredAttrNode(DeferredType dt, ResultInfo resultInfo, List<Type> stuckVars) { 29.247 + DeferredAttrNode(DeferredType dt, ResultInfo resultInfo, DeferredStuckPolicy deferredStuckPolicy) { 29.248 this.dt = dt; 29.249 this.resultInfo = resultInfo; 29.250 - this.stuckVars = stuckVars; 29.251 - if (!stuckVars.isEmpty()) { 29.252 - resultInfo.checkContext.inferenceContext().addFreeTypeListener(stuckVars, this); 29.253 - } 29.254 - } 29.255 - 29.256 - @Override 29.257 - public void typesInferred(InferenceContext inferenceContext) { 29.258 - stuckVars = List.nil(); 29.259 - resultInfo = resultInfo.dup(inferenceContext.asInstType(resultInfo.pt)); 29.260 + this.deferredStuckPolicy = deferredStuckPolicy; 29.261 } 29.262 29.263 /** 29.264 @@ -457,24 +531,41 @@ 29.265 * Invariant: a stuck node cannot be processed. 29.266 */ 29.267 @SuppressWarnings("fallthrough") 29.268 - boolean process(DeferredAttrContext deferredAttrContext) { 29.269 + boolean process(final DeferredAttrContext deferredAttrContext) { 29.270 switch (deferredAttrContext.mode) { 29.271 case SPECULATIVE: 29.272 - dt.check(resultInfo, List.<Type>nil(), new StructuralStuckChecker()); 29.273 - return true; 29.274 + if (deferredStuckPolicy.isStuck()) { 29.275 + dt.check(resultInfo, dummyStuckPolicy, new StructuralStuckChecker()); 29.276 + return true; 29.277 + } else { 29.278 + Assert.error("Cannot get here"); 29.279 + } 29.280 case CHECK: 29.281 - if (stuckVars.nonEmpty()) { 29.282 + if (deferredStuckPolicy.isStuck()) { 29.283 //stuck expression - see if we can propagate 29.284 if (deferredAttrContext.parent != emptyDeferredAttrContext && 29.285 - Type.containsAny(deferredAttrContext.parent.inferenceContext.inferencevars, List.from(stuckVars))) { 29.286 - deferredAttrContext.parent.deferredAttrNodes.add(this); 29.287 - dt.check(resultInfo, List.<Type>nil(), dummyCompleter); 29.288 + Type.containsAny(deferredAttrContext.parent.inferenceContext.inferencevars, 29.289 + List.from(deferredStuckPolicy.stuckVars()))) { 29.290 + deferredAttrContext.parent.addDeferredAttrNode(dt, 29.291 + resultInfo.dup(new Check.NestedCheckContext(resultInfo.checkContext) { 29.292 + @Override 29.293 + public InferenceContext inferenceContext() { 29.294 + return deferredAttrContext.parent.inferenceContext; 29.295 + } 29.296 + @Override 29.297 + public DeferredAttrContext deferredAttrContext() { 29.298 + return deferredAttrContext.parent; 29.299 + } 29.300 + }), deferredStuckPolicy); 29.301 + dt.tree.type = Type.stuckType; 29.302 return true; 29.303 } else { 29.304 return false; 29.305 } 29.306 } else { 29.307 - dt.check(resultInfo, stuckVars, basicCompleter); 29.308 + ResultInfo instResultInfo = 29.309 + resultInfo.dup(deferredAttrContext.inferenceContext.asInstType(resultInfo.pt)); 29.310 + dt.check(instResultInfo, dummyStuckPolicy, basicCompleter); 29.311 return true; 29.312 } 29.313 default: 29.314 @@ -489,12 +580,14 @@ 29.315 29.316 ResultInfo resultInfo; 29.317 InferenceContext inferenceContext; 29.318 + Env<AttrContext> env; 29.319 29.320 public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) { 29.321 this.resultInfo = resultInfo; 29.322 this.inferenceContext = deferredAttrContext.inferenceContext; 29.323 + this.env = dt.env; 29.324 dt.tree.accept(this); 29.325 - dt.speculativeCache.put(deferredAttrContext.msym, stuckTree, deferredAttrContext.phase); 29.326 + dt.speculativeCache.put(stuckTree, resultInfo); 29.327 return Type.noType; 29.328 } 29.329 29.330 @@ -541,15 +634,25 @@ 29.331 } catch (Types.FunctionDescriptorLookupError ex) { 29.332 checkContext.report(null, ex.getDiagnostic()); 29.333 } 29.334 - switch (tree.sym.kind) { 29.335 + Env<AttrContext> localEnv = env.dup(tree); 29.336 + JCExpression exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), localEnv, 29.337 + attr.memberReferenceQualifierResult(tree)); 29.338 + ListBuffer<Type> argtypes = ListBuffer.lb(); 29.339 + for (Type t : types.findDescriptorType(pt).getParameterTypes()) { 29.340 + argtypes.append(Type.noType); 29.341 + } 29.342 + JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree); 29.343 + mref2.expr = exprTree; 29.344 + Pair<Symbol, ?> lookupRes = 29.345 + rs.resolveMemberReference(tree, localEnv, mref2, exprTree.type, 29.346 + tree.name, argtypes.toList(), null, true, rs.arityMethodCheck, inferenceContext); 29.347 + switch (lookupRes.fst.kind) { 29.348 //note: as argtypes are erroneous types, type-errors must 29.349 //have been caused by arity mismatch 29.350 case Kinds.ABSENT_MTH: 29.351 case Kinds.WRONG_MTH: 29.352 case Kinds.WRONG_MTHS: 29.353 - case Kinds.STATICERR: 29.354 - case Kinds.MISSING_ENCL: 29.355 - checkContext.report(null, diags.fragment("incompatible.arg.types.in.mref")); 29.356 + checkContext.report(tree, diags.fragment("incompatible.arg.types.in.mref")); 29.357 } 29.358 } 29.359 } 29.360 @@ -575,18 +678,12 @@ 29.361 infer.emptyContext, emptyDeferredAttrContext, types.noWarnings); 29.362 } 29.363 29.364 - protected boolean validState(DeferredType dt) { 29.365 - return dt.mode != null && 29.366 - deferredAttrContext.mode.ordinal() <= dt.mode.ordinal(); 29.367 - } 29.368 - 29.369 @Override 29.370 public Type apply(Type t) { 29.371 if (!t.hasTag(DEFERRED)) { 29.372 return t.map(this); 29.373 } else { 29.374 DeferredType dt = (DeferredType)t; 29.375 - Assert.check(validState(dt)); 29.376 return typeOf(dt); 29.377 } 29.378 } 29.379 @@ -623,11 +720,6 @@ 29.380 recover(dt) : owntype; 29.381 } 29.382 29.383 - @Override 29.384 - protected boolean validState(DeferredType dt) { 29.385 - return true; 29.386 - } 29.387 - 29.388 /** 29.389 * Synthesize a type for a deferred type that hasn't been previously 29.390 * reduced to an ordinary type. Functional deferred types and conditionals 29.391 @@ -647,25 +739,6 @@ 29.392 } 29.393 29.394 /** 29.395 - * Retrieves the list of inference variables that need to be inferred before 29.396 - * an AST node can be type-checked 29.397 - */ 29.398 - @SuppressWarnings("fallthrough") 29.399 - List<Type> stuckVars(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) { 29.400 - if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) { 29.401 - return List.nil(); 29.402 - } else { 29.403 - return stuckVarsInternal(tree, resultInfo.pt, env, resultInfo.checkContext.inferenceContext()); 29.404 - } 29.405 - } 29.406 - //where 29.407 - private List<Type> stuckVarsInternal(JCTree tree, Type pt, Env<AttrContext> env, Infer.InferenceContext inferenceContext) { 29.408 - StuckChecker sc = new StuckChecker(pt, env, inferenceContext); 29.409 - sc.scan(tree); 29.410 - return List.from(sc.stuckVars); 29.411 - } 29.412 - 29.413 - /** 29.414 * A special tree scanner that would only visit portions of a given tree. 29.415 * The set of nodes visited by the scanner can be customized at construction-time. 29.416 */ 29.417 @@ -737,17 +810,41 @@ 29.418 * inferring types that make some of the nested expressions incompatible 29.419 * with their corresponding instantiated target 29.420 */ 29.421 - class StuckChecker extends PolyScanner { 29.422 + class CheckStuckPolicy extends PolyScanner implements DeferredStuckPolicy, Infer.FreeTypeListener { 29.423 29.424 Type pt; 29.425 - Env<AttrContext> env; 29.426 Infer.InferenceContext inferenceContext; 29.427 Set<Type> stuckVars = new LinkedHashSet<Type>(); 29.428 + Set<Type> depVars = new LinkedHashSet<Type>(); 29.429 29.430 - StuckChecker(Type pt, Env<AttrContext> env, Infer.InferenceContext inferenceContext) { 29.431 - this.pt = pt; 29.432 - this.env = env; 29.433 - this.inferenceContext = inferenceContext; 29.434 + @Override 29.435 + public boolean isStuck() { 29.436 + return !stuckVars.isEmpty(); 29.437 + } 29.438 + 29.439 + @Override 29.440 + public Set<Type> stuckVars() { 29.441 + return stuckVars; 29.442 + } 29.443 + 29.444 + @Override 29.445 + public Set<Type> depVars() { 29.446 + return depVars; 29.447 + } 29.448 + 29.449 + public CheckStuckPolicy(ResultInfo resultInfo, DeferredType dt) { 29.450 + this.pt = resultInfo.pt; 29.451 + this.inferenceContext = resultInfo.checkContext.inferenceContext(); 29.452 + scan(dt.tree); 29.453 + if (!stuckVars.isEmpty()) { 29.454 + resultInfo.checkContext.inferenceContext() 29.455 + .addFreeTypeListener(List.from(stuckVars), this); 29.456 + } 29.457 + } 29.458 + 29.459 + @Override 29.460 + public void typesInferred(InferenceContext inferenceContext) { 29.461 + stuckVars.clear(); 29.462 } 29.463 29.464 @Override 29.465 @@ -763,6 +860,7 @@ 29.466 if (tree.paramKind == JCLambda.ParameterKind.IMPLICIT && 29.467 freeArgVars.nonEmpty()) { 29.468 stuckVars.addAll(freeArgVars); 29.469 + depVars.addAll(inferenceContext.freeVarsIn(descType.getReturnType())); 29.470 } 29.471 scanLambdaBody(tree, descType.getReturnType()); 29.472 } 29.473 @@ -780,41 +878,34 @@ 29.474 29.475 Type descType = types.findDescriptorType(pt); 29.476 List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes()); 29.477 - Env<AttrContext> localEnv = env.dup(tree, env.info.dup()); 29.478 - if (freeArgVars.nonEmpty()) { 29.479 - //perform arity-based check 29.480 - JCExpression exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), localEnv, 29.481 - attr.memberReferenceQualifierResult(tree)); 29.482 - ListBuffer<Type> argtypes = ListBuffer.lb(); 29.483 - for (Type t : descType.getParameterTypes()) { 29.484 - argtypes.append(Type.noType); 29.485 - } 29.486 - JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree); 29.487 - mref2.expr = exprTree; 29.488 - Pair<Symbol, ReferenceLookupHelper> lookupRes = 29.489 - rs.resolveMemberReference(tree, localEnv, mref2, exprTree.type, 29.490 - tree.name, argtypes.toList(), null, true, rs.arityMethodCheck, 29.491 - inferenceContext); 29.492 - Symbol res = tree.sym = lookupRes.fst; 29.493 - if (res.kind >= Kinds.ERRONEOUS || 29.494 - res.type.hasTag(FORALL) || 29.495 - (res.flags() & Flags.VARARGS) != 0 || 29.496 - (TreeInfo.isStaticSelector(exprTree, tree.name.table.names) && 29.497 - exprTree.type.isRaw())) { 29.498 - stuckVars.addAll(freeArgVars); 29.499 - } 29.500 + if (freeArgVars.nonEmpty() && 29.501 + tree.overloadKind == JCMemberReference.OverloadKind.OVERLOADED) { 29.502 + stuckVars.addAll(freeArgVars); 29.503 + depVars.addAll(inferenceContext.freeVarsIn(descType.getReturnType())); 29.504 } 29.505 } 29.506 29.507 void scanLambdaBody(JCLambda lambda, final Type pt) { 29.508 if (lambda.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) { 29.509 - stuckVars.addAll(stuckVarsInternal(lambda.body, pt, env, inferenceContext)); 29.510 + Type prevPt = this.pt; 29.511 + try { 29.512 + this.pt = pt; 29.513 + scan(lambda.body); 29.514 + } finally { 29.515 + this.pt = prevPt; 29.516 + } 29.517 } else { 29.518 LambdaReturnScanner lambdaScanner = new LambdaReturnScanner() { 29.519 @Override 29.520 public void visitReturn(JCReturn tree) { 29.521 if (tree.expr != null) { 29.522 - stuckVars.addAll(stuckVarsInternal(tree.expr, pt, env, inferenceContext)); 29.523 + Type prevPt = CheckStuckPolicy.this.pt; 29.524 + try { 29.525 + CheckStuckPolicy.this.pt = pt; 29.526 + CheckStuckPolicy.this.scan(tree.expr); 29.527 + } finally { 29.528 + CheckStuckPolicy.this.pt = prevPt; 29.529 + } 29.530 } 29.531 } 29.532 }; 29.533 @@ -824,6 +915,42 @@ 29.534 } 29.535 29.536 /** 29.537 + * This visitor is used to check that structural expressions conform 29.538 + * to their target - this step is required as inference could end up 29.539 + * inferring types that make some of the nested expressions incompatible 29.540 + * with their corresponding instantiated target 29.541 + */ 29.542 + class OverloadStuckPolicy extends CheckStuckPolicy implements DeferredStuckPolicy { 29.543 + 29.544 + boolean stuck; 29.545 + 29.546 + @Override 29.547 + public boolean isStuck() { 29.548 + return super.isStuck() || stuck; 29.549 + } 29.550 + 29.551 + public OverloadStuckPolicy(ResultInfo resultInfo, DeferredType dt) { 29.552 + super(resultInfo, dt); 29.553 + } 29.554 + 29.555 + @Override 29.556 + public void visitLambda(JCLambda tree) { 29.557 + super.visitLambda(tree); 29.558 + if (tree.paramKind == JCLambda.ParameterKind.IMPLICIT) { 29.559 + stuck = true; 29.560 + } 29.561 + } 29.562 + 29.563 + @Override 29.564 + public void visitReference(JCMemberReference tree) { 29.565 + super.visitReference(tree); 29.566 + if (tree.overloadKind == JCMemberReference.OverloadKind.OVERLOADED) { 29.567 + stuck = true; 29.568 + } 29.569 + } 29.570 + } 29.571 + 29.572 + /** 29.573 * Does the argument expression {@code expr} need speculative type-checking? 29.574 */ 29.575 boolean isDeferred(Env<AttrContext> env, JCExpression expr) { 29.576 @@ -904,6 +1031,26 @@ 29.577 29.578 @Override 29.579 public void visitReference(JCMemberReference tree) { 29.580 + //perform arity-based check 29.581 + Env<AttrContext> localEnv = env.dup(tree); 29.582 + JCExpression exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), localEnv, 29.583 + attr.memberReferenceQualifierResult(tree)); 29.584 + JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree); 29.585 + mref2.expr = exprTree; 29.586 + Pair<Symbol, ReferenceLookupHelper> lookupRes = 29.587 + rs.resolveMemberReference(tree, localEnv, mref2, exprTree.type, 29.588 + tree.name, List.<Type>nil(), null, true, rs.nilMethodCheck, 29.589 + infer.emptyContext); 29.590 + Symbol res = tree.sym = lookupRes.fst; 29.591 + if (res.kind >= Kinds.ERRONEOUS || 29.592 + res.type.hasTag(FORALL) || 29.593 + (res.flags() & Flags.VARARGS) != 0 || 29.594 + (TreeInfo.isStaticSelector(exprTree, tree.name.table.names) && 29.595 + exprTree.type.isRaw())) { 29.596 + tree.overloadKind = JCMemberReference.OverloadKind.OVERLOADED; 29.597 + } else { 29.598 + tree.overloadKind = JCMemberReference.OverloadKind.UNOVERLOADED; 29.599 + } 29.600 //a method reference is always a poly expression 29.601 result = ArgumentExpressionKind.POLY; 29.602 }
30.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Thu Sep 12 11:09:20 2013 -0700 30.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Sep 17 08:21:11 2013 -0700 30.3 @@ -207,7 +207,7 @@ 30.4 30.5 public void analyzeTree(Env<AttrContext> env, TreeMaker make) { 30.6 new AliveAnalyzer().analyzeTree(env, make); 30.7 - new AssignAnalyzer().analyzeTree(env, make); 30.8 + new AssignAnalyzer(log, syms, lint, names).analyzeTree(env); 30.9 new FlowAnalyzer().analyzeTree(env, make); 30.10 new CaptureAnalyzer().analyzeTree(env, make); 30.11 } 30.12 @@ -224,7 +224,6 @@ 30.13 } 30.14 try { 30.15 new AliveAnalyzer().analyzeTree(env, that, make); 30.16 - new LambdaFlowAnalyzer().analyzeTree(env, that, make); 30.17 } finally { 30.18 if (!speculative) { 30.19 log.popDiagnosticHandler(diagHandler); 30.20 @@ -232,6 +231,23 @@ 30.21 } 30.22 } 30.23 30.24 + public List<Type> analyzeLambdaThrownTypes(Env<AttrContext> env, JCLambda that, TreeMaker make) { 30.25 + //we need to disable diagnostics temporarily; the problem is that if 30.26 + //a lambda expression contains e.g. an unreachable statement, an error 30.27 + //message will be reported and will cause compilation to skip the flow analyis 30.28 + //step - if we suppress diagnostics, we won't stop at Attr for flow-analysis 30.29 + //related errors, which will allow for more errors to be detected 30.30 + Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); 30.31 + try { 30.32 + new AssignAnalyzer(log, syms, lint, names).analyzeTree(env); 30.33 + LambdaFlowAnalyzer flowAnalyzer = new LambdaFlowAnalyzer(); 30.34 + flowAnalyzer.analyzeTree(env, that, make); 30.35 + return flowAnalyzer.inferredThrownTypes; 30.36 + } finally { 30.37 + log.popDiagnosticHandler(diagHandler); 30.38 + } 30.39 + } 30.40 + 30.41 /** 30.42 * Definite assignment scan mode 30.43 */ 30.44 @@ -276,15 +292,6 @@ 30.45 } 30.46 30.47 /** 30.48 - * Utility method to reset several Bits instances. 30.49 - */ 30.50 - private void resetBits(Bits... bits) { 30.51 - for (Bits b : bits) { 30.52 - b.reset(); 30.53 - } 30.54 - } 30.55 - 30.56 - /** 30.57 * Base visitor class for all visitors implementing dataflow analysis logic. 30.58 * This class define the shared logic for handling jumps (break/continue statements). 30.59 */ 30.60 @@ -331,17 +338,17 @@ 30.61 this.tree = tree; 30.62 } 30.63 30.64 - void resolveJump() { 30.65 + void resolveJump(JCTree tree) { 30.66 //do nothing 30.67 } 30.68 } 30.69 30.70 - abstract void markDead(); 30.71 + abstract void markDead(JCTree tree); 30.72 30.73 /** Record an outward transfer of control. */ 30.74 void recordExit(JCTree tree, P pe) { 30.75 pendingExits.append(pe); 30.76 - markDead(); 30.77 + markDead(tree); 30.78 } 30.79 30.80 /** Resolve all jumps of this statement. */ 30.81 @@ -355,7 +362,7 @@ 30.82 P exit = exits.head; 30.83 if (exit.tree.hasTag(jk.treeTag) && 30.84 jk.getTarget(exit.tree) == tree) { 30.85 - exit.resolveJump(); 30.86 + exit.resolveJump(tree); 30.87 resolved = true; 30.88 } else { 30.89 pendingExits.append(exit); 30.90 @@ -364,12 +371,12 @@ 30.91 return resolved; 30.92 } 30.93 30.94 - /** Resolve all breaks of this statement. */ 30.95 + /** Resolve all continues of this statement. */ 30.96 boolean resolveContinues(JCTree tree) { 30.97 return resolveJump(tree, new ListBuffer<P>(), JumpKind.CONTINUE); 30.98 } 30.99 30.100 - /** Resolve all continues of this statement. */ 30.101 + /** Resolve all breaks of this statement. */ 30.102 boolean resolveBreaks(JCTree tree, ListBuffer<P> oldPendingExits) { 30.103 return resolveJump(tree, oldPendingExits, JumpKind.BREAK); 30.104 } 30.105 @@ -398,7 +405,7 @@ 30.106 private boolean alive; 30.107 30.108 @Override 30.109 - void markDead() { 30.110 + void markDead(JCTree tree) { 30.111 alive = false; 30.112 } 30.113 30.114 @@ -680,7 +687,7 @@ 30.115 30.116 public void visitThrow(JCThrow tree) { 30.117 scan(tree.expr); 30.118 - markDead(); 30.119 + markDead(tree); 30.120 } 30.121 30.122 public void visitApply(JCMethodInvocation tree) { 30.123 @@ -781,7 +788,7 @@ 30.124 } 30.125 30.126 @Override 30.127 - void markDead() { 30.128 + void markDead(JCTree tree) { 30.129 //do nothing 30.130 } 30.131 30.132 @@ -1206,7 +1213,7 @@ 30.133 else { 30.134 markThrown(tree, tree.expr.type); 30.135 } 30.136 - markDead(); 30.137 + markDead(tree); 30.138 } 30.139 30.140 public void visitApply(JCMethodInvocation tree) { 30.141 @@ -1318,27 +1325,35 @@ 30.142 * Specialized pass that performs inference of thrown types for lambdas. 30.143 */ 30.144 class LambdaFlowAnalyzer extends FlowAnalyzer { 30.145 + List<Type> inferredThrownTypes; 30.146 + boolean inLambda; 30.147 @Override 30.148 public void visitLambda(JCLambda tree) { 30.149 - if (tree.type != null && 30.150 - tree.type.isErroneous()) { 30.151 + if ((tree.type != null && 30.152 + tree.type.isErroneous()) || inLambda) { 30.153 return; 30.154 } 30.155 List<Type> prevCaught = caught; 30.156 List<Type> prevThrown = thrown; 30.157 ListBuffer<FlowPendingExit> prevPending = pendingExits; 30.158 + inLambda = true; 30.159 try { 30.160 pendingExits = ListBuffer.lb(); 30.161 caught = List.of(syms.throwableType); 30.162 thrown = List.nil(); 30.163 scan(tree.body); 30.164 - tree.inferredThrownTypes = thrown; 30.165 + inferredThrownTypes = thrown; 30.166 } finally { 30.167 pendingExits = prevPending; 30.168 caught = prevCaught; 30.169 thrown = prevThrown; 30.170 + inLambda = false; 30.171 } 30.172 } 30.173 + @Override 30.174 + public void visitClassDef(JCClassDecl tree) { 30.175 + //skip 30.176 + } 30.177 } 30.178 30.179 /** 30.180 @@ -1348,11 +1363,13 @@ 30.181 * depends on the results of the liveliness analyzer. This pass is also used to mark 30.182 * effectively-final local variables/parameters. 30.183 */ 30.184 - class AssignAnalyzer extends BaseAnalyzer<AssignAnalyzer.AssignPendingExit> { 30.185 + 30.186 + public abstract static class AbstractAssignAnalyzer<P extends AbstractAssignAnalyzer.AbstractAssignPendingExit> 30.187 + extends BaseAnalyzer<P> { 30.188 30.189 /** The set of definitely assigned variables. 30.190 */ 30.191 - final Bits inits; 30.192 + protected final Bits inits; 30.193 30.194 /** The set of definitely unassigned variables. 30.195 */ 30.196 @@ -1378,7 +1395,7 @@ 30.197 30.198 /** A mapping from addresses to variable symbols. 30.199 */ 30.200 - JCVariableDecl[] vardecls; 30.201 + protected JCVariableDecl[] vardecls; 30.202 30.203 /** The current class being defined. 30.204 */ 30.205 @@ -1390,11 +1407,11 @@ 30.206 30.207 /** The next available variable sequence number. 30.208 */ 30.209 - int nextadr; 30.210 + protected int nextadr; 30.211 30.212 /** The first variable sequence number in a block that can return. 30.213 */ 30.214 - int returnadr; 30.215 + protected int returnadr; 30.216 30.217 /** The list of unreferenced automatic resources. 30.218 */ 30.219 @@ -1406,35 +1423,46 @@ 30.220 /** The starting position of the analysed tree */ 30.221 int startPos; 30.222 30.223 - AssignAnalyzer() { 30.224 - inits = new Bits(); 30.225 + final Symtab syms; 30.226 + 30.227 + protected Names names; 30.228 + 30.229 + public static class AbstractAssignPendingExit extends BaseAnalyzer.PendingExit { 30.230 + 30.231 + final Bits inits; 30.232 + final Bits uninits; 30.233 + final Bits exit_inits = new Bits(true); 30.234 + final Bits exit_uninits = new Bits(true); 30.235 + 30.236 + public AbstractAssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { 30.237 + super(tree); 30.238 + this.inits = inits; 30.239 + this.uninits = uninits; 30.240 + this.exit_inits.assign(inits); 30.241 + this.exit_uninits.assign(uninits); 30.242 + } 30.243 + 30.244 + @Override 30.245 + public void resolveJump(JCTree tree) { 30.246 + inits.andSet(exit_inits); 30.247 + uninits.andSet(exit_uninits); 30.248 + } 30.249 + } 30.250 + 30.251 + public AbstractAssignAnalyzer(Bits inits, Symtab syms, Names names) { 30.252 + this.inits = inits; 30.253 uninits = new Bits(); 30.254 uninitsTry = new Bits(); 30.255 initsWhenTrue = new Bits(true); 30.256 initsWhenFalse = new Bits(true); 30.257 uninitsWhenTrue = new Bits(true); 30.258 uninitsWhenFalse = new Bits(true); 30.259 - } 30.260 - 30.261 - class AssignPendingExit extends BaseAnalyzer.PendingExit { 30.262 - 30.263 - final Bits exit_inits = new Bits(true); 30.264 - final Bits exit_uninits = new Bits(true); 30.265 - 30.266 - AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { 30.267 - super(tree); 30.268 - this.exit_inits.assign(inits); 30.269 - this.exit_uninits.assign(uninits); 30.270 - } 30.271 - 30.272 - void resolveJump() { 30.273 - inits.andSet(exit_inits); 30.274 - uninits.andSet(exit_uninits); 30.275 - } 30.276 + this.syms = syms; 30.277 + this.names = names; 30.278 } 30.279 30.280 @Override 30.281 - void markDead() { 30.282 + protected void markDead(JCTree tree) { 30.283 inits.inclRange(returnadr, nextadr); 30.284 uninits.inclRange(returnadr, nextadr); 30.285 } 30.286 @@ -1444,7 +1472,7 @@ 30.287 /** Do we need to track init/uninit state of this symbol? 30.288 * I.e. is symbol either a local or a blank final variable? 30.289 */ 30.290 - boolean trackable(VarSymbol sym) { 30.291 + protected boolean trackable(VarSymbol sym) { 30.292 return 30.293 sym.pos >= startPos && 30.294 ((sym.owner.kind == MTH || 30.295 @@ -1464,44 +1492,35 @@ 30.296 } 30.297 sym.adr = nextadr; 30.298 vardecls[nextadr] = varDecl; 30.299 - inits.excl(nextadr); 30.300 + exclVarFromInits(varDecl, nextadr); 30.301 uninits.incl(nextadr); 30.302 nextadr++; 30.303 } 30.304 30.305 + protected void exclVarFromInits(JCTree tree, int adr) { 30.306 + inits.excl(adr); 30.307 + } 30.308 + 30.309 + protected void assignToInits(JCTree tree, Bits bits) { 30.310 + inits.assign(bits); 30.311 + } 30.312 + 30.313 + protected void andSetInits(JCTree tree, Bits bits) { 30.314 + inits.andSet(bits); 30.315 + } 30.316 + 30.317 + protected void orSetInits(JCTree tree, Bits bits) { 30.318 + inits.orSet(bits); 30.319 + } 30.320 + 30.321 /** Record an initialization of a trackable variable. 30.322 */ 30.323 void letInit(DiagnosticPosition pos, VarSymbol sym) { 30.324 if (sym.adr >= firstadr && trackable(sym)) { 30.325 - if ((sym.flags() & EFFECTIVELY_FINAL) != 0) { 30.326 - if (!uninits.isMember(sym.adr)) { 30.327 - //assignment targeting an effectively final variable 30.328 - //makes the variable lose its status of effectively final 30.329 - //if the variable is _not_ definitively unassigned 30.330 - sym.flags_field &= ~EFFECTIVELY_FINAL; 30.331 - } else { 30.332 - uninit(sym); 30.333 - } 30.334 - } 30.335 - else if ((sym.flags() & FINAL) != 0) { 30.336 - if ((sym.flags() & PARAMETER) != 0) { 30.337 - if ((sym.flags() & UNION) != 0) { //multi-catch parameter 30.338 - log.error(pos, "multicatch.parameter.may.not.be.assigned", 30.339 - sym); 30.340 - } 30.341 - else { 30.342 - log.error(pos, "final.parameter.may.not.be.assigned", 30.343 - sym); 30.344 - } 30.345 - } else if (!uninits.isMember(sym.adr)) { 30.346 - log.error(pos, flowKind.errKey, sym); 30.347 - } else { 30.348 - uninit(sym); 30.349 - } 30.350 + if (uninits.isMember(sym.adr)) { 30.351 + uninit(sym); 30.352 } 30.353 inits.incl(sym.adr); 30.354 - } else if ((sym.flags() & FINAL) != 0) { 30.355 - log.error(pos, "var.might.already.be.assigned", sym); 30.356 } 30.357 } 30.358 //where 30.359 @@ -1535,12 +1554,14 @@ 30.360 void checkInit(DiagnosticPosition pos, VarSymbol sym) { 30.361 checkInit(pos, sym, "var.might.not.have.been.initialized"); 30.362 } 30.363 - void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) { 30.364 - if ((sym.adr >= firstadr || sym.owner.kind != TYP) && 30.365 - trackable(sym) && 30.366 - !inits.isMember(sym.adr)) { 30.367 - log.error(pos, errkey, sym); 30.368 - inits.incl(sym.adr); 30.369 + 30.370 + void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) {} 30.371 + 30.372 + /** Utility method to reset several Bits instances. 30.373 + */ 30.374 + private void resetBits(Bits... bits) { 30.375 + for (Bits b : bits) { 30.376 + b.reset(); 30.377 } 30.378 } 30.379 30.380 @@ -1558,7 +1579,7 @@ 30.381 30.382 /** Merge (intersect) inits/uninits from WhenTrue/WhenFalse sets. 30.383 */ 30.384 - void merge() { 30.385 + protected void merge(JCTree tree) { 30.386 inits.assign(initsWhenFalse.andSet(initsWhenTrue)); 30.387 uninits.assign(uninitsWhenFalse.andSet(uninitsWhenTrue)); 30.388 } 30.389 @@ -1573,7 +1594,9 @@ 30.390 void scanExpr(JCTree tree) { 30.391 if (tree != null) { 30.392 scan(tree); 30.393 - if (inits.isReset()) merge(); 30.394 + if (inits.isReset()) { 30.395 + merge(tree); 30.396 + } 30.397 } 30.398 } 30.399 30.400 @@ -1590,7 +1613,7 @@ 30.401 */ 30.402 void scanCond(JCTree tree) { 30.403 if (tree.type.isFalse()) { 30.404 - if (inits.isReset()) merge(); 30.405 + if (inits.isReset()) merge(tree); 30.406 initsWhenTrue.assign(inits); 30.407 initsWhenTrue.inclRange(firstadr, nextadr); 30.408 uninitsWhenTrue.assign(uninits); 30.409 @@ -1598,7 +1621,7 @@ 30.410 initsWhenFalse.assign(inits); 30.411 uninitsWhenFalse.assign(uninits); 30.412 } else if (tree.type.isTrue()) { 30.413 - if (inits.isReset()) merge(); 30.414 + if (inits.isReset()) merge(tree); 30.415 initsWhenFalse.assign(inits); 30.416 initsWhenFalse.inclRange(firstadr, nextadr); 30.417 uninitsWhenFalse.assign(uninits); 30.418 @@ -1617,22 +1640,22 @@ 30.419 30.420 /* ------------ Visitor methods for various sorts of trees -------------*/ 30.421 30.422 + @Override 30.423 public void visitClassDef(JCClassDecl tree) { 30.424 - if (tree.sym == null) return; 30.425 + if (tree.sym == null) { 30.426 + return; 30.427 + } 30.428 30.429 JCClassDecl classDefPrev = classDef; 30.430 int firstadrPrev = firstadr; 30.431 int nextadrPrev = nextadr; 30.432 - ListBuffer<AssignPendingExit> pendingExitsPrev = pendingExits; 30.433 - Lint lintPrev = lint; 30.434 + ListBuffer<P> pendingExitsPrev = pendingExits; 30.435 30.436 - pendingExits = new ListBuffer<AssignPendingExit>(); 30.437 + pendingExits = new ListBuffer<P>(); 30.438 if (tree.name != names.empty) { 30.439 firstadr = nextadr; 30.440 } 30.441 classDef = tree; 30.442 - lint = lint.augment(tree.sym); 30.443 - 30.444 try { 30.445 // define all the static fields 30.446 for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) { 30.447 @@ -1640,8 +1663,9 @@ 30.448 JCVariableDecl def = (JCVariableDecl)l.head; 30.449 if ((def.mods.flags & STATIC) != 0) { 30.450 VarSymbol sym = def.sym; 30.451 - if (trackable(sym)) 30.452 + if (trackable(sym)) { 30.453 newVar(def); 30.454 + } 30.455 } 30.456 } 30.457 } 30.458 @@ -1660,8 +1684,9 @@ 30.459 JCVariableDecl def = (JCVariableDecl)l.head; 30.460 if ((def.mods.flags & STATIC) == 0) { 30.461 VarSymbol sym = def.sym; 30.462 - if (trackable(sym)) 30.463 + if (trackable(sym)) { 30.464 newVar(def); 30.465 + } 30.466 } 30.467 } 30.468 } 30.469 @@ -1685,21 +1710,25 @@ 30.470 nextadr = nextadrPrev; 30.471 firstadr = firstadrPrev; 30.472 classDef = classDefPrev; 30.473 - lint = lintPrev; 30.474 } 30.475 } 30.476 30.477 + @Override 30.478 public void visitMethodDef(JCMethodDecl tree) { 30.479 - if (tree.body == null) return; 30.480 + if (tree.body == null) { 30.481 + return; 30.482 + } 30.483 + /* MemberEnter can generate synthetic methods, ignore them 30.484 + */ 30.485 + if ((tree.sym.flags() & SYNTHETIC) != 0) { 30.486 + return; 30.487 + } 30.488 30.489 final Bits initsPrev = new Bits(inits); 30.490 final Bits uninitsPrev = new Bits(uninits); 30.491 int nextadrPrev = nextadr; 30.492 int firstadrPrev = firstadr; 30.493 int returnadrPrev = returnadr; 30.494 - Lint lintPrev = lint; 30.495 - 30.496 - lint = lint.augment(tree.sym); 30.497 30.498 Assert.check(pendingExits.isEmpty()); 30.499 30.500 @@ -1707,13 +1736,17 @@ 30.501 boolean isInitialConstructor = 30.502 TreeInfo.isInitialConstructor(tree); 30.503 30.504 - if (!isInitialConstructor) 30.505 + if (!isInitialConstructor) { 30.506 firstadr = nextadr; 30.507 + } 30.508 for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { 30.509 JCVariableDecl def = l.head; 30.510 scan(def); 30.511 - inits.incl(def.sym.adr); 30.512 - uninits.excl(def.sym.adr); 30.513 + Assert.check((def.sym.flags() & PARAMETER) != 0, "Method parameter without PARAMETER flag"); 30.514 + /* If we are executing the code from Gen, then there can be 30.515 + * synthetic or mandated variables, ignore them. 30.516 + */ 30.517 + initParam(def); 30.518 } 30.519 // else we are in an instance initializer block; 30.520 // leave caught unchanged. 30.521 @@ -1737,39 +1770,42 @@ 30.522 } 30.523 } 30.524 } 30.525 - List<AssignPendingExit> exits = pendingExits.toList(); 30.526 - pendingExits = new ListBuffer<AssignPendingExit>(); 30.527 + List<P> exits = pendingExits.toList(); 30.528 + pendingExits = new ListBuffer<>(); 30.529 while (exits.nonEmpty()) { 30.530 - AssignPendingExit exit = exits.head; 30.531 + P exit = exits.head; 30.532 exits = exits.tail; 30.533 Assert.check(exit.tree.hasTag(RETURN), exit.tree); 30.534 if (isInitialConstructor) { 30.535 - inits.assign(exit.exit_inits); 30.536 - for (int i = firstadr; i < nextadr; i++) 30.537 + assignToInits(exit.tree, exit.exit_inits); 30.538 + for (int i = firstadr; i < nextadr; i++) { 30.539 checkInit(exit.tree.pos(), vardecls[i].sym); 30.540 + } 30.541 } 30.542 } 30.543 } finally { 30.544 - inits.assign(initsPrev); 30.545 + assignToInits(tree, initsPrev); 30.546 uninits.assign(uninitsPrev); 30.547 nextadr = nextadrPrev; 30.548 firstadr = firstadrPrev; 30.549 returnadr = returnadrPrev; 30.550 - lint = lintPrev; 30.551 } 30.552 } 30.553 30.554 + protected void initParam(JCVariableDecl def) { 30.555 + inits.incl(def.sym.adr); 30.556 + uninits.excl(def.sym.adr); 30.557 + } 30.558 + 30.559 public void visitVarDef(JCVariableDecl tree) { 30.560 boolean track = trackable(tree.sym); 30.561 - if (track && tree.sym.owner.kind == MTH) newVar(tree); 30.562 + if (track && tree.sym.owner.kind == MTH) { 30.563 + newVar(tree); 30.564 + } 30.565 if (tree.init != null) { 30.566 - Lint lintPrev = lint; 30.567 - lint = lint.augment(tree.sym); 30.568 - try{ 30.569 - scanExpr(tree.init); 30.570 - if (track) letInit(tree.pos(), tree.sym); 30.571 - } finally { 30.572 - lint = lintPrev; 30.573 + scanExpr(tree.init); 30.574 + if (track) { 30.575 + letInit(tree.pos(), tree.sym); 30.576 } 30.577 } 30.578 } 30.579 @@ -1780,14 +1816,18 @@ 30.580 nextadr = nextadrPrev; 30.581 } 30.582 30.583 + int getLogNumberOfErrors() { 30.584 + return 0; 30.585 + } 30.586 + 30.587 public void visitDoLoop(JCDoWhileLoop tree) { 30.588 - ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; 30.589 + ListBuffer<P> prevPendingExits = pendingExits; 30.590 FlowKind prevFlowKind = flowKind; 30.591 flowKind = FlowKind.NORMAL; 30.592 final Bits initsSkip = new Bits(true); 30.593 final Bits uninitsSkip = new Bits(true); 30.594 - pendingExits = new ListBuffer<AssignPendingExit>(); 30.595 - int prevErrors = log.nerrors; 30.596 + pendingExits = new ListBuffer<P>(); 30.597 + int prevErrors = getLogNumberOfErrors(); 30.598 do { 30.599 final Bits uninitsEntry = new Bits(uninits); 30.600 uninitsEntry.excludeFrom(nextadr); 30.601 @@ -1798,28 +1838,28 @@ 30.602 initsSkip.assign(initsWhenFalse); 30.603 uninitsSkip.assign(uninitsWhenFalse); 30.604 } 30.605 - if (log.nerrors != prevErrors || 30.606 + if (getLogNumberOfErrors() != prevErrors || 30.607 flowKind.isFinal() || 30.608 new Bits(uninitsEntry).diffSet(uninitsWhenTrue).nextBit(firstadr)==-1) 30.609 break; 30.610 - inits.assign(initsWhenTrue); 30.611 + assignToInits(tree.cond, initsWhenTrue); 30.612 uninits.assign(uninitsEntry.andSet(uninitsWhenTrue)); 30.613 flowKind = FlowKind.SPECULATIVE_LOOP; 30.614 } while (true); 30.615 flowKind = prevFlowKind; 30.616 - inits.assign(initsSkip); 30.617 + assignToInits(tree, initsSkip); 30.618 uninits.assign(uninitsSkip); 30.619 resolveBreaks(tree, prevPendingExits); 30.620 } 30.621 30.622 public void visitWhileLoop(JCWhileLoop tree) { 30.623 - ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; 30.624 + ListBuffer<P> prevPendingExits = pendingExits; 30.625 FlowKind prevFlowKind = flowKind; 30.626 flowKind = FlowKind.NORMAL; 30.627 final Bits initsSkip = new Bits(true); 30.628 final Bits uninitsSkip = new Bits(true); 30.629 - pendingExits = new ListBuffer<AssignPendingExit>(); 30.630 - int prevErrors = log.nerrors; 30.631 + pendingExits = new ListBuffer<>(); 30.632 + int prevErrors = getLogNumberOfErrors(); 30.633 final Bits uninitsEntry = new Bits(uninits); 30.634 uninitsEntry.excludeFrom(nextadr); 30.635 do { 30.636 @@ -1828,35 +1868,36 @@ 30.637 initsSkip.assign(initsWhenFalse) ; 30.638 uninitsSkip.assign(uninitsWhenFalse); 30.639 } 30.640 - inits.assign(initsWhenTrue); 30.641 + assignToInits(tree, initsWhenTrue); 30.642 uninits.assign(uninitsWhenTrue); 30.643 scan(tree.body); 30.644 resolveContinues(tree); 30.645 - if (log.nerrors != prevErrors || 30.646 + if (getLogNumberOfErrors() != prevErrors || 30.647 flowKind.isFinal() || 30.648 - new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1) 30.649 + new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1) { 30.650 break; 30.651 + } 30.652 uninits.assign(uninitsEntry.andSet(uninits)); 30.653 flowKind = FlowKind.SPECULATIVE_LOOP; 30.654 } while (true); 30.655 flowKind = prevFlowKind; 30.656 //a variable is DA/DU after the while statement, if it's DA/DU assuming the 30.657 //branch is not taken AND if it's DA/DU before any break statement 30.658 - inits.assign(initsSkip); 30.659 + assignToInits(tree.body, initsSkip); 30.660 uninits.assign(uninitsSkip); 30.661 resolveBreaks(tree, prevPendingExits); 30.662 } 30.663 30.664 public void visitForLoop(JCForLoop tree) { 30.665 - ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; 30.666 + ListBuffer<P> prevPendingExits = pendingExits; 30.667 FlowKind prevFlowKind = flowKind; 30.668 flowKind = FlowKind.NORMAL; 30.669 int nextadrPrev = nextadr; 30.670 scan(tree.init); 30.671 final Bits initsSkip = new Bits(true); 30.672 final Bits uninitsSkip = new Bits(true); 30.673 - pendingExits = new ListBuffer<AssignPendingExit>(); 30.674 - int prevErrors = log.nerrors; 30.675 + pendingExits = new ListBuffer<P>(); 30.676 + int prevErrors = getLogNumberOfErrors(); 30.677 do { 30.678 final Bits uninitsEntry = new Bits(uninits); 30.679 uninitsEntry.excludeFrom(nextadr); 30.680 @@ -1866,7 +1907,7 @@ 30.681 initsSkip.assign(initsWhenFalse); 30.682 uninitsSkip.assign(uninitsWhenFalse); 30.683 } 30.684 - inits.assign(initsWhenTrue); 30.685 + assignToInits(tree.body, initsWhenTrue); 30.686 uninits.assign(uninitsWhenTrue); 30.687 } else if (!flowKind.isFinal()) { 30.688 initsSkip.assign(inits); 30.689 @@ -1877,7 +1918,7 @@ 30.690 scan(tree.body); 30.691 resolveContinues(tree); 30.692 scan(tree.step); 30.693 - if (log.nerrors != prevErrors || 30.694 + if (getLogNumberOfErrors() != prevErrors || 30.695 flowKind.isFinal() || 30.696 new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1) 30.697 break; 30.698 @@ -1887,7 +1928,7 @@ 30.699 flowKind = prevFlowKind; 30.700 //a variable is DA/DU after a for loop, if it's DA/DU assuming the 30.701 //branch is not taken AND if it's DA/DU before any break statement 30.702 - inits.assign(initsSkip); 30.703 + assignToInits(tree.body, initsSkip); 30.704 uninits.assign(uninitsSkip); 30.705 resolveBreaks(tree, prevPendingExits); 30.706 nextadr = nextadrPrev; 30.707 @@ -1896,7 +1937,7 @@ 30.708 public void visitForeachLoop(JCEnhancedForLoop tree) { 30.709 visitVarDef(tree.var); 30.710 30.711 - ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; 30.712 + ListBuffer<P> prevPendingExits = pendingExits; 30.713 FlowKind prevFlowKind = flowKind; 30.714 flowKind = FlowKind.NORMAL; 30.715 int nextadrPrev = nextadr; 30.716 @@ -1905,14 +1946,14 @@ 30.717 final Bits uninitsStart = new Bits(uninits); 30.718 30.719 letInit(tree.pos(), tree.var.sym); 30.720 - pendingExits = new ListBuffer<AssignPendingExit>(); 30.721 - int prevErrors = log.nerrors; 30.722 + pendingExits = new ListBuffer<P>(); 30.723 + int prevErrors = getLogNumberOfErrors(); 30.724 do { 30.725 final Bits uninitsEntry = new Bits(uninits); 30.726 uninitsEntry.excludeFrom(nextadr); 30.727 scan(tree.body); 30.728 resolveContinues(tree); 30.729 - if (log.nerrors != prevErrors || 30.730 + if (getLogNumberOfErrors() != prevErrors || 30.731 flowKind.isFinal() || 30.732 new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1) 30.733 break; 30.734 @@ -1920,41 +1961,50 @@ 30.735 flowKind = FlowKind.SPECULATIVE_LOOP; 30.736 } while (true); 30.737 flowKind = prevFlowKind; 30.738 - inits.assign(initsStart); 30.739 + assignToInits(tree.body, initsStart); 30.740 uninits.assign(uninitsStart.andSet(uninits)); 30.741 resolveBreaks(tree, prevPendingExits); 30.742 nextadr = nextadrPrev; 30.743 } 30.744 30.745 public void visitLabelled(JCLabeledStatement tree) { 30.746 - ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; 30.747 - pendingExits = new ListBuffer<AssignPendingExit>(); 30.748 + ListBuffer<P> prevPendingExits = pendingExits; 30.749 + pendingExits = new ListBuffer<P>(); 30.750 scan(tree.body); 30.751 resolveBreaks(tree, prevPendingExits); 30.752 } 30.753 30.754 public void visitSwitch(JCSwitch tree) { 30.755 - ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; 30.756 - pendingExits = new ListBuffer<AssignPendingExit>(); 30.757 + ListBuffer<P> prevPendingExits = pendingExits; 30.758 + pendingExits = new ListBuffer<>(); 30.759 int nextadrPrev = nextadr; 30.760 scanExpr(tree.selector); 30.761 final Bits initsSwitch = new Bits(inits); 30.762 final Bits uninitsSwitch = new Bits(uninits); 30.763 boolean hasDefault = false; 30.764 for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) { 30.765 - inits.assign(initsSwitch); 30.766 + assignToInits(l.head, initsSwitch); 30.767 uninits.assign(uninits.andSet(uninitsSwitch)); 30.768 JCCase c = l.head; 30.769 - if (c.pat == null) 30.770 + if (c.pat == null) { 30.771 hasDefault = true; 30.772 - else 30.773 + } else { 30.774 scanExpr(c.pat); 30.775 + } 30.776 + if (hasDefault) { 30.777 + assignToInits(null, initsSwitch); 30.778 + uninits.assign(uninits.andSet(uninitsSwitch)); 30.779 + } 30.780 scan(c.stats); 30.781 addVars(c.stats, initsSwitch, uninitsSwitch); 30.782 + if (!hasDefault) { 30.783 + assignToInits(l.head.stats.last(), initsSwitch); 30.784 + uninits.assign(uninits.andSet(uninitsSwitch)); 30.785 + } 30.786 // Warn about fall-through if lint switch fallthrough enabled. 30.787 } 30.788 if (!hasDefault) { 30.789 - inits.andSet(initsSwitch); 30.790 + andSetInits(null, initsSwitch); 30.791 } 30.792 resolveBreaks(tree, prevPendingExits); 30.793 nextadr = nextadrPrev; 30.794 @@ -1973,11 +2023,17 @@ 30.795 } 30.796 } 30.797 30.798 + boolean isEnabled(Lint.LintCategory lc) { 30.799 + return false; 30.800 + } 30.801 + 30.802 + void reportWarning(Lint.LintCategory lc, DiagnosticPosition pos, String key, Object ... args) {} 30.803 + 30.804 public void visitTry(JCTry tree) { 30.805 ListBuffer<JCVariableDecl> resourceVarDecls = ListBuffer.lb(); 30.806 final Bits uninitsTryPrev = new Bits(uninitsTry); 30.807 - ListBuffer<AssignPendingExit> prevPendingExits = pendingExits; 30.808 - pendingExits = new ListBuffer<AssignPendingExit>(); 30.809 + ListBuffer<P> prevPendingExits = pendingExits; 30.810 + pendingExits = new ListBuffer<>(); 30.811 final Bits initsTry = new Bits(inits); 30.812 uninitsTry.assign(uninits); 30.813 for (JCTree resource : tree.resources) { 30.814 @@ -1999,10 +2055,10 @@ 30.815 int nextadrCatch = nextadr; 30.816 30.817 if (!resourceVarDecls.isEmpty() && 30.818 - lint.isEnabled(Lint.LintCategory.TRY)) { 30.819 + isEnabled(Lint.LintCategory.TRY)) { 30.820 for (JCVariableDecl resVar : resourceVarDecls) { 30.821 if (unrefdResources.includes(resVar.sym)) { 30.822 - log.warning(Lint.LintCategory.TRY, resVar.pos(), 30.823 + reportWarning(Lint.LintCategory.TRY, resVar.pos(), 30.824 "try.resource.not.referenced", resVar.sym); 30.825 unrefdResources.remove(resVar.sym); 30.826 } 30.827 @@ -2018,20 +2074,22 @@ 30.828 30.829 for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) { 30.830 JCVariableDecl param = l.head.param; 30.831 - inits.assign(initsCatchPrev); 30.832 + assignToInits(tree.body, initsCatchPrev); 30.833 uninits.assign(uninitsCatchPrev); 30.834 scan(param); 30.835 - inits.incl(param.sym.adr); 30.836 - uninits.excl(param.sym.adr); 30.837 + /* If this is a TWR and we are executing the code from Gen, 30.838 + * then there can be synthetic variables, ignore them. 30.839 + */ 30.840 + initParam(param); 30.841 scan(l.head.body); 30.842 initsEnd.andSet(inits); 30.843 uninitsEnd.andSet(uninits); 30.844 nextadr = nextadrCatch; 30.845 } 30.846 if (tree.finalizer != null) { 30.847 - inits.assign(initsTry); 30.848 + assignToInits(tree.finalizer, initsTry); 30.849 uninits.assign(uninitsTry); 30.850 - ListBuffer<AssignPendingExit> exits = pendingExits; 30.851 + ListBuffer<P> exits = pendingExits; 30.852 pendingExits = prevPendingExits; 30.853 scan(tree.finalizer); 30.854 if (!tree.finallyCanCompleteNormally) { 30.855 @@ -2041,19 +2099,19 @@ 30.856 // FIX: this doesn't preserve source order of exits in catch 30.857 // versus finally! 30.858 while (exits.nonEmpty()) { 30.859 - AssignPendingExit exit = exits.next(); 30.860 + P exit = exits.next(); 30.861 if (exit.exit_inits != null) { 30.862 exit.exit_inits.orSet(inits); 30.863 exit.exit_uninits.andSet(uninits); 30.864 } 30.865 pendingExits.append(exit); 30.866 } 30.867 - inits.orSet(initsEnd); 30.868 + orSetInits(tree, initsEnd); 30.869 } 30.870 } else { 30.871 - inits.assign(initsEnd); 30.872 + assignToInits(tree, initsEnd); 30.873 uninits.assign(uninitsEnd); 30.874 - ListBuffer<AssignPendingExit> exits = pendingExits; 30.875 + ListBuffer<P> exits = pendingExits; 30.876 pendingExits = prevPendingExits; 30.877 while (exits.nonEmpty()) pendingExits.append(exits.next()); 30.878 } 30.879 @@ -2064,7 +2122,7 @@ 30.880 scanCond(tree.cond); 30.881 final Bits initsBeforeElse = new Bits(initsWhenFalse); 30.882 final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse); 30.883 - inits.assign(initsWhenTrue); 30.884 + assignToInits(tree.cond, initsWhenTrue); 30.885 uninits.assign(uninitsWhenTrue); 30.886 if (tree.truepart.type.hasTag(BOOLEAN) && 30.887 tree.falsepart.type.hasTag(BOOLEAN)) { 30.888 @@ -2077,7 +2135,7 @@ 30.889 final Bits initsAfterThenWhenFalse = new Bits(initsWhenFalse); 30.890 final Bits uninitsAfterThenWhenTrue = new Bits(uninitsWhenTrue); 30.891 final Bits uninitsAfterThenWhenFalse = new Bits(uninitsWhenFalse); 30.892 - inits.assign(initsBeforeElse); 30.893 + assignToInits(tree.truepart, initsBeforeElse); 30.894 uninits.assign(uninitsBeforeElse); 30.895 scanCond(tree.falsepart); 30.896 initsWhenTrue.andSet(initsAfterThenWhenTrue); 30.897 @@ -2088,10 +2146,10 @@ 30.898 scanExpr(tree.truepart); 30.899 final Bits initsAfterThen = new Bits(inits); 30.900 final Bits uninitsAfterThen = new Bits(uninits); 30.901 - inits.assign(initsBeforeElse); 30.902 + assignToInits(tree.truepart, initsBeforeElse); 30.903 uninits.assign(uninitsBeforeElse); 30.904 scanExpr(tree.falsepart); 30.905 - inits.andSet(initsAfterThen); 30.906 + andSetInits(tree.falsepart, initsAfterThen); 30.907 uninits.andSet(uninitsAfterThen); 30.908 } 30.909 } 30.910 @@ -2100,39 +2158,46 @@ 30.911 scanCond(tree.cond); 30.912 final Bits initsBeforeElse = new Bits(initsWhenFalse); 30.913 final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse); 30.914 - inits.assign(initsWhenTrue); 30.915 + assignToInits(tree.cond, initsWhenTrue); 30.916 uninits.assign(uninitsWhenTrue); 30.917 scan(tree.thenpart); 30.918 if (tree.elsepart != null) { 30.919 final Bits initsAfterThen = new Bits(inits); 30.920 final Bits uninitsAfterThen = new Bits(uninits); 30.921 - inits.assign(initsBeforeElse); 30.922 + assignToInits(tree.thenpart, initsBeforeElse); 30.923 uninits.assign(uninitsBeforeElse); 30.924 scan(tree.elsepart); 30.925 - inits.andSet(initsAfterThen); 30.926 + andSetInits(tree.elsepart, initsAfterThen); 30.927 uninits.andSet(uninitsAfterThen); 30.928 } else { 30.929 - inits.andSet(initsBeforeElse); 30.930 + andSetInits(tree.thenpart, initsBeforeElse); 30.931 uninits.andSet(uninitsBeforeElse); 30.932 } 30.933 } 30.934 30.935 - public void visitBreak(JCBreak tree) { 30.936 - recordExit(tree, new AssignPendingExit(tree, inits, uninits)); 30.937 + protected P createNewPendingExit(JCTree tree, Bits inits, Bits uninits) { 30.938 + return null; 30.939 } 30.940 30.941 - public void visitContinue(JCContinue tree) { 30.942 - recordExit(tree, new AssignPendingExit(tree, inits, uninits)); 30.943 + @Override 30.944 + public void visitBreak(JCBreak tree) { 30.945 + recordExit(tree, createNewPendingExit(tree, inits, uninits)); 30.946 } 30.947 30.948 + @Override 30.949 + public void visitContinue(JCContinue tree) { 30.950 + recordExit(tree, createNewPendingExit(tree, inits, uninits)); 30.951 + } 30.952 + 30.953 + @Override 30.954 public void visitReturn(JCReturn tree) { 30.955 scanExpr(tree.expr); 30.956 - recordExit(tree, new AssignPendingExit(tree, inits, uninits)); 30.957 + recordExit(tree, createNewPendingExit(tree, inits, uninits)); 30.958 } 30.959 30.960 public void visitThrow(JCThrow tree) { 30.961 scanExpr(tree.expr); 30.962 - markDead(); 30.963 + markDead(tree.expr); 30.964 } 30.965 30.966 public void visitApply(JCMethodInvocation tree) { 30.967 @@ -2151,10 +2216,10 @@ 30.968 final Bits prevUninits = new Bits(uninits); 30.969 final Bits prevInits = new Bits(inits); 30.970 int returnadrPrev = returnadr; 30.971 - ListBuffer<AssignPendingExit> prevPending = pendingExits; 30.972 + ListBuffer<P> prevPending = pendingExits; 30.973 try { 30.974 returnadr = nextadr; 30.975 - pendingExits = new ListBuffer<AssignPendingExit>(); 30.976 + pendingExits = new ListBuffer<P>(); 30.977 for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { 30.978 JCVariableDecl def = l.head; 30.979 scan(def); 30.980 @@ -2170,7 +2235,7 @@ 30.981 finally { 30.982 returnadr = returnadrPrev; 30.983 uninits.assign(prevUninits); 30.984 - inits.assign(prevInits); 30.985 + assignToInits(tree, prevInits); 30.986 pendingExits = prevPending; 30.987 } 30.988 } 30.989 @@ -2186,11 +2251,11 @@ 30.990 scanCond(tree.cond); 30.991 uninitsExit.andSet(uninitsWhenTrue); 30.992 if (tree.detail != null) { 30.993 - inits.assign(initsWhenFalse); 30.994 + assignToInits(tree, initsWhenFalse); 30.995 uninits.assign(uninitsWhenFalse); 30.996 scanExpr(tree.detail); 30.997 } 30.998 - inits.assign(initsExit); 30.999 + assignToInits(tree, initsExit); 30.1000 uninits.assign(uninitsExit); 30.1001 } 30.1002 30.1003 @@ -2236,7 +2301,7 @@ 30.1004 scanCond(tree.lhs); 30.1005 final Bits initsWhenFalseLeft = new Bits(initsWhenFalse); 30.1006 final Bits uninitsWhenFalseLeft = new Bits(uninitsWhenFalse); 30.1007 - inits.assign(initsWhenTrue); 30.1008 + assignToInits(tree.lhs, initsWhenTrue); 30.1009 uninits.assign(uninitsWhenTrue); 30.1010 scanCond(tree.rhs); 30.1011 initsWhenFalse.andSet(initsWhenFalseLeft); 30.1012 @@ -2246,7 +2311,7 @@ 30.1013 scanCond(tree.lhs); 30.1014 final Bits initsWhenTrueLeft = new Bits(initsWhenTrue); 30.1015 final Bits uninitsWhenTrueLeft = new Bits(uninitsWhenTrue); 30.1016 - inits.assign(initsWhenFalse); 30.1017 + assignToInits(tree.lhs, initsWhenFalse); 30.1018 uninits.assign(uninitsWhenFalse); 30.1019 scanCond(tree.rhs); 30.1020 initsWhenTrue.andSet(initsWhenTrueLeft); 30.1021 @@ -2284,14 +2349,12 @@ 30.1022 30.1023 /** Perform definite assignment/unassignment analysis on a tree. 30.1024 */ 30.1025 - public void analyzeTree(Env<AttrContext> env, TreeMaker make) { 30.1026 - analyzeTree(env, env.tree, make); 30.1027 - } 30.1028 + public void analyzeTree(Env<?> env) { 30.1029 + analyzeTree(env, env.tree); 30.1030 + } 30.1031 30.1032 - public void analyzeTree(Env<AttrContext> env, JCTree tree, TreeMaker make) { 30.1033 + public void analyzeTree(Env<?> env, JCTree tree) { 30.1034 try { 30.1035 - attrEnv = env; 30.1036 - Flow.this.make = make; 30.1037 startPos = tree.pos().getStartPosition(); 30.1038 30.1039 if (vardecls == null) 30.1040 @@ -2301,7 +2364,7 @@ 30.1041 vardecls[i] = null; 30.1042 firstadr = 0; 30.1043 nextadr = 0; 30.1044 - pendingExits = new ListBuffer<AssignPendingExit>(); 30.1045 + pendingExits = new ListBuffer<>(); 30.1046 this.classDef = null; 30.1047 unrefdResources = new Scope(env.enclClass.sym); 30.1048 scan(tree); 30.1049 @@ -2310,18 +2373,160 @@ 30.1050 startPos = -1; 30.1051 resetBits(inits, uninits, uninitsTry, initsWhenTrue, 30.1052 initsWhenFalse, uninitsWhenTrue, uninitsWhenFalse); 30.1053 - if (vardecls != null) for (int i=0; i<vardecls.length; i++) 30.1054 - vardecls[i] = null; 30.1055 + if (vardecls != null) { 30.1056 + for (int i=0; i<vardecls.length; i++) 30.1057 + vardecls[i] = null; 30.1058 + } 30.1059 firstadr = 0; 30.1060 nextadr = 0; 30.1061 pendingExits = null; 30.1062 - Flow.this.make = null; 30.1063 this.classDef = null; 30.1064 unrefdResources = null; 30.1065 } 30.1066 } 30.1067 } 30.1068 30.1069 + public static class AssignAnalyzer 30.1070 + extends AbstractAssignAnalyzer<AssignAnalyzer.AssignPendingExit> { 30.1071 + 30.1072 + Log log; 30.1073 + Lint lint; 30.1074 + 30.1075 + public static class AssignPendingExit 30.1076 + extends AbstractAssignAnalyzer.AbstractAssignPendingExit { 30.1077 + 30.1078 + public AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { 30.1079 + super(tree, inits, uninits); 30.1080 + } 30.1081 + } 30.1082 + 30.1083 + public AssignAnalyzer(Log log, Symtab syms, Lint lint, Names names) { 30.1084 + super(new Bits(), syms, names); 30.1085 + this.log = log; 30.1086 + this.lint = lint; 30.1087 + } 30.1088 + 30.1089 + @Override 30.1090 + protected AssignPendingExit createNewPendingExit(JCTree tree, 30.1091 + Bits inits, Bits uninits) { 30.1092 + return new AssignPendingExit(tree, inits, uninits); 30.1093 + } 30.1094 + 30.1095 + /** Record an initialization of a trackable variable. 30.1096 + */ 30.1097 + @Override 30.1098 + void letInit(DiagnosticPosition pos, VarSymbol sym) { 30.1099 + if (sym.adr >= firstadr && trackable(sym)) { 30.1100 + if ((sym.flags() & EFFECTIVELY_FINAL) != 0) { 30.1101 + if (!uninits.isMember(sym.adr)) { 30.1102 + //assignment targeting an effectively final variable 30.1103 + //makes the variable lose its status of effectively final 30.1104 + //if the variable is _not_ definitively unassigned 30.1105 + sym.flags_field &= ~EFFECTIVELY_FINAL; 30.1106 + } else { 30.1107 + uninit(sym); 30.1108 + } 30.1109 + } 30.1110 + else if ((sym.flags() & FINAL) != 0) { 30.1111 + if ((sym.flags() & PARAMETER) != 0) { 30.1112 + if ((sym.flags() & UNION) != 0) { //multi-catch parameter 30.1113 + log.error(pos, "multicatch.parameter.may.not.be.assigned", sym); 30.1114 + } 30.1115 + else { 30.1116 + log.error(pos, "final.parameter.may.not.be.assigned", 30.1117 + sym); 30.1118 + } 30.1119 + } else if (!uninits.isMember(sym.adr)) { 30.1120 + log.error(pos, flowKind.errKey, sym); 30.1121 + } else { 30.1122 + uninit(sym); 30.1123 + } 30.1124 + } 30.1125 + inits.incl(sym.adr); 30.1126 + } else if ((sym.flags() & FINAL) != 0) { 30.1127 + log.error(pos, "var.might.already.be.assigned", sym); 30.1128 + } 30.1129 + } 30.1130 + 30.1131 + @Override 30.1132 + void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) { 30.1133 + if ((sym.adr >= firstadr || sym.owner.kind != TYP) && 30.1134 + trackable(sym) && 30.1135 + !inits.isMember(sym.adr)) { 30.1136 + log.error(pos, errkey, sym); 30.1137 + inits.incl(sym.adr); 30.1138 + } 30.1139 + } 30.1140 + 30.1141 + @Override 30.1142 + void reportWarning(Lint.LintCategory lc, DiagnosticPosition pos, 30.1143 + String key, Object ... args) { 30.1144 + log.warning(lc, pos, key, args); 30.1145 + } 30.1146 + 30.1147 + @Override 30.1148 + int getLogNumberOfErrors() { 30.1149 + return log.nerrors; 30.1150 + } 30.1151 + 30.1152 + @Override 30.1153 + boolean isEnabled(Lint.LintCategory lc) { 30.1154 + return lint.isEnabled(lc); 30.1155 + } 30.1156 + 30.1157 + @Override 30.1158 + public void visitClassDef(JCClassDecl tree) { 30.1159 + if (tree.sym == null) { 30.1160 + return; 30.1161 + } 30.1162 + 30.1163 + Lint lintPrev = lint; 30.1164 + lint = lint.augment(tree.sym); 30.1165 + try { 30.1166 + super.visitClassDef(tree); 30.1167 + } finally { 30.1168 + lint = lintPrev; 30.1169 + } 30.1170 + } 30.1171 + 30.1172 + @Override 30.1173 + public void visitMethodDef(JCMethodDecl tree) { 30.1174 + if (tree.body == null) { 30.1175 + return; 30.1176 + } 30.1177 + 30.1178 + /* MemberEnter can generate synthetic methods ignore them 30.1179 + */ 30.1180 + if ((tree.sym.flags() & SYNTHETIC) != 0) { 30.1181 + return; 30.1182 + } 30.1183 + 30.1184 + Lint lintPrev = lint; 30.1185 + lint = lint.augment(tree.sym); 30.1186 + try { 30.1187 + super.visitMethodDef(tree); 30.1188 + } finally { 30.1189 + lint = lintPrev; 30.1190 + } 30.1191 + } 30.1192 + 30.1193 + @Override 30.1194 + public void visitVarDef(JCVariableDecl tree) { 30.1195 + if (tree.init == null) { 30.1196 + super.visitVarDef(tree); 30.1197 + } else { 30.1198 + Lint lintPrev = lint; 30.1199 + lint = lint.augment(tree.sym); 30.1200 + try{ 30.1201 + super.visitVarDef(tree); 30.1202 + } finally { 30.1203 + lint = lintPrev; 30.1204 + } 30.1205 + } 30.1206 + } 30.1207 + 30.1208 + } 30.1209 + 30.1210 /** 30.1211 * This pass implements the last step of the dataflow analysis, namely 30.1212 * the effectively-final analysis check. This checks that every local variable 30.1213 @@ -2334,7 +2539,7 @@ 30.1214 JCTree currentTree; //local class or lambda 30.1215 30.1216 @Override 30.1217 - void markDead() { 30.1218 + void markDead(JCTree tree) { 30.1219 //do nothing 30.1220 } 30.1221
31.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Sep 12 11:09:20 2013 -0700 31.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Sep 17 08:21:11 2013 -0700 31.3 @@ -40,17 +40,17 @@ 31.4 import com.sun.tools.javac.comp.Infer.GraphSolver.InferenceGraph.Node; 31.5 import com.sun.tools.javac.comp.Resolve.InapplicableMethodException; 31.6 import com.sun.tools.javac.comp.Resolve.VerboseResolutionMode; 31.7 - 31.8 -import java.util.Comparator; 31.9 -import java.util.HashMap; 31.10 -import java.util.Map; 31.11 -import java.util.Set; 31.12 -import java.util.TreeSet; 31.13 +import com.sun.tools.javac.util.GraphUtils.TarjanNode; 31.14 31.15 import java.util.ArrayList; 31.16 import java.util.Collections; 31.17 +import java.util.EnumMap; 31.18 import java.util.EnumSet; 31.19 +import java.util.HashMap; 31.20 import java.util.HashSet; 31.21 +import java.util.LinkedHashSet; 31.22 +import java.util.Map; 31.23 +import java.util.Set; 31.24 31.25 import static com.sun.tools.javac.code.TypeTag.*; 31.26 31.27 @@ -114,6 +114,12 @@ 31.28 } 31.29 31.30 @Override 31.31 + InapplicableMethodException setMessage() { 31.32 + //no message to set 31.33 + return this; 31.34 + } 31.35 + 31.36 + @Override 31.37 InapplicableMethodException setMessage(JCDiagnostic diag) { 31.38 messages = messages.append(diag); 31.39 return this; 31.40 @@ -1006,10 +1012,24 @@ 31.41 * and (ii) tell th engine when we are done fixing inference variables 31.42 */ 31.43 interface GraphStrategy { 31.44 + 31.45 + /** 31.46 + * A NodeNotFoundException is thrown whenever an inference strategy fails 31.47 + * to pick the next node to solve in the inference graph. 31.48 + */ 31.49 + public static class NodeNotFoundException extends RuntimeException { 31.50 + private static final long serialVersionUID = 0; 31.51 + 31.52 + InferenceGraph graph; 31.53 + 31.54 + public NodeNotFoundException(InferenceGraph graph) { 31.55 + this.graph = graph; 31.56 + } 31.57 + } 31.58 /** 31.59 * Pick the next node (leaf) to solve in the graph 31.60 */ 31.61 - Node pickNode(InferenceGraph g); 31.62 + Node pickNode(InferenceGraph g) throws NodeNotFoundException; 31.63 /** 31.64 * Is this the last step? 31.65 */ 31.66 @@ -1022,7 +1042,10 @@ 31.67 */ 31.68 abstract class LeafSolver implements GraphStrategy { 31.69 public Node pickNode(InferenceGraph g) { 31.70 - Assert.check(!g.nodes.isEmpty(), "No nodes to solve!"); 31.71 + if (g.nodes.isEmpty()) { 31.72 + //should not happen 31.73 + throw new NodeNotFoundException(g); 31.74 + }; 31.75 return g.nodes.get(0); 31.76 } 31.77 31.78 @@ -1069,6 +1092,7 @@ 31.79 */ 31.80 abstract class BestLeafSolver extends LeafSolver { 31.81 31.82 + /** list of ivars of which at least one must be solved */ 31.83 List<Type> varsToSolve; 31.84 31.85 BestLeafSolver(List<Type> varsToSolve) { 31.86 @@ -1076,54 +1100,66 @@ 31.87 } 31.88 31.89 /** 31.90 - * Computes the minimum path that goes from a given node to any of the nodes 31.91 - * containing a variable in {@code varsToSolve}. For any given path, the cost 31.92 - * is computed as the total number of type-variables that should be eagerly 31.93 - * instantiated across that path. 31.94 + * Computes a path that goes from a given node to the leafs in the graph. 31.95 + * Typically this will start from a node containing a variable in 31.96 + * {@code varsToSolve}. For any given path, the cost is computed as the total 31.97 + * number of type-variables that should be eagerly instantiated across that path. 31.98 */ 31.99 - int computeMinPath(InferenceGraph g, Node n) { 31.100 - return computeMinPath(g, n, List.<Node>nil(), 0); 31.101 + Pair<List<Node>, Integer> computeTreeToLeafs(Node n) { 31.102 + Pair<List<Node>, Integer> cachedPath = treeCache.get(n); 31.103 + if (cachedPath == null) { 31.104 + //cache miss 31.105 + if (n.isLeaf()) { 31.106 + //if leaf, stop 31.107 + cachedPath = new Pair<List<Node>, Integer>(List.of(n), n.data.length()); 31.108 + } else { 31.109 + //if non-leaf, proceed recursively 31.110 + Pair<List<Node>, Integer> path = new Pair<List<Node>, Integer>(List.of(n), n.data.length()); 31.111 + for (Node n2 : n.getAllDependencies()) { 31.112 + if (n2 == n) continue; 31.113 + Pair<List<Node>, Integer> subpath = computeTreeToLeafs(n2); 31.114 + path = new Pair<List<Node>, Integer>( 31.115 + path.fst.prependList(subpath.fst), 31.116 + path.snd + subpath.snd); 31.117 + } 31.118 + cachedPath = path; 31.119 + } 31.120 + //save results in cache 31.121 + treeCache.put(n, cachedPath); 31.122 + } 31.123 + return cachedPath; 31.124 } 31.125 31.126 - int computeMinPath(InferenceGraph g, Node n, List<Node> path, int cost) { 31.127 - if (path.contains(n)) return Integer.MAX_VALUE; 31.128 - List<Node> path2 = path.prepend(n); 31.129 - int cost2 = cost + n.data.size(); 31.130 - if (!Collections.disjoint(n.data, varsToSolve)) { 31.131 - return cost2; 31.132 - } else { 31.133 - int bestPath = Integer.MAX_VALUE; 31.134 - for (Node n2 : g.nodes) { 31.135 - if (n2.deps.contains(n)) { 31.136 - int res = computeMinPath(g, n2, path2, cost2); 31.137 - if (res < bestPath) { 31.138 - bestPath = res; 31.139 - } 31.140 - } 31.141 - } 31.142 - return bestPath; 31.143 - } 31.144 - } 31.145 + /** cache used to avoid redundant computation of tree costs */ 31.146 + final Map<Node, Pair<List<Node>, Integer>> treeCache = 31.147 + new HashMap<Node, Pair<List<Node>, Integer>>(); 31.148 + 31.149 + /** constant value used to mark non-existent paths */ 31.150 + final Pair<List<Node>, Integer> noPath = 31.151 + new Pair<List<Node>, Integer>(null, Integer.MAX_VALUE); 31.152 31.153 /** 31.154 * Pick the leaf that minimize cost 31.155 */ 31.156 @Override 31.157 public Node pickNode(final InferenceGraph g) { 31.158 - final Map<Node, Integer> leavesMap = new HashMap<Node, Integer>(); 31.159 + treeCache.clear(); //graph changes at every step - cache must be cleared 31.160 + Pair<List<Node>, Integer> bestPath = noPath; 31.161 for (Node n : g.nodes) { 31.162 - if (n.isLeaf(n)) { 31.163 - leavesMap.put(n, computeMinPath(g, n)); 31.164 + if (!Collections.disjoint(n.data, varsToSolve)) { 31.165 + Pair<List<Node>, Integer> path = computeTreeToLeafs(n); 31.166 + //discard all paths containing at least a node in the 31.167 + //closure computed above 31.168 + if (path.snd < bestPath.snd) { 31.169 + bestPath = path; 31.170 + } 31.171 } 31.172 } 31.173 - Assert.check(!leavesMap.isEmpty(), "No nodes to solve!"); 31.174 - TreeSet<Node> orderedLeaves = new TreeSet<Node>(new Comparator<Node>() { 31.175 - public int compare(Node n1, Node n2) { 31.176 - return leavesMap.get(n1) - leavesMap.get(n2); 31.177 - } 31.178 - }); 31.179 - orderedLeaves.addAll(leavesMap.keySet()); 31.180 - return orderedLeaves.first(); 31.181 + if (bestPath == noPath) { 31.182 + //no path leads there 31.183 + throw new NodeNotFoundException(g); 31.184 + } 31.185 + return bestPath.fst.head; 31.186 } 31.187 } 31.188 31.189 @@ -1321,6 +1357,33 @@ 31.190 } 31.191 31.192 /** 31.193 + * There are two kinds of dependencies between inference variables. The basic 31.194 + * kind of dependency (or bound dependency) arises when a variable mention 31.195 + * another variable in one of its bounds. There's also a more subtle kind 31.196 + * of dependency that arises when a variable 'might' lead to better constraints 31.197 + * on another variable (this is typically the case with variables holding up 31.198 + * stuck expressions). 31.199 + */ 31.200 + enum DependencyKind implements GraphUtils.DependencyKind { 31.201 + 31.202 + /** bound dependency */ 31.203 + BOUND("dotted"), 31.204 + /** stuck dependency */ 31.205 + STUCK("dashed"); 31.206 + 31.207 + final String dotSyle; 31.208 + 31.209 + private DependencyKind(String dotSyle) { 31.210 + this.dotSyle = dotSyle; 31.211 + } 31.212 + 31.213 + @Override 31.214 + public String getDotStyle() { 31.215 + return dotSyle; 31.216 + } 31.217 + } 31.218 + 31.219 + /** 31.220 * This is the graph inference solver - the solver organizes all inference variables in 31.221 * a given inference context by bound dependencies - in the general case, such dependencies 31.222 * would lead to a cyclic directed graph (hence the name); the dependency info is used to build 31.223 @@ -1331,10 +1394,12 @@ 31.224 class GraphSolver { 31.225 31.226 InferenceContext inferenceContext; 31.227 + Map<Type, Set<Type>> stuckDeps; 31.228 Warner warn; 31.229 31.230 - GraphSolver(InferenceContext inferenceContext, Warner warn) { 31.231 + GraphSolver(InferenceContext inferenceContext, Map<Type, Set<Type>> stuckDeps, Warner warn) { 31.232 this.inferenceContext = inferenceContext; 31.233 + this.stuckDeps = stuckDeps; 31.234 this.warn = warn; 31.235 } 31.236 31.237 @@ -1345,7 +1410,7 @@ 31.238 */ 31.239 void solve(GraphStrategy sstrategy) { 31.240 checkWithinBounds(inferenceContext, warn); //initial propagation of bounds 31.241 - InferenceGraph inferenceGraph = new InferenceGraph(); 31.242 + InferenceGraph inferenceGraph = new InferenceGraph(stuckDeps); 31.243 while (!sstrategy.done()) { 31.244 InferenceGraph.Node nodeToSolve = sstrategy.pickNode(inferenceGraph); 31.245 List<Type> varsToSolve = List.from(nodeToSolve.data); 31.246 @@ -1390,64 +1455,172 @@ 31.247 */ 31.248 class Node extends GraphUtils.TarjanNode<ListBuffer<Type>> { 31.249 31.250 - Set<Node> deps; 31.251 + /** map listing all dependencies (grouped by kind) */ 31.252 + EnumMap<DependencyKind, Set<Node>> deps; 31.253 31.254 Node(Type ivar) { 31.255 super(ListBuffer.of(ivar)); 31.256 - this.deps = new HashSet<Node>(); 31.257 + this.deps = new EnumMap<DependencyKind, Set<Node>>(DependencyKind.class); 31.258 } 31.259 31.260 @Override 31.261 - public Iterable<? extends Node> getDependencies() { 31.262 - return deps; 31.263 + public GraphUtils.DependencyKind[] getSupportedDependencyKinds() { 31.264 + return DependencyKind.values(); 31.265 } 31.266 31.267 @Override 31.268 - public String printDependency(GraphUtils.Node<ListBuffer<Type>> to) { 31.269 - StringBuilder buf = new StringBuilder(); 31.270 - String sep = ""; 31.271 - for (Type from : data) { 31.272 - UndetVar uv = (UndetVar)inferenceContext.asFree(from); 31.273 - for (Type bound : uv.getBounds(InferenceBound.values())) { 31.274 - if (bound.containsAny(List.from(to.data))) { 31.275 - buf.append(sep); 31.276 - buf.append(bound); 31.277 - sep = ","; 31.278 + public String getDependencyName(GraphUtils.Node<ListBuffer<Type>> to, GraphUtils.DependencyKind dk) { 31.279 + if (dk == DependencyKind.STUCK) return ""; 31.280 + else { 31.281 + StringBuilder buf = new StringBuilder(); 31.282 + String sep = ""; 31.283 + for (Type from : data) { 31.284 + UndetVar uv = (UndetVar)inferenceContext.asFree(from); 31.285 + for (Type bound : uv.getBounds(InferenceBound.values())) { 31.286 + if (bound.containsAny(List.from(to.data))) { 31.287 + buf.append(sep); 31.288 + buf.append(bound); 31.289 + sep = ","; 31.290 + } 31.291 } 31.292 } 31.293 + return buf.toString(); 31.294 } 31.295 - return buf.toString(); 31.296 } 31.297 31.298 - boolean isLeaf(Node n) { 31.299 - //no deps, or only one self dep 31.300 - return (n.deps.isEmpty() || 31.301 - n.deps.size() == 1 && n.deps.contains(n)); 31.302 + @Override 31.303 + public Iterable<? extends Node> getAllDependencies() { 31.304 + return getDependencies(DependencyKind.values()); 31.305 } 31.306 31.307 - void mergeWith(List<? extends Node> nodes) { 31.308 + @Override 31.309 + public Iterable<? extends TarjanNode<ListBuffer<Type>>> getDependenciesByKind(GraphUtils.DependencyKind dk) { 31.310 + return getDependencies((DependencyKind)dk); 31.311 + } 31.312 + 31.313 + /** 31.314 + * Retrieves all dependencies with given kind(s). 31.315 + */ 31.316 + protected Set<Node> getDependencies(DependencyKind... depKinds) { 31.317 + Set<Node> buf = new LinkedHashSet<Node>(); 31.318 + for (DependencyKind dk : depKinds) { 31.319 + Set<Node> depsByKind = deps.get(dk); 31.320 + if (depsByKind != null) { 31.321 + buf.addAll(depsByKind); 31.322 + } 31.323 + } 31.324 + return buf; 31.325 + } 31.326 + 31.327 + /** 31.328 + * Adds dependency with given kind. 31.329 + */ 31.330 + protected void addDependency(DependencyKind dk, Node depToAdd) { 31.331 + Set<Node> depsByKind = deps.get(dk); 31.332 + if (depsByKind == null) { 31.333 + depsByKind = new LinkedHashSet<Node>(); 31.334 + deps.put(dk, depsByKind); 31.335 + } 31.336 + depsByKind.add(depToAdd); 31.337 + } 31.338 + 31.339 + /** 31.340 + * Add multiple dependencies of same given kind. 31.341 + */ 31.342 + protected void addDependencies(DependencyKind dk, Set<Node> depsToAdd) { 31.343 + for (Node n : depsToAdd) { 31.344 + addDependency(dk, n); 31.345 + } 31.346 + } 31.347 + 31.348 + /** 31.349 + * Remove a dependency, regardless of its kind. 31.350 + */ 31.351 + protected Set<DependencyKind> removeDependency(Node n) { 31.352 + Set<DependencyKind> removedKinds = new HashSet<>(); 31.353 + for (DependencyKind dk : DependencyKind.values()) { 31.354 + Set<Node> depsByKind = deps.get(dk); 31.355 + if (depsByKind == null) continue; 31.356 + if (depsByKind.remove(n)) { 31.357 + removedKinds.add(dk); 31.358 + } 31.359 + } 31.360 + return removedKinds; 31.361 + } 31.362 + 31.363 + /** 31.364 + * Compute closure of a give node, by recursively walking 31.365 + * through all its dependencies (of given kinds) 31.366 + */ 31.367 + protected Set<Node> closure(DependencyKind... depKinds) { 31.368 + boolean progress = true; 31.369 + Set<Node> closure = new HashSet<Node>(); 31.370 + closure.add(this); 31.371 + while (progress) { 31.372 + progress = false; 31.373 + for (Node n1 : new HashSet<Node>(closure)) { 31.374 + progress = closure.addAll(n1.getDependencies(depKinds)); 31.375 + } 31.376 + } 31.377 + return closure; 31.378 + } 31.379 + 31.380 + /** 31.381 + * Is this node a leaf? This means either the node has no dependencies, 31.382 + * or it just has self-dependencies. 31.383 + */ 31.384 + protected boolean isLeaf() { 31.385 + //no deps, or only one self dep 31.386 + Set<Node> allDeps = getDependencies(DependencyKind.BOUND, DependencyKind.STUCK); 31.387 + if (allDeps.isEmpty()) return true; 31.388 + for (Node n : allDeps) { 31.389 + if (n != this) { 31.390 + return false; 31.391 + } 31.392 + } 31.393 + return true; 31.394 + } 31.395 + 31.396 + /** 31.397 + * Merge this node with another node, acquiring its dependencies. 31.398 + * This routine is used to merge all cyclic node together and 31.399 + * form an acyclic graph. 31.400 + */ 31.401 + protected void mergeWith(List<? extends Node> nodes) { 31.402 for (Node n : nodes) { 31.403 Assert.check(n.data.length() == 1, "Attempt to merge a compound node!"); 31.404 data.appendList(n.data); 31.405 - deps.addAll(n.deps); 31.406 + for (DependencyKind dk : DependencyKind.values()) { 31.407 + addDependencies(dk, n.getDependencies(dk)); 31.408 + } 31.409 } 31.410 //update deps 31.411 - Set<Node> deps2 = new HashSet<Node>(); 31.412 - for (Node d : deps) { 31.413 - if (data.contains(d.data.first())) { 31.414 - deps2.add(this); 31.415 - } else { 31.416 - deps2.add(d); 31.417 + EnumMap<DependencyKind, Set<Node>> deps2 = new EnumMap<DependencyKind, Set<Node>>(DependencyKind.class); 31.418 + for (DependencyKind dk : DependencyKind.values()) { 31.419 + for (Node d : getDependencies(dk)) { 31.420 + Set<Node> depsByKind = deps2.get(dk); 31.421 + if (depsByKind == null) { 31.422 + depsByKind = new LinkedHashSet<Node>(); 31.423 + deps2.put(dk, depsByKind); 31.424 + } 31.425 + if (data.contains(d.data.first())) { 31.426 + depsByKind.add(this); 31.427 + } else { 31.428 + depsByKind.add(d); 31.429 + } 31.430 } 31.431 } 31.432 deps = deps2; 31.433 } 31.434 31.435 - void graphChanged(Node from, Node to) { 31.436 - if (deps.contains(from)) { 31.437 - deps.remove(from); 31.438 + /** 31.439 + * Notify all nodes that something has changed in the graph 31.440 + * topology. 31.441 + */ 31.442 + private void graphChanged(Node from, Node to) { 31.443 + for (DependencyKind dk : removeDependency(from)) { 31.444 if (to != null) { 31.445 - deps.add(to); 31.446 + addDependency(dk, to); 31.447 } 31.448 } 31.449 } 31.450 @@ -1456,8 +1629,21 @@ 31.451 /** the nodes in the inference graph */ 31.452 ArrayList<Node> nodes; 31.453 31.454 - InferenceGraph() { 31.455 - initNodes(); 31.456 + InferenceGraph(Map<Type, Set<Type>> optDeps) { 31.457 + initNodes(optDeps); 31.458 + } 31.459 + 31.460 + /** 31.461 + * Basic lookup helper for retrieving a graph node given an inference 31.462 + * variable type. 31.463 + */ 31.464 + public Node findNode(Type t) { 31.465 + for (Node n : nodes) { 31.466 + if (n.data.contains(t)) { 31.467 + return n; 31.468 + } 31.469 + } 31.470 + return null; 31.471 } 31.472 31.473 /** 31.474 @@ -1484,24 +1670,32 @@ 31.475 * Create the graph nodes. First a simple node is created for every inference 31.476 * variables to be solved. Then Tarjan is used to found all connected components 31.477 * in the graph. For each component containing more than one node, a super node is 31.478 - * created, effectively replacing the original cyclic nodes. 31.479 + * created, effectively replacing the original cyclic nodes. 31.480 */ 31.481 - void initNodes() { 31.482 + void initNodes(Map<Type, Set<Type>> stuckDeps) { 31.483 + //add nodes 31.484 nodes = new ArrayList<Node>(); 31.485 for (Type t : inferenceContext.restvars()) { 31.486 nodes.add(new Node(t)); 31.487 } 31.488 + //add dependencies 31.489 for (Node n_i : nodes) { 31.490 Type i = n_i.data.first(); 31.491 + Set<Type> optDepsByNode = stuckDeps.get(i); 31.492 for (Node n_j : nodes) { 31.493 Type j = n_j.data.first(); 31.494 UndetVar uv_i = (UndetVar)inferenceContext.asFree(i); 31.495 if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) { 31.496 - //update i's deps 31.497 - n_i.deps.add(n_j); 31.498 + //update i's bound dependencies 31.499 + n_i.addDependency(DependencyKind.BOUND, n_j); 31.500 + } 31.501 + if (optDepsByNode != null && optDepsByNode.contains(j)) { 31.502 + //update i's stuck dependencies 31.503 + n_i.addDependency(DependencyKind.STUCK, n_j); 31.504 } 31.505 } 31.506 } 31.507 + //merge cyclic nodes 31.508 ArrayList<Node> acyclicNodes = new ArrayList<Node>(); 31.509 for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) { 31.510 if (conSubGraph.length() > 1) { 31.511 @@ -1631,8 +1825,8 @@ 31.512 return filterVars(new Filter<UndetVar>() { 31.513 public boolean accepts(UndetVar uv) { 31.514 return uv.getBounds(InferenceBound.UPPER) 31.515 - .diff(uv.getDeclaredBounds()) 31.516 - .appendList(uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)).nonEmpty(); 31.517 + .diff(uv.getDeclaredBounds()) 31.518 + .appendList(uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)).nonEmpty(); 31.519 } 31.520 }); 31.521 } 31.522 @@ -1822,11 +2016,15 @@ 31.523 } 31.524 } 31.525 31.526 + private void solve(GraphStrategy ss, Warner warn) { 31.527 + solve(ss, new HashMap<Type, Set<Type>>(), warn); 31.528 + } 31.529 + 31.530 /** 31.531 * Solve with given graph strategy. 31.532 */ 31.533 - private void solve(GraphStrategy ss, Warner warn) { 31.534 - GraphSolver s = new GraphSolver(this, warn); 31.535 + private void solve(GraphStrategy ss, Map<Type, Set<Type>> stuckDeps, Warner warn) { 31.536 + GraphSolver s = new GraphSolver(this, stuckDeps, warn); 31.537 s.solve(ss); 31.538 } 31.539 31.540 @@ -1855,18 +2053,12 @@ 31.541 /** 31.542 * Solve at least one variable in given list. 31.543 */ 31.544 - public void solveAny(List<Type> varsToSolve, Warner warn) { 31.545 - checkWithinBounds(this, warn); //propagate bounds 31.546 - List<Type> boundedVars = boundedVars().intersect(restvars()).intersect(varsToSolve); 31.547 - if (boundedVars.isEmpty()) { 31.548 - throw inferenceException.setMessage("cyclic.inference", 31.549 - freeVarsIn(varsToSolve)); 31.550 - } 31.551 - solve(new BestLeafSolver(boundedVars) { 31.552 + public void solveAny(List<Type> varsToSolve, Map<Type, Set<Type>> optDeps, Warner warn) { 31.553 + solve(new BestLeafSolver(varsToSolve.intersect(restvars())) { 31.554 public boolean done() { 31.555 return instvars().intersect(varsToSolve).nonEmpty(); 31.556 } 31.557 - }, warn); 31.558 + }, optDeps, warn); 31.559 } 31.560 31.561 /**
32.1 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Thu Sep 12 11:09:20 2013 -0700 32.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue Sep 17 08:21:11 2013 -0700 32.3 @@ -1745,6 +1745,11 @@ 32.4 // Just erase the type var 32.5 ret = new VarSymbol(sym.flags(), name, 32.6 types.erasure(sym.type), sym.owner); 32.7 + 32.8 + /* this information should also be kept for LVT generation at Gen 32.9 + * a Symbol with pos < startPos won't be tracked. 32.10 + */ 32.11 + ((VarSymbol)ret).pos = ((VarSymbol)sym).pos; 32.12 break; 32.13 case CAPTURED_VAR: 32.14 ret = new VarSymbol(SYNTHETIC | FINAL, name, types.erasure(sym.type), translatedSym) {
33.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Thu Sep 12 11:09:20 2013 -0700 33.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Sep 17 08:21:11 2013 -0700 33.3 @@ -49,7 +49,6 @@ 33.4 import static com.sun.tools.javac.code.TypeTag.*; 33.5 import static com.sun.tools.javac.jvm.ByteCodes.*; 33.6 import static com.sun.tools.javac.tree.JCTree.Tag.*; 33.7 -import javax.lang.model.type.TypeKind; 33.8 33.9 /** This pass translates away some syntactic sugar: inner classes, 33.10 * class literals, assertions, foreach loops, etc. 33.11 @@ -1480,7 +1479,12 @@ 33.12 * @param owner The class in which the definitions go. 33.13 */ 33.14 List<JCVariableDecl> freevarDefs(int pos, List<VarSymbol> freevars, Symbol owner) { 33.15 - long flags = FINAL | SYNTHETIC; 33.16 + return freevarDefs(pos, freevars, owner, 0); 33.17 + } 33.18 + 33.19 + List<JCVariableDecl> freevarDefs(int pos, List<VarSymbol> freevars, Symbol owner, 33.20 + long additionalFlags) { 33.21 + long flags = FINAL | SYNTHETIC | additionalFlags; 33.22 if (owner.kind == TYP && 33.23 target.usePrivateSyntheticFields()) 33.24 flags |= PRIVATE; 33.25 @@ -1543,7 +1547,7 @@ 33.26 (owner.isConstructor() && c.isInner() && 33.27 !c.isPrivate() && !c.isStatic()); 33.28 long flags = 33.29 - FINAL | (isMandated ? MANDATED : SYNTHETIC); 33.30 + FINAL | (isMandated ? MANDATED : SYNTHETIC) | PARAMETER; 33.31 VarSymbol outerThis = makeOuterThisVarSymbol(owner, flags); 33.32 owner.extraParams = owner.extraParams.prepend(outerThis); 33.33 return makeOuterThisVarDecl(pos, outerThis); 33.34 @@ -1627,7 +1631,8 @@ 33.35 JCTree makeTwrTry(JCTry tree) { 33.36 make_at(tree.pos()); 33.37 twrVars = twrVars.dup(); 33.38 - JCBlock twrBlock = makeTwrBlock(tree.resources, tree.body, 0); 33.39 + JCBlock twrBlock = makeTwrBlock(tree.resources, tree.body, 33.40 + tree.finallyCanCompleteNormally, 0); 33.41 if (tree.catchers.isEmpty() && tree.finalizer == null) 33.42 result = translate(twrBlock); 33.43 else 33.44 @@ -1636,7 +1641,8 @@ 33.45 return result; 33.46 } 33.47 33.48 - private JCBlock makeTwrBlock(List<JCTree> resources, JCBlock block, int depth) { 33.49 + private JCBlock makeTwrBlock(List<JCTree> resources, JCBlock block, 33.50 + boolean finallyCanCompleteNormally, int depth) { 33.51 if (resources.isEmpty()) 33.52 return block; 33.53 33.54 @@ -1692,17 +1698,20 @@ 33.55 make.at(TreeInfo.endPos(block)); 33.56 JCBlock finallyClause = makeTwrFinallyClause(primaryException, expr); 33.57 make.at(oldPos); 33.58 - JCTry outerTry = make.Try(makeTwrBlock(resources.tail, block, depth + 1), 33.59 + JCTry outerTry = make.Try(makeTwrBlock(resources.tail, block, 33.60 + finallyCanCompleteNormally, depth + 1), 33.61 List.<JCCatch>of(catchClause), 33.62 finallyClause); 33.63 + outerTry.finallyCanCompleteNormally = finallyCanCompleteNormally; 33.64 stats.add(outerTry); 33.65 - return make.Block(0L, stats.toList()); 33.66 + JCBlock newBlock = make.Block(0L, stats.toList()); 33.67 + return newBlock; 33.68 } 33.69 33.70 private JCBlock makeTwrFinallyClause(Symbol primaryException, JCExpression resource) { 33.71 // primaryException.addSuppressed(catchException); 33.72 VarSymbol catchException = 33.73 - new VarSymbol(0, make.paramName(2), 33.74 + new VarSymbol(SYNTHETIC, make.paramName(2), 33.75 syms.throwableType, 33.76 currentMethodSym); 33.77 JCStatement addSuppressionStatement = 33.78 @@ -1717,6 +1726,7 @@ 33.79 JCBlock catchBlock = make.Block(0L, List.<JCStatement>of(addSuppressionStatement)); 33.80 List<JCCatch> catchClauses = List.<JCCatch>of(make.Catch(catchExceptionDecl, catchBlock)); 33.81 JCTry tryTree = make.Try(tryBlock, catchClauses, null); 33.82 + tryTree.finallyCanCompleteNormally = true; 33.83 33.84 // if (primaryException != null) {try...} else resourceClose; 33.85 JCIf closeIfStatement = make.If(makeNonNullCheck(make.Ident(primaryException)), 33.86 @@ -2017,7 +2027,7 @@ 33.87 33.88 // catchParam := ClassNotFoundException e1 33.89 VarSymbol catchParam = 33.90 - new VarSymbol(0, make.paramName(1), 33.91 + new VarSymbol(SYNTHETIC, make.paramName(1), 33.92 syms.classNotFoundExceptionType, 33.93 classDollarSym); 33.94 33.95 @@ -2705,7 +2715,7 @@ 33.96 JCVariableDecl otdef = null; 33.97 if (currentClass.hasOuterInstance()) 33.98 otdef = outerThisDef(tree.pos, m); 33.99 - List<JCVariableDecl> fvdefs = freevarDefs(tree.pos, fvs, m); 33.100 + List<JCVariableDecl> fvdefs = freevarDefs(tree.pos, fvs, m, PARAMETER); 33.101 33.102 // Recursively translate result type, parameters and thrown list. 33.103 tree.restype = translate(tree.restype); 33.104 @@ -3364,18 +3374,18 @@ 33.105 */ 33.106 private void visitArrayForeachLoop(JCEnhancedForLoop tree) { 33.107 make_at(tree.expr.pos()); 33.108 - VarSymbol arraycache = new VarSymbol(0, 33.109 + VarSymbol arraycache = new VarSymbol(SYNTHETIC, 33.110 names.fromString("arr" + target.syntheticNameChar()), 33.111 tree.expr.type, 33.112 currentMethodSym); 33.113 JCStatement arraycachedef = make.VarDef(arraycache, tree.expr); 33.114 - VarSymbol lencache = new VarSymbol(0, 33.115 + VarSymbol lencache = new VarSymbol(SYNTHETIC, 33.116 names.fromString("len" + target.syntheticNameChar()), 33.117 syms.intType, 33.118 currentMethodSym); 33.119 JCStatement lencachedef = make. 33.120 VarDef(lencache, make.Select(make.Ident(arraycache), syms.lengthVar)); 33.121 - VarSymbol index = new VarSymbol(0, 33.122 + VarSymbol index = new VarSymbol(SYNTHETIC, 33.123 names.fromString("i" + target.syntheticNameChar()), 33.124 syms.intType, 33.125 currentMethodSym); 33.126 @@ -3457,7 +3467,7 @@ 33.127 names.iterator, 33.128 eType, 33.129 List.<Type>nil()); 33.130 - VarSymbol itvar = new VarSymbol(0, names.fromString("i" + target.syntheticNameChar()), 33.131 + VarSymbol itvar = new VarSymbol(SYNTHETIC, names.fromString("i" + target.syntheticNameChar()), 33.132 types.erasure(types.asSuper(iterator.type.getReturnType(), syms.iteratorType.tsym)), 33.133 currentMethodSym); 33.134 33.135 @@ -3830,19 +3840,32 @@ 33.136 33.137 @Override 33.138 public void visitTry(JCTry tree) { 33.139 - /* special case of try without catchers and with finally emtpy. 33.140 - * Don't give it a try, translate only the body. 33.141 - */ 33.142 - if (tree.resources.isEmpty()) { 33.143 - if (tree.catchers.isEmpty() && 33.144 - tree.finalizer.getStatements().isEmpty()) { 33.145 + if (tree.resources.nonEmpty()) { 33.146 + result = makeTwrTry(tree); 33.147 + return; 33.148 + } 33.149 + 33.150 + boolean hasBody = tree.body.getStatements().nonEmpty(); 33.151 + boolean hasCatchers = tree.catchers.nonEmpty(); 33.152 + boolean hasFinally = tree.finalizer != null && 33.153 + tree.finalizer.getStatements().nonEmpty(); 33.154 + 33.155 + if (!hasCatchers && !hasFinally) { 33.156 + result = translate(tree.body); 33.157 + return; 33.158 + } 33.159 + 33.160 + if (!hasBody) { 33.161 + if (hasFinally) { 33.162 + result = translate(tree.finalizer); 33.163 + } else { 33.164 result = translate(tree.body); 33.165 - } else { 33.166 - super.visitTry(tree); 33.167 } 33.168 - } else { 33.169 - result = makeTwrTry(tree); 33.170 + return; 33.171 } 33.172 + 33.173 + // no optimizations possible 33.174 + super.visitTry(tree); 33.175 } 33.176 33.177 /**************************************************************************
34.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Sep 12 11:09:20 2013 -0700 34.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Sep 17 08:21:11 2013 -0700 34.3 @@ -84,6 +84,7 @@ 34.4 private final Source source; 34.5 private final Target target; 34.6 private final DeferredLintHandler deferredLintHandler; 34.7 + private final Lint lint; 34.8 34.9 public static MemberEnter instance(Context context) { 34.10 MemberEnter instance = context.get(memberEnterKey); 34.11 @@ -109,6 +110,7 @@ 34.12 source = Source.instance(context); 34.13 target = Target.instance(context); 34.14 deferredLintHandler = DeferredLintHandler.instance(context); 34.15 + lint = Lint.instance(context); 34.16 allowTypeAnnos = source.allowTypeAnnotations(); 34.17 } 34.18 34.19 @@ -506,9 +508,10 @@ 34.20 } 34.21 34.22 // process package annotations 34.23 - annotateLater(tree.packageAnnotations, env, tree.packge); 34.24 + annotateLater(tree.packageAnnotations, env, tree.packge, null); 34.25 34.26 - DeferredLintHandler prevLintHandler = chk.setDeferredLintHandler(DeferredLintHandler.immediateHandler); 34.27 + DiagnosticPosition prevLintPos = deferredLintHandler.immediate(); 34.28 + Lint prevLint = chk.setLint(lint); 34.29 34.30 try { 34.31 // Import-on-demand java.lang. 34.32 @@ -517,7 +520,8 @@ 34.33 // Process all import clauses. 34.34 memberEnter(tree.defs, env); 34.35 } finally { 34.36 - chk.setDeferredLintHandler(prevLintHandler); 34.37 + chk.setLint(prevLint); 34.38 + deferredLintHandler.setPos(prevLintPos); 34.39 } 34.40 } 34.41 34.42 @@ -564,8 +568,7 @@ 34.43 34.44 Env<AttrContext> localEnv = methodEnv(tree, env); 34.45 34.46 - DeferredLintHandler prevLintHandler = 34.47 - chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos())); 34.48 + DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); 34.49 try { 34.50 // Compute the method type 34.51 m.type = signature(m, tree.typarams, tree.params, 34.52 @@ -573,7 +576,7 @@ 34.53 tree.thrown, 34.54 localEnv); 34.55 } finally { 34.56 - chk.setDeferredLintHandler(prevLintHandler); 34.57 + deferredLintHandler.setPos(prevLintPos); 34.58 } 34.59 34.60 if (types.isSignaturePolymorphic(m)) { 34.61 @@ -597,10 +600,10 @@ 34.62 if (chk.checkUnique(tree.pos(), m, enclScope)) { 34.63 enclScope.enter(m); 34.64 } 34.65 - annotateLater(tree.mods.annotations, localEnv, m); 34.66 + annotateLater(tree.mods.annotations, localEnv, m, tree.pos()); 34.67 // Visit the signature of the method. Note that 34.68 // TypeAnnotate doesn't descend into the body. 34.69 - typeAnnotate(tree, localEnv, m); 34.70 + typeAnnotate(tree, localEnv, m, tree.pos()); 34.71 34.72 if (tree.defaultValue != null) 34.73 annotateDefaultValueLater(tree.defaultValue, localEnv, m); 34.74 @@ -630,15 +633,14 @@ 34.75 localEnv = env.dup(tree, env.info.dup()); 34.76 localEnv.info.staticLevel++; 34.77 } 34.78 - DeferredLintHandler prevLintHandler = 34.79 - chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos())); 34.80 + DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); 34.81 try { 34.82 if (TreeInfo.isEnumInit(tree)) { 34.83 attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype); 34.84 } else { 34.85 // Make sure type annotations are processed. 34.86 // But we don't have a symbol to attach them to yet - use null. 34.87 - typeAnnotate(tree.vartype, env, null); 34.88 + typeAnnotate(tree.vartype, env, null, tree.pos()); 34.89 attr.attribType(tree.vartype, localEnv); 34.90 if (tree.nameexpr != null) { 34.91 attr.attribExpr(tree.nameexpr, localEnv); 34.92 @@ -658,7 +660,7 @@ 34.93 } 34.94 } 34.95 } finally { 34.96 - chk.setDeferredLintHandler(prevLintHandler); 34.97 + deferredLintHandler.setPos(prevLintPos); 34.98 } 34.99 34.100 if ((tree.mods.flags & VARARGS) != 0) { 34.101 @@ -680,15 +682,15 @@ 34.102 needsLazyConstValue(tree.init)) { 34.103 Env<AttrContext> initEnv = getInitEnv(tree, env); 34.104 initEnv.info.enclVar = v; 34.105 - v.setLazyConstValue(initEnv(tree, initEnv), attr, tree.init); 34.106 + v.setLazyConstValue(initEnv(tree, initEnv), attr, tree); 34.107 } 34.108 } 34.109 if (chk.checkUnique(tree.pos(), v, enclScope)) { 34.110 chk.checkTransparentVar(tree.pos(), v, enclScope); 34.111 enclScope.enter(v); 34.112 } 34.113 - annotateLater(tree.mods.annotations, localEnv, v); 34.114 - typeAnnotate(tree.vartype, env, v); 34.115 + annotateLater(tree.mods.annotations, localEnv, v, tree.pos()); 34.116 + typeAnnotate(tree.vartype, env, v, tree.pos()); 34.117 annotate.flush(); 34.118 v.pos = tree.pos; 34.119 } 34.120 @@ -720,6 +722,11 @@ 34.121 } 34.122 34.123 @Override 34.124 + public void visitNewArray(JCNewArray that) { 34.125 + result = false; 34.126 + } 34.127 + 34.128 + @Override 34.129 public void visitLambda(JCLambda that) { 34.130 result = false; 34.131 } 34.132 @@ -730,6 +737,11 @@ 34.133 } 34.134 34.135 @Override 34.136 + public void visitApply(JCMethodInvocation that) { 34.137 + result = false; 34.138 + } 34.139 + 34.140 + @Override 34.141 public void visitSelect(JCFieldAccess tree) { 34.142 tree.selected.accept(this); 34.143 } 34.144 @@ -820,7 +832,8 @@ 34.145 /** Queue annotations for later processing. */ 34.146 void annotateLater(final List<JCAnnotation> annotations, 34.147 final Env<AttrContext> localEnv, 34.148 - final Symbol s) { 34.149 + final Symbol s, 34.150 + final DiagnosticPosition deferPos) { 34.151 if (annotations.isEmpty()) { 34.152 return; 34.153 } 34.154 @@ -837,6 +850,11 @@ 34.155 public void enterAnnotation() { 34.156 Assert.check(s.kind == PCK || s.annotationsPendingCompletion()); 34.157 JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); 34.158 + DiagnosticPosition prevLintPos = 34.159 + deferPos != null 34.160 + ? deferredLintHandler.setPos(deferPos) 34.161 + : deferredLintHandler.immediate(); 34.162 + Lint prevLint = deferPos != null ? null : chk.setLint(lint); 34.163 try { 34.164 if (s.hasAnnotations() && 34.165 annotations.nonEmpty()) 34.166 @@ -845,6 +863,9 @@ 34.167 kindName(s), s); 34.168 actualEnterAnnotations(annotations, localEnv, s); 34.169 } finally { 34.170 + if (prevLint != null) 34.171 + chk.setLint(prevLint); 34.172 + deferredLintHandler.setPos(prevLintPos); 34.173 log.useSource(prev); 34.174 } 34.175 } 34.176 @@ -964,6 +985,7 @@ 34.177 isFirst = false; 34.178 34.179 JavaFileObject prev = log.useSource(env.toplevel.sourcefile); 34.180 + DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); 34.181 try { 34.182 // Save class environment for later member enter (2) processing. 34.183 halfcompleted.append(env); 34.184 @@ -985,9 +1007,9 @@ 34.185 Env<AttrContext> baseEnv = baseEnv(tree, env); 34.186 34.187 if (tree.extending != null) 34.188 - typeAnnotate(tree.extending, baseEnv, sym); 34.189 + typeAnnotate(tree.extending, baseEnv, sym, tree.pos()); 34.190 for (JCExpression impl : tree.implementing) 34.191 - typeAnnotate(impl, baseEnv, sym); 34.192 + typeAnnotate(impl, baseEnv, sym, tree.pos()); 34.193 annotate.flush(); 34.194 34.195 // Determine supertype. 34.196 @@ -1048,7 +1070,7 @@ 34.197 attr.attribAnnotationTypes(tree.mods.annotations, baseEnv); 34.198 if (hasDeprecatedAnnotation(tree.mods.annotations)) 34.199 c.flags_field |= DEPRECATED; 34.200 - annotateLater(tree.mods.annotations, baseEnv, c); 34.201 + annotateLater(tree.mods.annotations, baseEnv, c, tree.pos()); 34.202 // class type parameters use baseEnv but everything uses env 34.203 34.204 chk.checkNonCyclicDecl(tree); 34.205 @@ -1056,7 +1078,7 @@ 34.206 attr.attribTypeVariables(tree.typarams, baseEnv); 34.207 // Do this here, where we have the symbol. 34.208 for (JCTypeParameter tp : tree.typarams) 34.209 - typeAnnotate(tp, baseEnv, sym); 34.210 + typeAnnotate(tp, baseEnv, sym, tree.pos()); 34.211 annotate.flush(); 34.212 34.213 // Add default constructor if needed. 34.214 @@ -1126,6 +1148,7 @@ 34.215 } catch (CompletionFailure ex) { 34.216 chk.completionError(tree.pos(), ex); 34.217 } finally { 34.218 + deferredLintHandler.setPos(prevLintPos); 34.219 log.useSource(prev); 34.220 } 34.221 34.222 @@ -1186,9 +1209,9 @@ 34.223 } 34.224 } 34.225 34.226 - public void typeAnnotate(final JCTree tree, final Env<AttrContext> env, final Symbol sym) { 34.227 + public void typeAnnotate(final JCTree tree, final Env<AttrContext> env, final Symbol sym, DiagnosticPosition deferPos) { 34.228 if (allowTypeAnnos) { 34.229 - tree.accept(new TypeAnnotate(env, sym)); 34.230 + tree.accept(new TypeAnnotate(env, sym, deferPos)); 34.231 } 34.232 } 34.233 34.234 @@ -1199,10 +1222,12 @@ 34.235 private class TypeAnnotate extends TreeScanner { 34.236 private Env<AttrContext> env; 34.237 private Symbol sym; 34.238 + private DiagnosticPosition deferPos; 34.239 34.240 - public TypeAnnotate(final Env<AttrContext> env, final Symbol sym) { 34.241 + public TypeAnnotate(final Env<AttrContext> env, final Symbol sym, DiagnosticPosition deferPos) { 34.242 this.env = env; 34.243 this.sym = sym; 34.244 + this.deferPos = deferPos; 34.245 } 34.246 34.247 void annotateTypeLater(final List<JCAnnotation> annotations) { 34.248 @@ -1210,6 +1235,8 @@ 34.249 return; 34.250 } 34.251 34.252 + final DiagnosticPosition deferPos = this.deferPos; 34.253 + 34.254 annotate.normal(new Annotate.Annotator() { 34.255 @Override 34.256 public String toString() { 34.257 @@ -1218,9 +1245,16 @@ 34.258 @Override 34.259 public void enterAnnotation() { 34.260 JavaFileObject prev = log.useSource(env.toplevel.sourcefile); 34.261 + DiagnosticPosition prevLintPos = null; 34.262 + 34.263 + if (deferPos != null) { 34.264 + prevLintPos = deferredLintHandler.setPos(deferPos); 34.265 + } 34.266 try { 34.267 actualEnterTypeAnnotations(annotations, env, sym); 34.268 } finally { 34.269 + if (prevLintPos != null) 34.270 + deferredLintHandler.setPos(prevLintPos); 34.271 log.useSource(prev); 34.272 } 34.273 } 34.274 @@ -1262,13 +1296,19 @@ 34.275 34.276 @Override 34.277 public void visitVarDef(final JCVariableDecl tree) { 34.278 - if (sym != null && sym.kind == Kinds.VAR) { 34.279 - // Don't visit a parameter once when the sym is the method 34.280 - // and once when the sym is the parameter. 34.281 - scan(tree.mods); 34.282 - scan(tree.vartype); 34.283 + DiagnosticPosition prevPos = deferPos; 34.284 + deferPos = tree.pos(); 34.285 + try { 34.286 + if (sym != null && sym.kind == Kinds.VAR) { 34.287 + // Don't visit a parameter once when the sym is the method 34.288 + // and once when the sym is the parameter. 34.289 + scan(tree.mods); 34.290 + scan(tree.vartype); 34.291 + } 34.292 + scan(tree.init); 34.293 + } finally { 34.294 + deferPos = prevPos; 34.295 } 34.296 - scan(tree.init); 34.297 } 34.298 34.299 @Override 34.300 @@ -1532,7 +1572,7 @@ 34.301 * parameters from baseInit. 34.302 */ 34.303 initParams = List.nil(); 34.304 - VarSymbol param = new VarSymbol(0, make.paramName(0), argtypes.head, init); 34.305 + VarSymbol param = new VarSymbol(PARAMETER, make.paramName(0), argtypes.head, init); 34.306 initParams = initParams.append(param); 34.307 argTypesList = argTypesList.tail; 34.308 } 34.309 @@ -1541,7 +1581,7 @@ 34.310 initParams = (initParams == null) ? List.<VarSymbol>nil() : initParams; 34.311 List<VarSymbol> baseInitParams = baseInit.params; 34.312 while (baseInitParams.nonEmpty() && argTypesList.nonEmpty()) { 34.313 - VarSymbol param = new VarSymbol(baseInitParams.head.flags(), 34.314 + VarSymbol param = new VarSymbol(baseInitParams.head.flags() | PARAMETER, 34.315 baseInitParams.head.name, argTypesList.head, init); 34.316 initParams = initParams.append(param); 34.317 baseInitParams = baseInitParams.tail;
35.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Sep 12 11:09:20 2013 -0700 35.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Sep 17 08:21:11 2013 -0700 35.3 @@ -568,8 +568,10 @@ 35.4 currentResolutionContext, 35.5 warn); 35.6 35.7 - currentResolutionContext.methodCheck.argumentsAcceptable(env, currentResolutionContext.deferredAttrContext(m, infer.emptyContext, resultInfo, warn), 35.8 + DeferredAttr.DeferredAttrContext dc = currentResolutionContext.deferredAttrContext(m, infer.emptyContext, resultInfo, warn); 35.9 + currentResolutionContext.methodCheck.argumentsAcceptable(env, dc, 35.10 argtypes, mt.getParameterTypes(), warn); 35.11 + dc.complete(); 35.12 return mt; 35.13 } 35.14 35.15 @@ -1053,7 +1055,8 @@ 35.16 DeferredType dt = (DeferredType) actual; 35.17 DeferredType.SpeculativeCache.Entry e = dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase); 35.18 return (e == null || e.speculativeTree == deferredAttr.stuckTree) 35.19 - ? false : mostSpecific(found, req, e.speculativeTree, warn); 35.20 + ? super.compatible(found, req, warn) : 35.21 + mostSpecific(found, req, e.speculativeTree, warn); 35.22 default: 35.23 return standaloneMostSpecific(found, req, actual, warn); 35.24 } 35.25 @@ -1125,13 +1128,15 @@ 35.26 @Override 35.27 public void visitReference(JCMemberReference tree) { 35.28 if (types.isFunctionalInterface(t.tsym) && 35.29 - types.isFunctionalInterface(s.tsym) && 35.30 - types.asSuper(t, s.tsym) == null && 35.31 - types.asSuper(s, t.tsym) == null) { 35.32 + types.isFunctionalInterface(s.tsym)) { 35.33 Type desc_t = types.findDescriptorType(t); 35.34 Type desc_s = types.findDescriptorType(s); 35.35 - if (types.isSameTypes(desc_t.getParameterTypes(), desc_s.getParameterTypes())) { 35.36 - if (!desc_s.getReturnType().hasTag(VOID)) { 35.37 + if (types.isSameTypes(desc_t.getParameterTypes(), 35.38 + inferenceContext().asFree(desc_s.getParameterTypes()))) { 35.39 + if (types.asSuper(t, s.tsym) != null || 35.40 + types.asSuper(s, t.tsym) != null) { 35.41 + result &= MostSpecificCheckContext.super.compatible(t, s, warn); 35.42 + } else if (!desc_s.getReturnType().hasTag(VOID)) { 35.43 //perform structural comparison 35.44 Type ret_t = desc_t.getReturnType(); 35.45 Type ret_s = desc_s.getReturnType(); 35.46 @@ -1141,25 +1146,24 @@ 35.47 } else { 35.48 return; 35.49 } 35.50 - } else { 35.51 - result &= false; 35.52 } 35.53 } else { 35.54 - result &= MostSpecificCheckContext.super.compatible(t, s, warn); 35.55 + result &= false; 35.56 } 35.57 } 35.58 35.59 @Override 35.60 public void visitLambda(JCLambda tree) { 35.61 if (types.isFunctionalInterface(t.tsym) && 35.62 - types.isFunctionalInterface(s.tsym) && 35.63 - types.asSuper(t, s.tsym) == null && 35.64 - types.asSuper(s, t.tsym) == null) { 35.65 + types.isFunctionalInterface(s.tsym)) { 35.66 Type desc_t = types.findDescriptorType(t); 35.67 Type desc_s = types.findDescriptorType(s); 35.68 - if (tree.paramKind == JCLambda.ParameterKind.EXPLICIT 35.69 - || types.isSameTypes(desc_t.getParameterTypes(), desc_s.getParameterTypes())) { 35.70 - if (!desc_s.getReturnType().hasTag(VOID)) { 35.71 + if (types.isSameTypes(desc_t.getParameterTypes(), 35.72 + inferenceContext().asFree(desc_s.getParameterTypes()))) { 35.73 + if (types.asSuper(t, s.tsym) != null || 35.74 + types.asSuper(s, t.tsym) != null) { 35.75 + result &= MostSpecificCheckContext.super.compatible(t, s, warn); 35.76 + } else if (!desc_s.getReturnType().hasTag(VOID)) { 35.77 //perform structural comparison 35.78 Type ret_t = desc_t.getReturnType(); 35.79 Type ret_s = desc_s.getReturnType(); 35.80 @@ -1167,11 +1171,9 @@ 35.81 } else { 35.82 return; 35.83 } 35.84 - } else { 35.85 - result &= false; 35.86 } 35.87 } else { 35.88 - result &= MostSpecificCheckContext.super.compatible(t, s, warn); 35.89 + result &= false; 35.90 } 35.91 } 35.92 //where 35.93 @@ -1521,7 +1523,8 @@ 35.94 currentResolutionContext = prevResolutionContext; 35.95 } 35.96 } 35.97 - private List<Type> adjustArgs(List<Type> args, Symbol msym, int length, boolean allowVarargs) { 35.98 + 35.99 + List<Type> adjustArgs(List<Type> args, Symbol msym, int length, boolean allowVarargs) { 35.100 if ((msym.flags() & VARARGS) != 0 && allowVarargs) { 35.101 Type varargsElem = types.elemtype(args.last()); 35.102 if (varargsElem == null) { 35.103 @@ -2241,33 +2244,33 @@ 35.104 public List<Type> getArgumentTypes(ResolveError errSym, Symbol accessedSym, Name name, List<Type> argtypes) { 35.105 return (syms.operatorNames.contains(name)) ? 35.106 argtypes : 35.107 - Type.map(argtypes, new ResolveDeferredRecoveryMap(accessedSym)); 35.108 - } 35.109 - 35.110 - class ResolveDeferredRecoveryMap extends DeferredAttr.RecoveryDeferredTypeMap { 35.111 - 35.112 - public ResolveDeferredRecoveryMap(Symbol msym) { 35.113 - deferredAttr.super(AttrMode.SPECULATIVE, msym, currentResolutionContext.step); 35.114 - } 35.115 - 35.116 - @Override 35.117 - protected Type typeOf(DeferredType dt) { 35.118 - Type res = super.typeOf(dt); 35.119 - if (!res.isErroneous()) { 35.120 - switch (TreeInfo.skipParens(dt.tree).getTag()) { 35.121 - case LAMBDA: 35.122 - case REFERENCE: 35.123 - return dt; 35.124 - case CONDEXPR: 35.125 - return res == Type.recoveryType ? 35.126 - dt : res; 35.127 - } 35.128 - } 35.129 - return res; 35.130 - } 35.131 + Type.map(argtypes, new ResolveDeferredRecoveryMap(AttrMode.SPECULATIVE, accessedSym, currentResolutionContext.step)); 35.132 } 35.133 }; 35.134 35.135 + class ResolveDeferredRecoveryMap extends DeferredAttr.RecoveryDeferredTypeMap { 35.136 + 35.137 + public ResolveDeferredRecoveryMap(AttrMode mode, Symbol msym, MethodResolutionPhase step) { 35.138 + deferredAttr.super(mode, msym, step); 35.139 + } 35.140 + 35.141 + @Override 35.142 + protected Type typeOf(DeferredType dt) { 35.143 + Type res = super.typeOf(dt); 35.144 + if (!res.isErroneous()) { 35.145 + switch (TreeInfo.skipParens(dt.tree).getTag()) { 35.146 + case LAMBDA: 35.147 + case REFERENCE: 35.148 + return dt; 35.149 + case CONDEXPR: 35.150 + return res == Type.recoveryType ? 35.151 + dt : res; 35.152 + } 35.153 + } 35.154 + return res; 35.155 + } 35.156 + } 35.157 + 35.158 /** Check that sym is not an abstract method. 35.159 */ 35.160 void checkNonAbstract(DiagnosticPosition pos, Symbol sym) { 35.161 @@ -2543,22 +2546,26 @@ 35.162 @Override 35.163 Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) { 35.164 if (sym.kind >= AMBIGUOUS) { 35.165 - final JCDiagnostic details = sym.kind == WRONG_MTH ? 35.166 - ((InapplicableSymbolError)sym).errCandidate().snd : 35.167 - null; 35.168 - sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) { 35.169 - @Override 35.170 - JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, 35.171 - Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) { 35.172 - String key = details == null ? 35.173 - "cant.apply.diamond" : 35.174 - "cant.apply.diamond.1"; 35.175 - return diags.create(dkind, log.currentSource(), pos, key, 35.176 - diags.fragment("diamond", site.tsym), details); 35.177 - } 35.178 - }; 35.179 - sym = accessMethod(sym, pos, site, names.init, true, argtypes, typeargtypes); 35.180 - env.info.pendingResolutionPhase = currentResolutionContext.step; 35.181 + if (sym.kind != WRONG_MTH && sym.kind != WRONG_MTHS) { 35.182 + sym = super.access(env, pos, location, sym); 35.183 + } else { 35.184 + final JCDiagnostic details = sym.kind == WRONG_MTH ? 35.185 + ((InapplicableSymbolError)sym).errCandidate().snd : 35.186 + null; 35.187 + sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) { 35.188 + @Override 35.189 + JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, 35.190 + Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) { 35.191 + String key = details == null ? 35.192 + "cant.apply.diamond" : 35.193 + "cant.apply.diamond.1"; 35.194 + return diags.create(dkind, log.currentSource(), pos, key, 35.195 + diags.fragment("diamond", site.tsym), details); 35.196 + } 35.197 + }; 35.198 + sym = accessMethod(sym, pos, site, names.init, true, argtypes, typeargtypes); 35.199 + env.info.pendingResolutionPhase = currentResolutionContext.step; 35.200 + } 35.201 } 35.202 return sym; 35.203 }}); 35.204 @@ -3969,16 +3976,6 @@ 35.205 35.206 static { 35.207 String argMismatchRegex = MethodCheckDiag.ARG_MISMATCH.regex(); 35.208 - rewriters.put(new Template(argMismatchRegex, new Template("(.*)(bad.arg.types.in.lambda)", skip, skip)), 35.209 - new DiagnosticRewriter() { 35.210 - @Override 35.211 - public JCDiagnostic rewriteDiagnostic(JCDiagnostic.Factory diags, 35.212 - DiagnosticPosition preferedPos, DiagnosticSource preferredSource, 35.213 - DiagnosticType preferredKind, JCDiagnostic d) { 35.214 - return (JCDiagnostic)((JCDiagnostic)d.getArgs()[0]).getArgs()[1]; 35.215 - } 35.216 - }); 35.217 - 35.218 rewriters.put(new Template(argMismatchRegex, skip), 35.219 new DiagnosticRewriter() { 35.220 @Override
36.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Sep 12 11:09:20 2013 -0700 36.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Sep 17 08:21:11 2013 -0700 36.3 @@ -310,7 +310,7 @@ 36.4 Type.MethodType mType = (Type.MethodType)bridgeType; 36.5 List<Type> argTypes = mType.argtypes; 36.6 while (implParams.nonEmpty() && argTypes.nonEmpty()) { 36.7 - VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC, 36.8 + VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC | PARAMETER, 36.9 implParams.head.name, argTypes.head, bridge); 36.10 param.setAttributes(implParams.head); 36.11 bridgeParams = bridgeParams.append(param); 36.12 @@ -833,7 +833,7 @@ 36.13 } 36.14 36.15 public void visitReference(JCMemberReference tree) { 36.16 - tree.expr = translate(tree.expr, null); 36.17 + tree.expr = translate(tree.expr, erasure(tree.expr.type)); 36.18 tree.type = erasure(tree.type); 36.19 result = tree; 36.20 }
37.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Sep 12 11:09:20 2013 -0700 37.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Sep 17 08:21:11 2013 -0700 37.3 @@ -72,7 +72,7 @@ 37.4 * This code and its internal interfaces are subject to change or 37.5 * deletion without notice.</b> 37.6 */ 37.7 -public class ClassReader implements Completer { 37.8 +public class ClassReader { 37.9 /** The context key for the class reader. */ 37.10 protected static final Context.Key<ClassReader> classReaderKey = 37.11 new Context.Key<ClassReader>(); 37.12 @@ -234,6 +234,17 @@ 37.13 */ 37.14 Set<Name> warnedAttrs = new HashSet<Name>(); 37.15 37.16 + /** 37.17 + * Completer that delegates to the complete-method of this class. 37.18 + */ 37.19 + private final Completer thisCompleter = new Completer() { 37.20 + @Override 37.21 + public void complete(Symbol sym) throws CompletionFailure { 37.22 + ClassReader.this.complete(sym); 37.23 + } 37.24 + }; 37.25 + 37.26 + 37.27 /** Get the ClassReader instance for this invocation. */ 37.28 public static ClassReader instance(Context context) { 37.29 ClassReader instance = context.get(classReaderKey); 37.30 @@ -264,8 +275,8 @@ 37.31 } 37.32 37.33 packages.put(names.empty, syms.rootPackage); 37.34 - syms.rootPackage.completer = this; 37.35 - syms.unnamedPackage.completer = this; 37.36 + syms.rootPackage.completer = thisCompleter; 37.37 + syms.unnamedPackage.completer = thisCompleter; 37.38 } 37.39 37.40 /** Construct a new class reader, optionally treated as the 37.41 @@ -727,12 +738,14 @@ 37.42 ClassSymbol t = enterClass(names.fromUtf(signatureBuffer, 37.43 startSbp, 37.44 sbp - startSbp)); 37.45 - if (outer == Type.noType) 37.46 - outer = t.erasure(types); 37.47 - else 37.48 - outer = new ClassType(outer, List.<Type>nil(), t); 37.49 - sbp = startSbp; 37.50 - return outer; 37.51 + 37.52 + try { 37.53 + return (outer == Type.noType) ? 37.54 + t.erasure(types) : 37.55 + new ClassType(outer, List.<Type>nil(), t); 37.56 + } finally { 37.57 + sbp = startSbp; 37.58 + } 37.59 } 37.60 37.61 case '<': // generic arguments 37.62 @@ -797,6 +810,13 @@ 37.63 continue; 37.64 37.65 case '.': 37.66 + //we have seen an enclosing non-generic class 37.67 + if (outer != Type.noType) { 37.68 + t = enterClass(names.fromUtf(signatureBuffer, 37.69 + startSbp, 37.70 + sbp - startSbp)); 37.71 + outer = new ClassType(outer, List.<Type>nil(), t); 37.72 + } 37.73 signatureBuffer[sbp++] = (byte)'$'; 37.74 continue; 37.75 case '/': 37.76 @@ -2310,7 +2330,7 @@ 37.77 ClassSymbol c = new ClassSymbol(0, name, owner); 37.78 if (owner.kind == PCK) 37.79 Assert.checkNull(classes.get(c.flatname), c); 37.80 - c.completer = this; 37.81 + c.completer = thisCompleter; 37.82 return c; 37.83 } 37.84 37.85 @@ -2380,7 +2400,7 @@ 37.86 /** Completion for classes to be loaded. Before a class is loaded 37.87 * we make sure its enclosing class (if any) is loaded. 37.88 */ 37.89 - public void complete(Symbol sym) throws CompletionFailure { 37.90 + private void complete(Symbol sym) throws CompletionFailure { 37.91 if (sym.kind == TYP) { 37.92 ClassSymbol c = (ClassSymbol)sym; 37.93 c.members_field = new Scope.ErrorScope(c); // make sure it's always defined 37.94 @@ -2601,7 +2621,7 @@ 37.95 p = new PackageSymbol( 37.96 Convert.shortName(fullname), 37.97 enterPackage(Convert.packagePart(fullname))); 37.98 - p.completer = this; 37.99 + p.completer = thisCompleter; 37.100 packages.put(fullname, p); 37.101 } 37.102 return p;
38.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Thu Sep 12 11:09:20 2013 -0700 38.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Sep 17 08:21:11 2013 -0700 38.3 @@ -37,7 +37,6 @@ 38.4 38.5 import com.sun.tools.javac.code.*; 38.6 import com.sun.tools.javac.code.Attribute.RetentionPolicy; 38.7 -import com.sun.tools.javac.code.Attribute.TypeCompound; 38.8 import com.sun.tools.javac.code.Symbol.*; 38.9 import com.sun.tools.javac.code.Type.*; 38.10 import com.sun.tools.javac.code.Types.UniqueType; 38.11 @@ -55,7 +54,6 @@ 38.12 import static com.sun.tools.javac.main.Option.*; 38.13 import static javax.tools.StandardLocation.CLASS_OUTPUT; 38.14 38.15 - 38.16 /** This class provides operations to map an internal symbol table graph 38.17 * rooted in a ClassSymbol into a classfile. 38.18 * 38.19 @@ -1180,25 +1178,26 @@ 38.20 38.21 if (code.varBufferSize > 0) { 38.22 int alenIdx = writeAttr(names.LocalVariableTable); 38.23 - databuf.appendChar(code.varBufferSize); 38.24 - 38.25 + databuf.appendChar(code.getLVTSize()); 38.26 for (int i=0; i<code.varBufferSize; i++) { 38.27 Code.LocalVar var = code.varBuffer[i]; 38.28 38.29 - // write variable info 38.30 - Assert.check(var.start_pc >= 0 38.31 - && var.start_pc <= code.cp); 38.32 - databuf.appendChar(var.start_pc); 38.33 - Assert.check(var.length >= 0 38.34 - && (var.start_pc + var.length) <= code.cp); 38.35 - databuf.appendChar(var.length); 38.36 - VarSymbol sym = var.sym; 38.37 - databuf.appendChar(pool.put(sym.name)); 38.38 - Type vartype = sym.erasure(types); 38.39 - if (needsLocalVariableTypeEntry(sym.type)) 38.40 - nGenericVars++; 38.41 - databuf.appendChar(pool.put(typeSig(vartype))); 38.42 - databuf.appendChar(var.reg); 38.43 + for (Code.LocalVar.Range r: var.aliveRanges) { 38.44 + // write variable info 38.45 + Assert.check(r.start_pc >= 0 38.46 + && r.start_pc <= code.cp); 38.47 + databuf.appendChar(r.start_pc); 38.48 + Assert.check(r.length >= 0 38.49 + && (r.start_pc + r.length) <= code.cp); 38.50 + databuf.appendChar(r.length); 38.51 + VarSymbol sym = var.sym; 38.52 + databuf.appendChar(pool.put(sym.name)); 38.53 + Type vartype = sym.erasure(types); 38.54 + databuf.appendChar(pool.put(typeSig(vartype))); 38.55 + databuf.appendChar(var.reg); 38.56 + if (needsLocalVariableTypeEntry(var.sym.type)) 38.57 + nGenericVars++; 38.58 + } 38.59 } 38.60 endAttr(alenIdx); 38.61 acount++; 38.62 @@ -1214,13 +1213,15 @@ 38.63 VarSymbol sym = var.sym; 38.64 if (!needsLocalVariableTypeEntry(sym.type)) 38.65 continue; 38.66 - count++; 38.67 - // write variable info 38.68 - databuf.appendChar(var.start_pc); 38.69 - databuf.appendChar(var.length); 38.70 - databuf.appendChar(pool.put(sym.name)); 38.71 - databuf.appendChar(pool.put(typeSig(sym.type))); 38.72 - databuf.appendChar(var.reg); 38.73 + for (Code.LocalVar.Range r : var.aliveRanges) { 38.74 + // write variable info 38.75 + databuf.appendChar(r.start_pc); 38.76 + databuf.appendChar(r.length); 38.77 + databuf.appendChar(pool.put(sym.name)); 38.78 + databuf.appendChar(pool.put(typeSig(sym.type))); 38.79 + databuf.appendChar(var.reg); 38.80 + count++; 38.81 + } 38.82 } 38.83 Assert.check(count == nGenericVars); 38.84 endAttr(alenIdx);
39.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Sep 12 11:09:20 2013 -0700 39.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Sep 17 08:21:11 2013 -0700 39.3 @@ -28,6 +28,7 @@ 39.4 import com.sun.tools.javac.code.*; 39.5 import com.sun.tools.javac.code.Symbol.*; 39.6 import com.sun.tools.javac.code.Types.UniqueType; 39.7 +import com.sun.tools.javac.tree.JCTree; 39.8 import com.sun.tools.javac.util.*; 39.9 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 39.10 39.11 @@ -181,6 +182,8 @@ 39.12 39.13 final MethodSymbol meth; 39.14 39.15 + final LVTRanges lvtRanges; 39.16 + 39.17 /** Construct a code object, given the settings of the fatcode, 39.18 * debugging info switches and the CharacterRangeTable. 39.19 */ 39.20 @@ -193,7 +196,8 @@ 39.21 CRTable crt, 39.22 Symtab syms, 39.23 Types types, 39.24 - Pool pool) { 39.25 + Pool pool, 39.26 + LVTRanges lvtRanges) { 39.27 this.meth = meth; 39.28 this.fatcode = fatcode; 39.29 this.lineMap = lineMap; 39.30 @@ -215,6 +219,7 @@ 39.31 state = new State(); 39.32 lvar = new LocalVar[20]; 39.33 this.pool = pool; 39.34 + this.lvtRanges = lvtRanges; 39.35 } 39.36 39.37 39.38 @@ -305,9 +310,19 @@ 39.39 39.40 /** The current output code pointer. 39.41 */ 39.42 - public int curPc() { 39.43 - if (pendingJumps != null) resolvePending(); 39.44 - if (pendingStatPos != Position.NOPOS) markStatBegin(); 39.45 + public int curCP() { 39.46 + /* 39.47 + * This method has side-effects because calling it can indirectly provoke 39.48 + * extra code generation, like goto instructions, depending on the context 39.49 + * where it's called. 39.50 + * Use with care or even better avoid using it. 39.51 + */ 39.52 + if (pendingJumps != null) { 39.53 + resolvePending(); 39.54 + } 39.55 + if (pendingStatPos != Position.NOPOS) { 39.56 + markStatBegin(); 39.57 + } 39.58 fixedPc = true; 39.59 return cp; 39.60 } 39.61 @@ -1175,7 +1190,7 @@ 39.62 /** Declare an entry point; return current code pointer 39.63 */ 39.64 public int entryPoint() { 39.65 - int pc = curPc(); 39.66 + int pc = curCP(); 39.67 alive = true; 39.68 pendingStackMap = needStackMap; 39.69 return pc; 39.70 @@ -1185,7 +1200,7 @@ 39.71 * return current code pointer 39.72 */ 39.73 public int entryPoint(State state) { 39.74 - int pc = curPc(); 39.75 + int pc = curCP(); 39.76 alive = true; 39.77 this.state = state.dup(); 39.78 Assert.check(state.stacksize <= max_stack); 39.79 @@ -1198,7 +1213,7 @@ 39.80 * return current code pointer 39.81 */ 39.82 public int entryPoint(State state, Type pushed) { 39.83 - int pc = curPc(); 39.84 + int pc = curCP(); 39.85 alive = true; 39.86 this.state = state.dup(); 39.87 Assert.check(state.stacksize <= max_stack); 39.88 @@ -1238,7 +1253,7 @@ 39.89 39.90 /** Emit a stack map entry. */ 39.91 public void emitStackMap() { 39.92 - int pc = curPc(); 39.93 + int pc = curCP(); 39.94 if (!needStackMap) return; 39.95 39.96 39.97 @@ -1482,6 +1497,9 @@ 39.98 chain.pc + 3 == target && target == cp && !fixedPc) { 39.99 // If goto the next instruction, the jump is not needed: 39.100 // compact the code. 39.101 + if (varDebugInfo) { 39.102 + adjustAliveRanges(cp, -3); 39.103 + } 39.104 cp = cp - 3; 39.105 target = target - 3; 39.106 if (chain.next == null) { 39.107 @@ -1781,8 +1799,7 @@ 39.108 sym = sym.clone(sym.owner); 39.109 sym.type = newtype; 39.110 LocalVar newlv = lvar[i] = new LocalVar(sym); 39.111 - // should the following be initialized to cp? 39.112 - newlv.start_pc = lv.start_pc; 39.113 + newlv.aliveRanges = lv.aliveRanges; 39.114 } 39.115 } 39.116 } 39.117 @@ -1870,8 +1887,36 @@ 39.118 static class LocalVar { 39.119 final VarSymbol sym; 39.120 final char reg; 39.121 - char start_pc = Character.MAX_VALUE; 39.122 - char length = Character.MAX_VALUE; 39.123 + 39.124 + class Range { 39.125 + char start_pc = Character.MAX_VALUE; 39.126 + char length = Character.MAX_VALUE; 39.127 + 39.128 + Range() {} 39.129 + 39.130 + Range(char start) { 39.131 + this.start_pc = start; 39.132 + } 39.133 + 39.134 + Range(char start, char length) { 39.135 + this.start_pc = start; 39.136 + this.length = length; 39.137 + } 39.138 + 39.139 + boolean closed() { 39.140 + return start_pc != Character.MAX_VALUE && length != Character.MAX_VALUE; 39.141 + } 39.142 + 39.143 + @Override 39.144 + public String toString() { 39.145 + int currentStartPC = start_pc; 39.146 + int currentLength = length; 39.147 + return "startpc = " + currentStartPC + " length " + currentLength; 39.148 + } 39.149 + } 39.150 + 39.151 + java.util.List<Range> aliveRanges = new java.util.ArrayList<>(); 39.152 + 39.153 LocalVar(VarSymbol v) { 39.154 this.sym = v; 39.155 this.reg = (char)v.adr; 39.156 @@ -1879,9 +1924,78 @@ 39.157 public LocalVar dup() { 39.158 return new LocalVar(sym); 39.159 } 39.160 + 39.161 + Range firstRange() { 39.162 + return aliveRanges.isEmpty() ? null : aliveRanges.get(0); 39.163 + } 39.164 + 39.165 + Range lastRange() { 39.166 + return aliveRanges.isEmpty() ? null : aliveRanges.get(aliveRanges.size() - 1); 39.167 + } 39.168 + 39.169 + @Override 39.170 public String toString() { 39.171 - return "" + sym + " in register " + ((int)reg) + " starts at pc=" + ((int)start_pc) + " length=" + ((int)length); 39.172 + if (aliveRanges == null) { 39.173 + return "empty local var"; 39.174 + } 39.175 + StringBuilder sb = new StringBuilder().append(sym) 39.176 + .append(" in register ").append((int)reg).append(" \n"); 39.177 + for (Range r : aliveRanges) { 39.178 + sb.append(" starts at pc=").append(Integer.toString(((int)r.start_pc))) 39.179 + .append(" length=").append(Integer.toString(((int)r.length))) 39.180 + .append("\n"); 39.181 + } 39.182 + return sb.toString(); 39.183 } 39.184 + 39.185 + public void openRange(char start) { 39.186 + if (!hasOpenRange()) { 39.187 + aliveRanges.add(new Range(start)); 39.188 + } 39.189 + } 39.190 + 39.191 + public void closeRange(char end) { 39.192 + if (isLastRangeInitialized()) { 39.193 + Range range = lastRange(); 39.194 + if (range != null) { 39.195 + if (range.length == Character.MAX_VALUE) { 39.196 + range.length = end; 39.197 + } 39.198 + } 39.199 + } else { 39.200 + if (!aliveRanges.isEmpty()) { 39.201 + aliveRanges.remove(aliveRanges.size() - 1); 39.202 + } 39.203 + } 39.204 + } 39.205 + 39.206 + public boolean hasOpenRange() { 39.207 + if (aliveRanges.isEmpty()) { 39.208 + return false; 39.209 + } 39.210 + Range range = lastRange(); 39.211 + return range.length == Character.MAX_VALUE; 39.212 + } 39.213 + 39.214 + public boolean isLastRangeInitialized() { 39.215 + if (aliveRanges.isEmpty()) { 39.216 + return false; 39.217 + } 39.218 + Range range = lastRange(); 39.219 + return range.start_pc != Character.MAX_VALUE; 39.220 + } 39.221 + 39.222 + public Range getWidestRange() { 39.223 + if (aliveRanges.isEmpty()) { 39.224 + return new Range(); 39.225 + } else { 39.226 + Range firstRange = firstRange(); 39.227 + Range lastRange = lastRange(); 39.228 + char length = (char)(lastRange.length + (lastRange.start_pc - firstRange.start_pc)); 39.229 + return new Range(firstRange.start_pc, length); 39.230 + } 39.231 + } 39.232 + 39.233 }; 39.234 39.235 /** Local variables, indexed by register. */ 39.236 @@ -1892,11 +2006,60 @@ 39.237 int adr = v.adr; 39.238 lvar = ArrayUtils.ensureCapacity(lvar, adr+1); 39.239 Assert.checkNull(lvar[adr]); 39.240 - if (pendingJumps != null) resolvePending(); 39.241 + if (pendingJumps != null) { 39.242 + resolvePending(); 39.243 + } 39.244 lvar[adr] = new LocalVar(v); 39.245 state.defined.excl(adr); 39.246 } 39.247 39.248 + 39.249 + public void closeAliveRanges(JCTree tree) { 39.250 + closeAliveRanges(tree, cp); 39.251 + } 39.252 + 39.253 + public void closeAliveRanges(JCTree tree, int closingCP) { 39.254 + List<VarSymbol> locals = lvtRanges.getVars(meth, tree); 39.255 + for (LocalVar localVar: lvar) { 39.256 + for (VarSymbol aliveLocal : locals) { 39.257 + if (localVar == null) { 39.258 + return; 39.259 + } 39.260 + if (localVar.sym == aliveLocal && localVar.lastRange() != null) { 39.261 + char length = (char)(closingCP - localVar.lastRange().start_pc); 39.262 + if (length > 0 && length < Character.MAX_VALUE) { 39.263 + localVar.closeRange(length); 39.264 + } 39.265 + } 39.266 + } 39.267 + } 39.268 + } 39.269 + 39.270 + void adjustAliveRanges(int oldCP, int delta) { 39.271 + for (LocalVar localVar: lvar) { 39.272 + if (localVar == null) { 39.273 + return; 39.274 + } 39.275 + for (LocalVar.Range range: localVar.aliveRanges) { 39.276 + if (range.closed() && range.start_pc + range.length >= oldCP) { 39.277 + range.length += delta; 39.278 + } 39.279 + } 39.280 + } 39.281 + } 39.282 + 39.283 + /** 39.284 + * Calculates the size of the LocalVariableTable. 39.285 + */ 39.286 + public int getLVTSize() { 39.287 + int result = varBufferSize; 39.288 + for (int i = 0; i < varBufferSize; i++) { 39.289 + LocalVar var = varBuffer[i]; 39.290 + result += var.aliveRanges.size() - 1; 39.291 + } 39.292 + return result; 39.293 + } 39.294 + 39.295 /** Set the current variable defined state. */ 39.296 public void setDefined(Bits newDefined) { 39.297 if (alive && newDefined != state.defined) { 39.298 @@ -1922,8 +2085,7 @@ 39.299 } else { 39.300 state.defined.incl(adr); 39.301 if (cp < Character.MAX_VALUE) { 39.302 - if (v.start_pc == Character.MAX_VALUE) 39.303 - v.start_pc = (char)cp; 39.304 + v.openRange((char)cp); 39.305 } 39.306 } 39.307 } 39.308 @@ -1933,15 +2095,15 @@ 39.309 state.defined.excl(adr); 39.310 if (adr < lvar.length && 39.311 lvar[adr] != null && 39.312 - lvar[adr].start_pc != Character.MAX_VALUE) { 39.313 + lvar[adr].isLastRangeInitialized()) { 39.314 LocalVar v = lvar[adr]; 39.315 - char length = (char)(curPc() - v.start_pc); 39.316 + char length = (char)(curCP() - v.lastRange().start_pc); 39.317 if (length > 0 && length < Character.MAX_VALUE) { 39.318 lvar[adr] = v.dup(); 39.319 - v.length = length; 39.320 + v.closeRange(length); 39.321 putVar(v); 39.322 } else { 39.323 - v.start_pc = Character.MAX_VALUE; 39.324 + v.lastRange().start_pc = Character.MAX_VALUE; 39.325 } 39.326 } 39.327 } 39.328 @@ -1951,10 +2113,10 @@ 39.329 LocalVar v = lvar[adr]; 39.330 if (v != null) { 39.331 lvar[adr] = null; 39.332 - if (v.start_pc != Character.MAX_VALUE) { 39.333 - char length = (char)(curPc() - v.start_pc); 39.334 + if (v.isLastRangeInitialized()) { 39.335 + char length = (char)(curCP() - v.lastRange().start_pc); 39.336 if (length < Character.MAX_VALUE) { 39.337 - v.length = length; 39.338 + v.closeRange(length); 39.339 putVar(v); 39.340 fillLocalVarPosition(v); 39.341 } 39.342 @@ -1968,8 +2130,9 @@ 39.343 return; 39.344 for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) { 39.345 TypeAnnotationPosition p = ta.position; 39.346 - p.lvarOffset = new int[] { (int)lv.start_pc }; 39.347 - p.lvarLength = new int[] { (int)lv.length }; 39.348 + LocalVar.Range widestRange = lv.getWidestRange(); 39.349 + p.lvarOffset = new int[] { (int)widestRange.start_pc }; 39.350 + p.lvarLength = new int[] { (int)widestRange.length }; 39.351 p.lvarIndex = new int[] { (int)lv.reg }; 39.352 p.isValidOffset = true; 39.353 }
40.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Sep 12 11:09:20 2013 -0700 40.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Sep 17 08:21:11 2013 -0700 40.3 @@ -24,6 +24,7 @@ 40.4 */ 40.5 40.6 package com.sun.tools.javac.jvm; 40.7 + 40.8 import java.util.*; 40.9 40.10 import com.sun.tools.javac.util.*; 40.11 @@ -95,10 +96,14 @@ 40.12 return instance; 40.13 } 40.14 40.15 - /* Constant pool, reset by genClass. 40.16 + /** Constant pool, reset by genClass. 40.17 */ 40.18 private Pool pool; 40.19 40.20 + /** LVTRanges info. 40.21 + */ 40.22 + private LVTRanges lvtRanges; 40.23 + 40.24 protected Gen(Context context) { 40.25 context.put(genKey, this); 40.26 40.27 @@ -128,6 +133,9 @@ 40.28 options.isUnset(G_CUSTOM) 40.29 ? options.isSet(G) 40.30 : options.isSet(G_CUSTOM, "vars"); 40.31 + if (varDebugInfo) { 40.32 + lvtRanges = LVTRanges.instance(context); 40.33 + } 40.34 genCrt = options.isSet(XJCOV); 40.35 debugCode = options.isSet("debugcode"); 40.36 allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic"); 40.37 @@ -423,7 +431,7 @@ 40.38 */ 40.39 void endFinalizerGap(Env<GenContext> env) { 40.40 if (env.info.gaps != null && env.info.gaps.length() % 2 == 1) 40.41 - env.info.gaps.append(code.curPc()); 40.42 + env.info.gaps.append(code.curCP()); 40.43 } 40.44 40.45 /** Mark end of all gaps in catch-all ranges for finalizers of environments 40.46 @@ -743,10 +751,10 @@ 40.47 genStat(tree, env); 40.48 return; 40.49 } 40.50 - int startpc = code.curPc(); 40.51 + int startpc = code.curCP(); 40.52 genStat(tree, env); 40.53 if (tree.hasTag(Tag.BLOCK)) crtFlags |= CRT_BLOCK; 40.54 - code.crt.put(tree, crtFlags, startpc, code.curPc()); 40.55 + code.crt.put(tree, crtFlags, startpc, code.curCP()); 40.56 } 40.57 40.58 /** Derived visitor method: generate code for a statement. 40.59 @@ -781,9 +789,9 @@ 40.60 if (trees.length() == 1) { // mark one statement with the flags 40.61 genStat(trees.head, env, crtFlags | CRT_STATEMENT); 40.62 } else { 40.63 - int startpc = code.curPc(); 40.64 + int startpc = code.curCP(); 40.65 genStats(trees, env); 40.66 - code.crt.put(trees, crtFlags, startpc, code.curPc()); 40.67 + code.crt.put(trees, crtFlags, startpc, code.curCP()); 40.68 } 40.69 } 40.70 40.71 @@ -806,9 +814,9 @@ 40.72 */ 40.73 public CondItem genCond(JCTree tree, int crtFlags) { 40.74 if (!genCrt) return genCond(tree, false); 40.75 - int startpc = code.curPc(); 40.76 + int startpc = code.curCP(); 40.77 CondItem item = genCond(tree, (crtFlags & CRT_FLOW_CONTROLLER) != 0); 40.78 - code.crt.put(tree, crtFlags, startpc, code.curPc()); 40.79 + code.crt.put(tree, crtFlags, startpc, code.curCP()); 40.80 return item; 40.81 } 40.82 40.83 @@ -971,7 +979,6 @@ 40.84 // definition. 40.85 Env<GenContext> localEnv = env.dup(tree); 40.86 localEnv.enclMethod = tree; 40.87 - 40.88 // The expected type of every return statement in this method 40.89 // is the method's return type. 40.90 this.pt = tree.sym.erasure(types).getReturnType(); 40.91 @@ -1045,7 +1052,7 @@ 40.92 code.crt.put(tree.body, 40.93 CRT_BLOCK, 40.94 startpcCrt, 40.95 - code.curPc()); 40.96 + code.curCP()); 40.97 40.98 code.endScopes(0); 40.99 40.100 @@ -1087,10 +1094,12 @@ 40.101 : null, 40.102 syms, 40.103 types, 40.104 - pool); 40.105 + pool, 40.106 + varDebugInfo ? lvtRanges : null); 40.107 items = new Items(pool, code, syms, types); 40.108 - if (code.debugCode) 40.109 + if (code.debugCode) { 40.110 System.err.println(meth + " for body " + tree); 40.111 + } 40.112 40.113 // If method is not static, create a new local variable address 40.114 // for `this'. 40.115 @@ -1111,7 +1120,7 @@ 40.116 } 40.117 40.118 // Get ready to generate code for method body. 40.119 - int startpcCrt = genCrt ? code.curPc() : 0; 40.120 + int startpcCrt = genCrt ? code.curCP() : 0; 40.121 code.entryPoint(); 40.122 40.123 // Suppress initial stackmap 40.124 @@ -1189,14 +1198,30 @@ 40.125 Chain loopDone = c.jumpFalse(); 40.126 code.resolve(c.trueJumps); 40.127 genStat(body, loopEnv, CRT_STATEMENT | CRT_FLOW_TARGET); 40.128 + if (varDebugInfo) { 40.129 + checkLoopLocalVarRangeEnding(loop, body, 40.130 + LoopLocalVarRangeEndingPoint.BEFORE_STEPS); 40.131 + } 40.132 code.resolve(loopEnv.info.cont); 40.133 genStats(step, loopEnv); 40.134 + if (varDebugInfo) { 40.135 + checkLoopLocalVarRangeEnding(loop, body, 40.136 + LoopLocalVarRangeEndingPoint.AFTER_STEPS); 40.137 + } 40.138 code.resolve(code.branch(goto_), startpc); 40.139 code.resolve(loopDone); 40.140 } else { 40.141 genStat(body, loopEnv, CRT_STATEMENT | CRT_FLOW_TARGET); 40.142 + if (varDebugInfo) { 40.143 + checkLoopLocalVarRangeEnding(loop, body, 40.144 + LoopLocalVarRangeEndingPoint.BEFORE_STEPS); 40.145 + } 40.146 code.resolve(loopEnv.info.cont); 40.147 genStats(step, loopEnv); 40.148 + if (varDebugInfo) { 40.149 + checkLoopLocalVarRangeEnding(loop, body, 40.150 + LoopLocalVarRangeEndingPoint.AFTER_STEPS); 40.151 + } 40.152 CondItem c; 40.153 if (cond != null) { 40.154 code.statBegin(cond.pos); 40.155 @@ -1210,6 +1235,44 @@ 40.156 code.resolve(loopEnv.info.exit); 40.157 } 40.158 40.159 + private enum LoopLocalVarRangeEndingPoint { 40.160 + BEFORE_STEPS, 40.161 + AFTER_STEPS, 40.162 + } 40.163 + 40.164 + /** 40.165 + * Checks whether we have reached an alive range ending point for local 40.166 + * variables after a loop. 40.167 + * 40.168 + * Local variables alive range ending point for loops varies depending 40.169 + * on the loop type. The range can be closed before or after the code 40.170 + * for the steps sentences has been generated. 40.171 + * 40.172 + * - While loops has no steps so in that case the range is closed just 40.173 + * after the body of the loop. 40.174 + * 40.175 + * - For-like loops may have steps so as long as the steps sentences 40.176 + * can possibly contain non-synthetic local variables, the alive range 40.177 + * for local variables must be closed after the steps in this case. 40.178 + */ 40.179 + private void checkLoopLocalVarRangeEnding(JCTree loop, JCTree body, 40.180 + LoopLocalVarRangeEndingPoint endingPoint) { 40.181 + if (varDebugInfo && lvtRanges.containsKey(code.meth, body)) { 40.182 + switch (endingPoint) { 40.183 + case BEFORE_STEPS: 40.184 + if (!loop.hasTag(FORLOOP)) { 40.185 + code.closeAliveRanges(body); 40.186 + } 40.187 + break; 40.188 + case AFTER_STEPS: 40.189 + if (loop.hasTag(FORLOOP)) { 40.190 + code.closeAliveRanges(body); 40.191 + } 40.192 + break; 40.193 + } 40.194 + } 40.195 + } 40.196 + 40.197 public void visitForeachLoop(JCEnhancedForLoop tree) { 40.198 throw new AssertionError(); // should have been removed by Lower. 40.199 } 40.200 @@ -1223,7 +1286,7 @@ 40.201 public void visitSwitch(JCSwitch tree) { 40.202 int limit = code.nextreg; 40.203 Assert.check(!tree.selector.type.hasTag(CLASS)); 40.204 - int startpcCrt = genCrt ? code.curPc() : 0; 40.205 + int startpcCrt = genCrt ? code.curCP() : 0; 40.206 Item sel = genExpr(tree.selector, syms.intType); 40.207 List<JCCase> cases = tree.cases; 40.208 if (cases.isEmpty()) { 40.209 @@ -1231,13 +1294,13 @@ 40.210 sel.load().drop(); 40.211 if (genCrt) 40.212 code.crt.put(TreeInfo.skipParens(tree.selector), 40.213 - CRT_FLOW_CONTROLLER, startpcCrt, code.curPc()); 40.214 + CRT_FLOW_CONTROLLER, startpcCrt, code.curCP()); 40.215 } else { 40.216 // We are seeing a nonempty switch. 40.217 sel.load(); 40.218 if (genCrt) 40.219 code.crt.put(TreeInfo.skipParens(tree.selector), 40.220 - CRT_FLOW_CONTROLLER, startpcCrt, code.curPc()); 40.221 + CRT_FLOW_CONTROLLER, startpcCrt, code.curCP()); 40.222 Env<GenContext> switchEnv = env.dup(tree, new GenContext()); 40.223 switchEnv.info.isSwitch = true; 40.224 40.225 @@ -1278,10 +1341,10 @@ 40.226 ? 40.227 tableswitch : lookupswitch; 40.228 40.229 - int startpc = code.curPc(); // the position of the selector operation 40.230 + int startpc = code.curCP(); // the position of the selector operation 40.231 code.emitop0(opcode); 40.232 code.align(4); 40.233 - int tableBase = code.curPc(); // the start of the jump table 40.234 + int tableBase = code.curCP(); // the start of the jump table 40.235 int[] offsets = null; // a table of offsets for a lookupswitch 40.236 code.emit4(-1); // leave space for default offset 40.237 if (opcode == tableswitch) { 40.238 @@ -1323,6 +1386,9 @@ 40.239 40.240 // Generate code for the statements in this case. 40.241 genStats(c.stats, switchEnv, CRT_FLOW_TARGET); 40.242 + if (varDebugInfo && lvtRanges.containsKey(code.meth, c.stats.last())) { 40.243 + code.closeAliveRanges(c.stats.last()); 40.244 + } 40.245 } 40.246 40.247 // Resolve all breaks. 40.248 @@ -1402,7 +1468,7 @@ 40.249 void gen() { 40.250 genLast(); 40.251 Assert.check(syncEnv.info.gaps.length() % 2 == 0); 40.252 - syncEnv.info.gaps.append(code.curPc()); 40.253 + syncEnv.info.gaps.append(code.curCP()); 40.254 } 40.255 void genLast() { 40.256 if (code.isAlive()) { 40.257 @@ -1441,10 +1507,10 @@ 40.258 jsrState); 40.259 } 40.260 Assert.check(tryEnv.info.gaps.length() % 2 == 0); 40.261 - tryEnv.info.gaps.append(code.curPc()); 40.262 + tryEnv.info.gaps.append(code.curCP()); 40.263 } else { 40.264 Assert.check(tryEnv.info.gaps.length() % 2 == 0); 40.265 - tryEnv.info.gaps.append(code.curPc()); 40.266 + tryEnv.info.gaps.append(code.curCP()); 40.267 genLast(); 40.268 } 40.269 } 40.270 @@ -1467,10 +1533,10 @@ 40.271 */ 40.272 void genTry(JCTree body, List<JCCatch> catchers, Env<GenContext> env) { 40.273 int limit = code.nextreg; 40.274 - int startpc = code.curPc(); 40.275 + int startpc = code.curCP(); 40.276 Code.State stateTry = code.state.dup(); 40.277 genStat(body, env, CRT_BLOCK); 40.278 - int endpc = code.curPc(); 40.279 + int endpc = code.curCP(); 40.280 boolean hasFinalizer = 40.281 env.info.finalize != null && 40.282 env.info.finalize.hasFinalizer(); 40.283 @@ -1478,82 +1544,77 @@ 40.284 code.statBegin(TreeInfo.endPos(body)); 40.285 genFinalizer(env); 40.286 code.statBegin(TreeInfo.endPos(env.tree)); 40.287 - Chain exitChain; 40.288 - if (startpc != endpc) { 40.289 - exitChain = code.branch(goto_); 40.290 - } else { 40.291 - exitChain = code.branch(dontgoto); 40.292 + Chain exitChain = code.branch(goto_); 40.293 + if (varDebugInfo && lvtRanges.containsKey(code.meth, body)) { 40.294 + code.closeAliveRanges(body); 40.295 } 40.296 endFinalizerGap(env); 40.297 - if (startpc != endpc) { 40.298 - for (List<JCCatch> l = catchers; l.nonEmpty(); l = l.tail) { 40.299 - // start off with exception on stack 40.300 - code.entryPoint(stateTry, l.head.param.sym.type); 40.301 - genCatch(l.head, env, startpc, endpc, gaps); 40.302 - genFinalizer(env); 40.303 - if (hasFinalizer || l.tail.nonEmpty()) { 40.304 - code.statBegin(TreeInfo.endPos(env.tree)); 40.305 - exitChain = Code.mergeChains(exitChain, 40.306 - code.branch(goto_)); 40.307 - } 40.308 - endFinalizerGap(env); 40.309 + if (startpc != endpc) for (List<JCCatch> l = catchers; l.nonEmpty(); l = l.tail) { 40.310 + // start off with exception on stack 40.311 + code.entryPoint(stateTry, l.head.param.sym.type); 40.312 + genCatch(l.head, env, startpc, endpc, gaps); 40.313 + genFinalizer(env); 40.314 + if (hasFinalizer || l.tail.nonEmpty()) { 40.315 + code.statBegin(TreeInfo.endPos(env.tree)); 40.316 + exitChain = Code.mergeChains(exitChain, 40.317 + code.branch(goto_)); 40.318 } 40.319 + endFinalizerGap(env); 40.320 + } 40.321 + if (hasFinalizer) { 40.322 + // Create a new register segement to avoid allocating 40.323 + // the same variables in finalizers and other statements. 40.324 + code.newRegSegment(); 40.325 40.326 - if (hasFinalizer) { 40.327 - // Create a new register segement to avoid allocating 40.328 - // the same variables in finalizers and other statements. 40.329 - code.newRegSegment(); 40.330 + // Add a catch-all clause. 40.331 40.332 - // Add a catch-all clause. 40.333 + // start off with exception on stack 40.334 + int catchallpc = code.entryPoint(stateTry, syms.throwableType); 40.335 40.336 - // start off with exception on stack 40.337 - int catchallpc = code.entryPoint(stateTry, syms.throwableType); 40.338 + // Register all exception ranges for catch all clause. 40.339 + // The range of the catch all clause is from the beginning 40.340 + // of the try or synchronized block until the present 40.341 + // code pointer excluding all gaps in the current 40.342 + // environment's GenContext. 40.343 + int startseg = startpc; 40.344 + while (env.info.gaps.nonEmpty()) { 40.345 + int endseg = env.info.gaps.next().intValue(); 40.346 + registerCatch(body.pos(), startseg, endseg, 40.347 + catchallpc, 0); 40.348 + startseg = env.info.gaps.next().intValue(); 40.349 + } 40.350 + code.statBegin(TreeInfo.finalizerPos(env.tree)); 40.351 + code.markStatBegin(); 40.352 40.353 - // Register all exception ranges for catch all clause. 40.354 - // The range of the catch all clause is from the beginning 40.355 - // of the try or synchronized block until the present 40.356 - // code pointer excluding all gaps in the current 40.357 - // environment's GenContext. 40.358 - int startseg = startpc; 40.359 - while (env.info.gaps.nonEmpty()) { 40.360 - int endseg = env.info.gaps.next().intValue(); 40.361 - registerCatch(body.pos(), startseg, endseg, 40.362 - catchallpc, 0); 40.363 - startseg = env.info.gaps.next().intValue(); 40.364 - } 40.365 + Item excVar = makeTemp(syms.throwableType); 40.366 + excVar.store(); 40.367 + genFinalizer(env); 40.368 + excVar.load(); 40.369 + registerCatch(body.pos(), startseg, 40.370 + env.info.gaps.next().intValue(), 40.371 + catchallpc, 0); 40.372 + code.emitop0(athrow); 40.373 + code.markDead(); 40.374 + 40.375 + // If there are jsr's to this finalizer, ... 40.376 + if (env.info.cont != null) { 40.377 + // Resolve all jsr's. 40.378 + code.resolve(env.info.cont); 40.379 + 40.380 + // Mark statement line number 40.381 code.statBegin(TreeInfo.finalizerPos(env.tree)); 40.382 code.markStatBegin(); 40.383 40.384 - Item excVar = makeTemp(syms.throwableType); 40.385 - excVar.store(); 40.386 - genFinalizer(env); 40.387 - excVar.load(); 40.388 - registerCatch(body.pos(), startseg, 40.389 - env.info.gaps.next().intValue(), 40.390 - catchallpc, 0); 40.391 - code.emitop0(athrow); 40.392 + // Save return address. 40.393 + LocalItem retVar = makeTemp(syms.throwableType); 40.394 + retVar.store(); 40.395 + 40.396 + // Generate finalizer code. 40.397 + env.info.finalize.genLast(); 40.398 + 40.399 + // Return. 40.400 + code.emitop1w(ret, retVar.reg); 40.401 code.markDead(); 40.402 - 40.403 - // If there are jsr's to this finalizer, ... 40.404 - if (env.info.cont != null) { 40.405 - // Resolve all jsr's. 40.406 - code.resolve(env.info.cont); 40.407 - 40.408 - // Mark statement line number 40.409 - code.statBegin(TreeInfo.finalizerPos(env.tree)); 40.410 - code.markStatBegin(); 40.411 - 40.412 - // Save return address. 40.413 - LocalItem retVar = makeTemp(syms.throwableType); 40.414 - retVar.store(); 40.415 - 40.416 - // Generate finalizer code. 40.417 - env.info.finalize.genLast(); 40.418 - 40.419 - // Return. 40.420 - code.emitop1w(ret, retVar.reg); 40.421 - code.markDead(); 40.422 - } 40.423 } 40.424 } 40.425 // Resolve all breaks. 40.426 @@ -1581,7 +1642,7 @@ 40.427 int catchType = makeRef(tree.pos(), subCatch.type); 40.428 int end = gaps.head.intValue(); 40.429 registerCatch(tree.pos(), 40.430 - startpc, end, code.curPc(), 40.431 + startpc, end, code.curCP(), 40.432 catchType); 40.433 if (subCatch.type.isAnnotated()) { 40.434 // All compounds share the same position, simply update the 40.435 @@ -1597,7 +1658,7 @@ 40.436 for (JCExpression subCatch : subClauses) { 40.437 int catchType = makeRef(tree.pos(), subCatch.type); 40.438 registerCatch(tree.pos(), 40.439 - startpc, endpc, code.curPc(), 40.440 + startpc, endpc, code.curCP(), 40.441 catchType); 40.442 if (subCatch.type.isAnnotated()) { 40.443 // All compounds share the same position, simply update the 40.444 @@ -1740,11 +1801,19 @@ 40.445 code.resolve(c.trueJumps); 40.446 genStat(tree.thenpart, env, CRT_STATEMENT | CRT_FLOW_TARGET); 40.447 thenExit = code.branch(goto_); 40.448 + if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.thenpart)) { 40.449 + code.closeAliveRanges(tree.thenpart, 40.450 + thenExit != null && tree.elsepart == null ? thenExit.pc : code.cp); 40.451 + } 40.452 } 40.453 if (elseChain != null) { 40.454 code.resolve(elseChain); 40.455 - if (tree.elsepart != null) 40.456 + if (tree.elsepart != null) { 40.457 genStat(tree.elsepart, env,CRT_STATEMENT | CRT_FLOW_TARGET); 40.458 + if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.elsepart)) { 40.459 + code.closeAliveRanges(tree.elsepart); 40.460 + } 40.461 + } 40.462 } 40.463 code.resolve(thenExit); 40.464 code.endScopes(limit); 40.465 @@ -1838,20 +1907,20 @@ 40.466 Chain elseChain = c.jumpFalse(); 40.467 if (!c.isFalse()) { 40.468 code.resolve(c.trueJumps); 40.469 - int startpc = genCrt ? code.curPc() : 0; 40.470 + int startpc = genCrt ? code.curCP() : 0; 40.471 genExpr(tree.truepart, pt).load(); 40.472 code.state.forceStackTop(tree.type); 40.473 if (genCrt) code.crt.put(tree.truepart, CRT_FLOW_TARGET, 40.474 - startpc, code.curPc()); 40.475 + startpc, code.curCP()); 40.476 thenExit = code.branch(goto_); 40.477 } 40.478 if (elseChain != null) { 40.479 code.resolve(elseChain); 40.480 - int startpc = genCrt ? code.curPc() : 0; 40.481 + int startpc = genCrt ? code.curCP() : 0; 40.482 genExpr(tree.falsepart, pt).load(); 40.483 code.state.forceStackTop(tree.type); 40.484 if (genCrt) code.crt.put(tree.falsepart, CRT_FLOW_TARGET, 40.485 - startpc, code.curPc()); 40.486 + startpc, code.curCP()); 40.487 } 40.488 code.resolve(thenExit); 40.489 result = items.makeStackItem(pt); 40.490 @@ -2431,6 +2500,19 @@ 40.491 new Env<GenContext>(cdef, new GenContext()); 40.492 localEnv.toplevel = env.toplevel; 40.493 localEnv.enclClass = cdef; 40.494 + 40.495 + /* We must not analyze synthetic methods 40.496 + */ 40.497 + if (varDebugInfo && (cdef.sym.flags() & SYNTHETIC) == 0) { 40.498 + try { 40.499 + LVTAssignAnalyzer lvtAssignAnalyzer = LVTAssignAnalyzer.make( 40.500 + lvtRanges, syms, names); 40.501 + lvtAssignAnalyzer.analyzeTree(localEnv); 40.502 + } catch (Throwable e) { 40.503 + throw e; 40.504 + } 40.505 + } 40.506 + 40.507 for (List<JCTree> l = cdef.defs; l.nonEmpty(); l = l.tail) { 40.508 genDef(l.head, localEnv); 40.509 } 40.510 @@ -2515,4 +2597,311 @@ 40.511 cont = Code.mergeChains(c, cont); 40.512 } 40.513 } 40.514 + 40.515 + static class LVTAssignAnalyzer 40.516 + extends Flow.AbstractAssignAnalyzer<LVTAssignAnalyzer.LVTAssignPendingExit> { 40.517 + 40.518 + final LVTBits lvtInits; 40.519 + final LVTRanges lvtRanges; 40.520 + 40.521 + /* This class is anchored to a context dependent tree. The tree can 40.522 + * vary inside the same instruction for example in the switch instruction 40.523 + * the same FlowBits instance can be anchored to the whole tree, or 40.524 + * to a given case. The aim is to always anchor the bits to the tree 40.525 + * capable of closing a DA range. 40.526 + */ 40.527 + static class LVTBits extends Bits { 40.528 + 40.529 + enum BitsOpKind { 40.530 + INIT, 40.531 + CLEAR, 40.532 + INCL_BIT, 40.533 + EXCL_BIT, 40.534 + ASSIGN, 40.535 + AND_SET, 40.536 + OR_SET, 40.537 + DIFF_SET, 40.538 + XOR_SET, 40.539 + INCL_RANGE, 40.540 + EXCL_RANGE, 40.541 + } 40.542 + 40.543 + JCTree currentTree; 40.544 + LVTAssignAnalyzer analyzer; 40.545 + private int[] oldBits = null; 40.546 + BitsState stateBeforeOp; 40.547 + 40.548 + LVTBits() { 40.549 + super(false); 40.550 + } 40.551 + 40.552 + LVTBits(int[] bits, BitsState initState) { 40.553 + super(bits, initState); 40.554 + } 40.555 + 40.556 + @Override 40.557 + public void clear() { 40.558 + generalOp(null, -1, BitsOpKind.CLEAR); 40.559 + } 40.560 + 40.561 + @Override 40.562 + protected void internalReset() { 40.563 + super.internalReset(); 40.564 + oldBits = null; 40.565 + } 40.566 + 40.567 + @Override 40.568 + public Bits assign(Bits someBits) { 40.569 + // bits can be null 40.570 + oldBits = bits; 40.571 + stateBeforeOp = currentState; 40.572 + super.assign(someBits); 40.573 + changed(); 40.574 + return this; 40.575 + } 40.576 + 40.577 + @Override 40.578 + public void excludeFrom(int start) { 40.579 + generalOp(null, start, BitsOpKind.EXCL_RANGE); 40.580 + } 40.581 + 40.582 + @Override 40.583 + public void excl(int x) { 40.584 + Assert.check(x >= 0); 40.585 + generalOp(null, x, BitsOpKind.EXCL_BIT); 40.586 + } 40.587 + 40.588 + @Override 40.589 + public Bits andSet(Bits xs) { 40.590 + return generalOp(xs, -1, BitsOpKind.AND_SET); 40.591 + } 40.592 + 40.593 + @Override 40.594 + public Bits orSet(Bits xs) { 40.595 + return generalOp(xs, -1, BitsOpKind.OR_SET); 40.596 + } 40.597 + 40.598 + @Override 40.599 + public Bits diffSet(Bits xs) { 40.600 + return generalOp(xs, -1, BitsOpKind.DIFF_SET); 40.601 + } 40.602 + 40.603 + @Override 40.604 + public Bits xorSet(Bits xs) { 40.605 + return generalOp(xs, -1, BitsOpKind.XOR_SET); 40.606 + } 40.607 + 40.608 + private Bits generalOp(Bits xs, int i, BitsOpKind opKind) { 40.609 + Assert.check(currentState != BitsState.UNKNOWN); 40.610 + oldBits = dupBits(); 40.611 + stateBeforeOp = currentState; 40.612 + switch (opKind) { 40.613 + case AND_SET: 40.614 + super.andSet(xs); 40.615 + break; 40.616 + case OR_SET: 40.617 + super.orSet(xs); 40.618 + break; 40.619 + case XOR_SET: 40.620 + super.xorSet(xs); 40.621 + break; 40.622 + case DIFF_SET: 40.623 + super.diffSet(xs); 40.624 + break; 40.625 + case CLEAR: 40.626 + super.clear(); 40.627 + break; 40.628 + case EXCL_BIT: 40.629 + super.excl(i); 40.630 + break; 40.631 + case EXCL_RANGE: 40.632 + super.excludeFrom(i); 40.633 + break; 40.634 + } 40.635 + changed(); 40.636 + return this; 40.637 + } 40.638 + 40.639 + /* The tree we need to anchor the bits instance to. 40.640 + */ 40.641 + LVTBits at(JCTree tree) { 40.642 + this.currentTree = tree; 40.643 + return this; 40.644 + } 40.645 + 40.646 + /* If the instance should be changed but the tree is not a closing 40.647 + * tree then a reset is needed or the former tree can mistakingly be 40.648 + * used. 40.649 + */ 40.650 + LVTBits resetTree() { 40.651 + this.currentTree = null; 40.652 + return this; 40.653 + } 40.654 + 40.655 + /** This method will be called after any operation that causes a change to 40.656 + * the bits. Subclasses can thus override it in order to extract information 40.657 + * from the changes produced to the bits by the given operation. 40.658 + */ 40.659 + public void changed() { 40.660 + if (currentTree != null && 40.661 + stateBeforeOp != BitsState.UNKNOWN && 40.662 + trackTree(currentTree)) { 40.663 + List<VarSymbol> locals = 40.664 + analyzer.lvtRanges 40.665 + .getVars(analyzer.currentMethod, currentTree); 40.666 + locals = locals != null ? 40.667 + locals : List.<VarSymbol>nil(); 40.668 + for (JCVariableDecl vardecl : analyzer.vardecls) { 40.669 + //once the first is null, the rest will be so. 40.670 + if (vardecl == null) { 40.671 + break; 40.672 + } 40.673 + if (trackVar(vardecl.sym) && bitChanged(vardecl.sym.adr)) { 40.674 + locals = locals.prepend(vardecl.sym); 40.675 + } 40.676 + } 40.677 + if (!locals.isEmpty()) { 40.678 + analyzer.lvtRanges.setEntry(analyzer.currentMethod, 40.679 + currentTree, locals); 40.680 + } 40.681 + } 40.682 + } 40.683 + 40.684 + boolean bitChanged(int x) { 40.685 + boolean isMemberOfBits = isMember(x); 40.686 + int[] tmp = bits; 40.687 + bits = oldBits; 40.688 + boolean isMemberOfOldBits = isMember(x); 40.689 + bits = tmp; 40.690 + return (!isMemberOfBits && isMemberOfOldBits); 40.691 + } 40.692 + 40.693 + boolean trackVar(VarSymbol var) { 40.694 + return (var.owner.kind == MTH && 40.695 + (var.flags() & (PARAMETER | HASINIT)) == 0 && 40.696 + analyzer.trackable(var)); 40.697 + } 40.698 + 40.699 + boolean trackTree(JCTree tree) { 40.700 + switch (tree.getTag()) { 40.701 + // of course a method closes the alive range of a local variable. 40.702 + case METHODDEF: 40.703 + // for while loops we want only the body 40.704 + case WHILELOOP: 40.705 + return false; 40.706 + } 40.707 + return true; 40.708 + } 40.709 + 40.710 + } 40.711 + 40.712 + public class LVTAssignPendingExit extends Flow.AssignAnalyzer.AssignPendingExit { 40.713 + 40.714 + LVTAssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { 40.715 + super(tree, inits, uninits); 40.716 + } 40.717 + 40.718 + @Override 40.719 + public void resolveJump(JCTree tree) { 40.720 + lvtInits.at(tree); 40.721 + super.resolveJump(tree); 40.722 + } 40.723 + } 40.724 + 40.725 + private LVTAssignAnalyzer(LVTRanges lvtRanges, Symtab syms, Names names) { 40.726 + super(new LVTBits(), syms, names); 40.727 + lvtInits = (LVTBits)inits; 40.728 + this.lvtRanges = lvtRanges; 40.729 + } 40.730 + 40.731 + public static LVTAssignAnalyzer make(LVTRanges lvtRanges, Symtab syms, Names names) { 40.732 + LVTAssignAnalyzer result = new LVTAssignAnalyzer(lvtRanges, syms, names); 40.733 + result.lvtInits.analyzer = result; 40.734 + return result; 40.735 + } 40.736 + 40.737 + @Override 40.738 + protected void markDead(JCTree tree) { 40.739 + lvtInits.at(tree).inclRange(returnadr, nextadr); 40.740 + super.markDead(tree); 40.741 + } 40.742 + 40.743 + @Override 40.744 + protected void merge(JCTree tree) { 40.745 + lvtInits.at(tree); 40.746 + super.merge(tree); 40.747 + } 40.748 + 40.749 + boolean isSyntheticOrMandated(Symbol sym) { 40.750 + return (sym.flags() & (SYNTHETIC | MANDATED)) != 0; 40.751 + } 40.752 + 40.753 + @Override 40.754 + protected boolean trackable(VarSymbol sym) { 40.755 + if (isSyntheticOrMandated(sym)) { 40.756 + //fast check to avoid tracking synthetic or mandated variables 40.757 + return false; 40.758 + } 40.759 + return super.trackable(sym); 40.760 + } 40.761 + 40.762 + @Override 40.763 + protected void initParam(JCVariableDecl def) { 40.764 + if (!isSyntheticOrMandated(def.sym)) { 40.765 + super.initParam(def); 40.766 + } 40.767 + } 40.768 + 40.769 + @Override 40.770 + protected void assignToInits(JCTree tree, Bits bits) { 40.771 + lvtInits.at(tree); 40.772 + lvtInits.assign(bits); 40.773 + } 40.774 + 40.775 + @Override 40.776 + protected void andSetInits(JCTree tree, Bits bits) { 40.777 + lvtInits.at(tree); 40.778 + lvtInits.andSet(bits); 40.779 + } 40.780 + 40.781 + @Override 40.782 + protected void orSetInits(JCTree tree, Bits bits) { 40.783 + lvtInits.at(tree); 40.784 + lvtInits.orSet(bits); 40.785 + } 40.786 + 40.787 + @Override 40.788 + protected void exclVarFromInits(JCTree tree, int adr) { 40.789 + lvtInits.at(tree); 40.790 + lvtInits.excl(adr); 40.791 + } 40.792 + 40.793 + @Override 40.794 + protected LVTAssignPendingExit createNewPendingExit(JCTree tree, Bits inits, Bits uninits) { 40.795 + return new LVTAssignPendingExit(tree, inits, uninits); 40.796 + } 40.797 + 40.798 + MethodSymbol currentMethod; 40.799 + 40.800 + @Override 40.801 + public void visitMethodDef(JCMethodDecl tree) { 40.802 + if ((tree.sym.flags() & (SYNTHETIC | GENERATEDCONSTR)) != 0) { 40.803 + return; 40.804 + } 40.805 + if (tree.name.equals(names.clinit)) { 40.806 + return; 40.807 + } 40.808 + boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0; 40.809 + if (enumClass && 40.810 + (tree.name.equals(names.valueOf) || 40.811 + tree.name.equals(names.values) || 40.812 + tree.name.equals(names.init))) { 40.813 + return; 40.814 + } 40.815 + currentMethod = tree.sym; 40.816 + super.visitMethodDef(tree); 40.817 + } 40.818 + 40.819 + } 40.820 + 40.821 }
41.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Items.java Thu Sep 12 11:09:20 2013 -0700 41.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Items.java Tue Sep 17 08:21:11 2013 -0700 41.3 @@ -789,18 +789,18 @@ 41.4 Chain jumpTrue() { 41.5 if (tree == null) return Code.mergeChains(trueJumps, code.branch(opcode)); 41.6 // we should proceed further in -Xjcov mode only 41.7 - int startpc = code.curPc(); 41.8 + int startpc = code.curCP(); 41.9 Chain c = Code.mergeChains(trueJumps, code.branch(opcode)); 41.10 - code.crt.put(tree, CRTable.CRT_BRANCH_TRUE, startpc, code.curPc()); 41.11 + code.crt.put(tree, CRTable.CRT_BRANCH_TRUE, startpc, code.curCP()); 41.12 return c; 41.13 } 41.14 41.15 Chain jumpFalse() { 41.16 if (tree == null) return Code.mergeChains(falseJumps, code.branch(Code.negate(opcode))); 41.17 // we should proceed further in -Xjcov mode only 41.18 - int startpc = code.curPc(); 41.19 + int startpc = code.curCP(); 41.20 Chain c = Code.mergeChains(falseJumps, code.branch(Code.negate(opcode))); 41.21 - code.crt.put(tree, CRTable.CRT_BRANCH_FALSE, startpc, code.curPc()); 41.22 + code.crt.put(tree, CRTable.CRT_BRANCH_FALSE, startpc, code.curCP()); 41.23 return c; 41.24 } 41.25
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 42.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/LVTRanges.java Tue Sep 17 08:21:11 2013 -0700 42.3 @@ -0,0 +1,129 @@ 42.4 +/* 42.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 42.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 42.7 + * 42.8 + * This code is free software; you can redistribute it and/or modify it 42.9 + * under the terms of the GNU General Public License version 2 only, as 42.10 + * published by the Free Software Foundation. Oracle designates this 42.11 + * particular file as subject to the "Classpath" exception as provided 42.12 + * by Oracle in the LICENSE file that accompanied this code. 42.13 + * 42.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 42.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 42.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 42.17 + * version 2 for more details (a copy is included in the LICENSE file that 42.18 + * accompanied this code). 42.19 + * 42.20 + * You should have received a copy of the GNU General Public License version 42.21 + * 2 along with this work; if not, write to the Free Software Foundation, 42.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 42.23 + * 42.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 42.25 + * or visit www.oracle.com if you need additional information or have any 42.26 + * questions. 42.27 + */ 42.28 + 42.29 +package com.sun.tools.javac.jvm; 42.30 + 42.31 +import java.util.Map; 42.32 +import java.util.Map.Entry; 42.33 +import java.util.WeakHashMap; 42.34 + 42.35 +import com.sun.tools.javac.code.Symbol.MethodSymbol; 42.36 +import com.sun.tools.javac.code.Symbol.VarSymbol; 42.37 +import com.sun.tools.javac.tree.JCTree; 42.38 +import com.sun.tools.javac.util.Context; 42.39 +import com.sun.tools.javac.util.List; 42.40 + 42.41 +/** This class contains a one to many relation between a tree and a set of variables. 42.42 + * The relation implies that the given tree closes the DA (definite assignment) 42.43 + * range for the set of variables. 42.44 + * 42.45 + * <p><b>This is NOT part of any supported API. 42.46 + * If you write code that depends on this, you do so at your own risk. 42.47 + * This code and its internal interfaces are subject to change or 42.48 + * deletion without notice.</b> 42.49 + */ 42.50 +public class LVTRanges { 42.51 + /** The context key for the LVT ranges. */ 42.52 + protected static final Context.Key<LVTRanges> lvtRangesKey = new Context.Key<>(); 42.53 + 42.54 + /** Get the LVTRanges instance for this context. */ 42.55 + public static LVTRanges instance(Context context) { 42.56 + LVTRanges instance = context.get(lvtRangesKey); 42.57 + if (instance == null) { 42.58 + instance = new LVTRanges(context); 42.59 + } 42.60 + return instance; 42.61 + } 42.62 + 42.63 + private static final long serialVersionUID = 1812267524140424433L; 42.64 + 42.65 + protected Context context; 42.66 + 42.67 + protected Map<MethodSymbol, Map<JCTree, List<VarSymbol>>> 42.68 + aliveRangeClosingTrees = new WeakHashMap<>(); 42.69 + 42.70 + public LVTRanges(Context context) { 42.71 + this.context = context; 42.72 + context.put(lvtRangesKey, this); 42.73 + } 42.74 + 42.75 + public List<VarSymbol> getVars(MethodSymbol method, JCTree tree) { 42.76 + Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); 42.77 + return (varMap != null) ? varMap.get(tree) : null; 42.78 + } 42.79 + 42.80 + public boolean containsKey(MethodSymbol method, JCTree tree) { 42.81 + Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); 42.82 + if (varMap == null) { 42.83 + return false; 42.84 + } 42.85 + return varMap.containsKey(tree); 42.86 + } 42.87 + 42.88 + public void setEntry(MethodSymbol method, JCTree tree, List<VarSymbol> vars) { 42.89 + Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); 42.90 + if (varMap != null) { 42.91 + varMap.put(tree, vars); 42.92 + } else { 42.93 + varMap = new WeakHashMap<>(); 42.94 + varMap.put(tree, vars); 42.95 + aliveRangeClosingTrees.put(method, varMap); 42.96 + } 42.97 + } 42.98 + 42.99 + public List<VarSymbol> removeEntry(MethodSymbol method, JCTree tree) { 42.100 + Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method); 42.101 + if (varMap != null) { 42.102 + List<VarSymbol> result = varMap.remove(tree); 42.103 + if (varMap.isEmpty()) { 42.104 + aliveRangeClosingTrees.remove(method); 42.105 + } 42.106 + return result; 42.107 + } 42.108 + return null; 42.109 + } 42.110 + 42.111 + /* This method should be used for debugging LVT related issues. 42.112 + */ 42.113 + @Override 42.114 + public String toString() { 42.115 + String result = ""; 42.116 + for (Entry<MethodSymbol, Map<JCTree, List<VarSymbol>>> mainEntry: aliveRangeClosingTrees.entrySet()) { 42.117 + result += "Method: \n" + mainEntry.getKey().flatName() + "\n"; 42.118 + int i = 1; 42.119 + for (Entry<JCTree, List<VarSymbol>> treeEntry: mainEntry.getValue().entrySet()) { 42.120 + result += " Tree " + i + ": \n" + treeEntry.getKey().toString() + "\n"; 42.121 + result += " Variables closed:\n"; 42.122 + for (VarSymbol var: treeEntry.getValue()) { 42.123 + result += " " + var.toString(); 42.124 + } 42.125 + result += "\n"; 42.126 + i++; 42.127 + } 42.128 + } 42.129 + return result; 42.130 + } 42.131 + 42.132 +}
43.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Thu Sep 12 11:09:20 2013 -0700 43.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Tue Sep 17 08:21:11 2013 -0700 43.3 @@ -80,7 +80,7 @@ 43.4 * This code and its internal interfaces are subject to change or 43.5 * deletion without notice.</b> 43.6 */ 43.7 -public class JavaCompiler implements ClassReader.SourceCompleter { 43.8 +public class JavaCompiler { 43.9 /** The context key for the compiler. */ 43.10 protected static final Context.Key<JavaCompiler> compilerKey = 43.11 new Context.Key<JavaCompiler>(); 43.12 @@ -311,6 +311,17 @@ 43.13 protected JavaCompiler delegateCompiler; 43.14 43.15 /** 43.16 + * SourceCompleter that delegates to the complete-method of this class. 43.17 + */ 43.18 + protected final ClassReader.SourceCompleter thisCompleter = 43.19 + new ClassReader.SourceCompleter() { 43.20 + @Override 43.21 + public void complete(ClassSymbol sym) throws CompletionFailure { 43.22 + JavaCompiler.this.complete(sym); 43.23 + } 43.24 + }; 43.25 + 43.26 + /** 43.27 * Command line options. 43.28 */ 43.29 protected Options options; 43.30 @@ -374,7 +385,7 @@ 43.31 types = Types.instance(context); 43.32 taskListener = MultiTaskListener.instance(context); 43.33 43.34 - reader.sourceCompleter = this; 43.35 + reader.sourceCompleter = thisCompleter; 43.36 43.37 options = Options.instance(context); 43.38
44.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Sep 12 11:09:20 2013 -0700 44.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Sep 17 08:21:11 2013 -0700 44.3 @@ -742,11 +742,6 @@ 44.4 compiler.misc.incompatible.arg.types.in.mref=\ 44.5 incompatible parameter types in method reference 44.6 44.7 -# 0: list of type, 1: message segment 44.8 -compiler.misc.bad.arg.types.in.lambda=\ 44.9 - cannot type-check lambda expression with inferred parameter types\n\ 44.10 - inferred types: {0} 44.11 - 44.12 compiler.err.new.not.allowed.in.annotation=\ 44.13 ''new'' not allowed in an annotation 44.14 44.15 @@ -1397,6 +1392,10 @@ 44.16 compiler.warn.missing.SVUID=\ 44.17 serializable class {0} has no definition of serialVersionUID 44.18 44.19 +# 0: symbol, 1: symbol, 2: symbol, 3: symbol 44.20 +compiler.warn.potentially.ambiguous.overload=\ 44.21 + {0} in {1} is potentially ambiguous with {2} in {3} 44.22 + 44.23 # 0: message segment 44.24 compiler.warn.override.varargs.missing=\ 44.25 {0}; overridden method has no ''...'' 44.26 @@ -1916,10 +1915,6 @@ 44.27 inferred: {0}\n\ 44.28 equality constraints(s): {1} 44.29 44.30 -# 0: list of type 44.31 -compiler.misc.cyclic.inference=\ 44.32 - Cannot instantiate inference variables {0} because of an inference loop 44.33 - 44.34 # 0: symbol 44.35 compiler.misc.diamond=\ 44.36 {0}<> 44.37 @@ -1932,6 +1927,10 @@ 44.38 compiler.misc.diamond.and.explicit.params=\ 44.39 cannot use ''<>'' with explicit type parameters for constructor 44.40 44.41 +# 0: unused 44.42 +compiler.misc.mref.infer.and.explicit.params=\ 44.43 + cannot use raw constructor reference with explicit type parameters for constructor 44.44 + 44.45 # 0: type, 1: list of type 44.46 compiler.misc.explicit.param.do.not.conform.to.bounds=\ 44.47 explicit type argument {0} does not conform to declared bound(s) {1}
45.1 --- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java Thu Sep 12 11:09:20 2013 -0700 45.2 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java Tue Sep 17 08:21:11 2013 -0700 45.3 @@ -1596,7 +1596,6 @@ 45.4 public List<JCVariableDecl> params; 45.5 public JCTree body; 45.6 public boolean canCompleteNormally = true; 45.7 - public List<Type> inferredThrownTypes; 45.8 public ParameterKind paramKind; 45.9 45.10 public JCLambda(List<JCVariableDecl> params, 45.11 @@ -1908,6 +1907,7 @@ 45.12 * Selects a member expression. 45.13 */ 45.14 public static class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree { 45.15 + 45.16 public ReferenceMode mode; 45.17 public ReferenceKind kind; 45.18 public Name name; 45.19 @@ -1917,6 +1917,12 @@ 45.20 public Type varargsElement; 45.21 public PolyKind refPolyKind; 45.22 public boolean ownerAccessible; 45.23 + public OverloadKind overloadKind; 45.24 + 45.25 + public enum OverloadKind { 45.26 + OVERLOADED, 45.27 + UNOVERLOADED; 45.28 + } 45.29 45.30 /** 45.31 * Javac-dependent classification for member references, based
46.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Thu Sep 12 11:09:20 2013 -0700 46.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Tue Sep 17 08:21:11 2013 -0700 46.3 @@ -890,7 +890,7 @@ 46.4 /** Create a value parameter tree from its name, type, and owner. 46.5 */ 46.6 public JCVariableDecl Param(Name name, Type argtype, Symbol owner) { 46.7 - return VarDef(new VarSymbol(0, name, argtype, owner), null); 46.8 + return VarDef(new VarSymbol(PARAMETER, name, argtype, owner), null); 46.9 } 46.10 46.11 /** Create a a list of value parameter trees x0, ..., xn from a list of
47.1 --- a/src/share/classes/com/sun/tools/javac/util/Bits.java Thu Sep 12 11:09:20 2013 -0700 47.2 +++ b/src/share/classes/com/sun/tools/javac/util/Bits.java Tue Sep 17 08:21:11 2013 -0700 47.3 @@ -27,8 +27,6 @@ 47.4 47.5 import java.util.Arrays; 47.6 47.7 -import static com.sun.tools.javac.util.Bits.BitsOpKind.*; 47.8 - 47.9 /** A class for extensible, mutable bit sets. 47.10 * 47.11 * <p><b>This is NOT part of any supported API. 47.12 @@ -38,20 +36,6 @@ 47.13 */ 47.14 public class Bits { 47.15 47.16 - public enum BitsOpKind { 47.17 - INIT, 47.18 - CLEAR, 47.19 - INCL_BIT, 47.20 - EXCL_BIT, 47.21 - ASSIGN, 47.22 - AND_SET, 47.23 - OR_SET, 47.24 - DIFF_SET, 47.25 - XOR_SET, 47.26 - INCL_RANGE, 47.27 - EXCL_RANGE, 47.28 - } 47.29 - 47.30 // ____________ reset _________ 47.31 // / UNKNOWN \ <-------- / UNINIT \ 47.32 // \____________/ | \_________/ 47.33 @@ -64,11 +48,14 @@ 47.34 // | | 47.35 // ----------- 47.36 // any 47.37 - private enum BitsState { 47.38 + protected enum BitsState { 47.39 /* A Bits instance is in UNKNOWN state if it has been explicitly reset. 47.40 * It is possible to get to this state from any other by calling the 47.41 * reset method. An instance in the UNKNOWN state can pass to the 47.42 * NORMAL state after being assigned another Bits instance. 47.43 + * 47.44 + * Bits instances are final fields in Flow so the UNKNOWN state models 47.45 + * the null assignment. 47.46 */ 47.47 UNKNOWN, 47.48 /* A Bits instance is in UNINIT when it is created with the default 47.49 @@ -103,13 +90,9 @@ 47.50 47.51 public int[] bits = null; 47.52 // This field will store last version of bits after every change. 47.53 - public int[] oldBits = null; 47.54 - 47.55 - public BitsOpKind lastOperation = null; 47.56 - 47.57 private static final int[] unassignedBits = new int[0]; 47.58 47.59 - private BitsState currentState; 47.60 + protected BitsState currentState; 47.61 47.62 /** Construct an initially empty set. 47.63 */ 47.64 @@ -127,27 +110,20 @@ 47.65 47.66 /** Construct a set consisting initially of given bit vector. 47.67 */ 47.68 - private Bits(int[] bits, BitsState initState) { 47.69 + protected Bits(int[] bits, BitsState initState) { 47.70 this.bits = bits; 47.71 this.currentState = initState; 47.72 switch (initState) { 47.73 case UNKNOWN: 47.74 - reset(); //this will also set current state; 47.75 + this.bits = null; 47.76 break; 47.77 case NORMAL: 47.78 Assert.check(bits != unassignedBits); 47.79 - lastOperation = INIT; 47.80 break; 47.81 } 47.82 } 47.83 47.84 - /** This method will be called after any operation that causes a change to 47.85 - * the bits. Subclasses can thus override it in order to extract information 47.86 - * from the changes produced to the bits by the given operation. 47.87 - */ 47.88 - public void changed() {} 47.89 - 47.90 - private void sizeTo(int len) { 47.91 + protected void sizeTo(int len) { 47.92 if (bits.length < len) { 47.93 bits = Arrays.copyOf(bits, len); 47.94 } 47.95 @@ -157,16 +133,18 @@ 47.96 */ 47.97 public void clear() { 47.98 Assert.check(currentState != BitsState.UNKNOWN); 47.99 - oldBits = bits; 47.100 - lastOperation = CLEAR; 47.101 - for (int i = 0; i < bits.length; i++) bits[i] = 0; 47.102 - changed(); 47.103 + for (int i = 0; i < bits.length; i++) { 47.104 + bits[i] = 0; 47.105 + } 47.106 currentState = BitsState.NORMAL; 47.107 } 47.108 47.109 public void reset() { 47.110 + internalReset(); 47.111 + } 47.112 + 47.113 + protected void internalReset() { 47.114 bits = null; 47.115 - oldBits = null; 47.116 currentState = BitsState.UNKNOWN; 47.117 } 47.118 47.119 @@ -175,40 +153,40 @@ 47.120 } 47.121 47.122 public Bits assign(Bits someBits) { 47.123 - lastOperation = ASSIGN; 47.124 - oldBits = bits; 47.125 bits = someBits.dup().bits; 47.126 - changed(); 47.127 currentState = BitsState.NORMAL; 47.128 return this; 47.129 } 47.130 47.131 /** Return a copy of this set. 47.132 */ 47.133 - private Bits dup() { 47.134 + public Bits dup() { 47.135 Assert.check(currentState != BitsState.UNKNOWN); 47.136 Bits tmp = new Bits(); 47.137 - if (currentState != BitsState.NORMAL) { 47.138 - tmp.bits = bits; 47.139 - } else { 47.140 - tmp.bits = new int[bits.length]; 47.141 - System.arraycopy(bits, 0, tmp.bits, 0, bits.length); 47.142 - } 47.143 + tmp.bits = dupBits(); 47.144 currentState = BitsState.NORMAL; 47.145 return tmp; 47.146 } 47.147 47.148 + protected int[] dupBits() { 47.149 + int [] result; 47.150 + if (currentState != BitsState.NORMAL) { 47.151 + result = bits; 47.152 + } else { 47.153 + result = new int[bits.length]; 47.154 + System.arraycopy(bits, 0, result, 0, bits.length); 47.155 + } 47.156 + return result; 47.157 + } 47.158 + 47.159 /** Include x in this set. 47.160 */ 47.161 public void incl(int x) { 47.162 Assert.check(currentState != BitsState.UNKNOWN); 47.163 - Assert.check(x >= 0); 47.164 - oldBits = bits; 47.165 - lastOperation = INCL_BIT; 47.166 + Assert.check(x >= 0, "Value of x " + x); 47.167 sizeTo((x >>> wordshift) + 1); 47.168 bits[x >>> wordshift] = bits[x >>> wordshift] | 47.169 (1 << (x & wordmask)); 47.170 - changed(); 47.171 currentState = BitsState.NORMAL; 47.172 } 47.173 47.174 @@ -217,14 +195,11 @@ 47.175 */ 47.176 public void inclRange(int start, int limit) { 47.177 Assert.check(currentState != BitsState.UNKNOWN); 47.178 - oldBits = bits; 47.179 - lastOperation = INCL_RANGE; 47.180 sizeTo((limit >>> wordshift) + 1); 47.181 for (int x = start; x < limit; x++) { 47.182 bits[x >>> wordshift] = bits[x >>> wordshift] | 47.183 (1 << (x & wordmask)); 47.184 } 47.185 - changed(); 47.186 currentState = BitsState.NORMAL; 47.187 } 47.188 47.189 @@ -232,13 +207,10 @@ 47.190 */ 47.191 public void excludeFrom(int start) { 47.192 Assert.check(currentState != BitsState.UNKNOWN); 47.193 - oldBits = bits; 47.194 - lastOperation = EXCL_RANGE; 47.195 Bits temp = new Bits(); 47.196 temp.sizeTo(bits.length); 47.197 temp.inclRange(0, start); 47.198 internalAndSet(temp); 47.199 - changed(); 47.200 currentState = BitsState.NORMAL; 47.201 } 47.202 47.203 @@ -247,12 +219,9 @@ 47.204 public void excl(int x) { 47.205 Assert.check(currentState != BitsState.UNKNOWN); 47.206 Assert.check(x >= 0); 47.207 - oldBits = bits; 47.208 - lastOperation = EXCL_BIT; 47.209 sizeTo((x >>> wordshift) + 1); 47.210 bits[x >>> wordshift] = bits[x >>> wordshift] & 47.211 ~(1 << (x & wordmask)); 47.212 - changed(); 47.213 currentState = BitsState.NORMAL; 47.214 } 47.215 47.216 @@ -269,15 +238,12 @@ 47.217 */ 47.218 public Bits andSet(Bits xs) { 47.219 Assert.check(currentState != BitsState.UNKNOWN); 47.220 - oldBits = bits; 47.221 - lastOperation = AND_SET; 47.222 internalAndSet(xs); 47.223 - changed(); 47.224 currentState = BitsState.NORMAL; 47.225 return this; 47.226 } 47.227 47.228 - private void internalAndSet(Bits xs) { 47.229 + protected void internalAndSet(Bits xs) { 47.230 Assert.check(currentState != BitsState.UNKNOWN); 47.231 sizeTo(xs.bits.length); 47.232 for (int i = 0; i < xs.bits.length; i++) { 47.233 @@ -289,13 +255,10 @@ 47.234 */ 47.235 public Bits orSet(Bits xs) { 47.236 Assert.check(currentState != BitsState.UNKNOWN); 47.237 - oldBits = bits; 47.238 - lastOperation = OR_SET; 47.239 sizeTo(xs.bits.length); 47.240 for (int i = 0; i < xs.bits.length; i++) { 47.241 bits[i] = bits[i] | xs.bits[i]; 47.242 } 47.243 - changed(); 47.244 currentState = BitsState.NORMAL; 47.245 return this; 47.246 } 47.247 @@ -304,14 +267,11 @@ 47.248 */ 47.249 public Bits diffSet(Bits xs) { 47.250 Assert.check(currentState != BitsState.UNKNOWN); 47.251 - oldBits = bits; 47.252 - lastOperation = DIFF_SET; 47.253 for (int i = 0; i < bits.length; i++) { 47.254 if (i < xs.bits.length) { 47.255 bits[i] = bits[i] & ~xs.bits[i]; 47.256 } 47.257 } 47.258 - changed(); 47.259 currentState = BitsState.NORMAL; 47.260 return this; 47.261 } 47.262 @@ -320,13 +280,10 @@ 47.263 */ 47.264 public Bits xorSet(Bits xs) { 47.265 Assert.check(currentState != BitsState.UNKNOWN); 47.266 - oldBits = bits; 47.267 - lastOperation = XOR_SET; 47.268 sizeTo(xs.bits.length); 47.269 for (int i = 0; i < xs.bits.length; i++) { 47.270 bits[i] = bits[i] ^ xs.bits[i]; 47.271 } 47.272 - changed(); 47.273 currentState = BitsState.NORMAL; 47.274 return this; 47.275 } 47.276 @@ -336,7 +293,9 @@ 47.277 */ 47.278 private static int trailingZeroBits(int x) { 47.279 Assert.check(wordlen == 32); 47.280 - if (x == 0) return 32; 47.281 + if (x == 0) { 47.282 + return 32; 47.283 + } 47.284 int n = 1; 47.285 if ((x & 0xffff) == 0) { n += 16; x >>>= 16; } 47.286 if ((x & 0x00ff) == 0) { n += 8; x >>>= 8; } 47.287 @@ -355,24 +314,31 @@ 47.288 public int nextBit(int x) { 47.289 Assert.check(currentState != BitsState.UNKNOWN); 47.290 int windex = x >>> wordshift; 47.291 - if (windex >= bits.length) return -1; 47.292 + if (windex >= bits.length) { 47.293 + return -1; 47.294 + } 47.295 int word = bits[windex] & ~((1 << (x & wordmask))-1); 47.296 while (true) { 47.297 - if (word != 0) 47.298 + if (word != 0) { 47.299 return (windex << wordshift) + trailingZeroBits(word); 47.300 + } 47.301 windex++; 47.302 - if (windex >= bits.length) return -1; 47.303 + if (windex >= bits.length) { 47.304 + return -1; 47.305 + } 47.306 word = bits[windex]; 47.307 } 47.308 } 47.309 47.310 /** a string representation of this set. 47.311 */ 47.312 + @Override 47.313 public String toString() { 47.314 - if (bits.length > 0) { 47.315 + if (bits != null && bits.length > 0) { 47.316 char[] digits = new char[bits.length * wordlen]; 47.317 - for (int i = 0; i < bits.length * wordlen; i++) 47.318 + for (int i = 0; i < bits.length * wordlen; i++) { 47.319 digits[i] = isMember(i) ? '1' : '0'; 47.320 + } 47.321 return new String(digits); 47.322 } else { 47.323 return "[]"; 47.324 @@ -396,6 +362,8 @@ 47.325 System.out.println("found " + i); 47.326 count ++; 47.327 } 47.328 - if (count != 125) throw new Error(); 47.329 + if (count != 125) { 47.330 + throw new Error(); 47.331 + } 47.332 } 47.333 }
48.1 --- a/src/share/classes/com/sun/tools/javac/util/GraphUtils.java Thu Sep 12 11:09:20 2013 -0700 48.2 +++ b/src/share/classes/com/sun/tools/javac/util/GraphUtils.java Tue Sep 17 08:21:11 2013 -0700 48.3 @@ -33,6 +33,18 @@ 48.4 public class GraphUtils { 48.5 48.6 /** 48.7 + * Basic interface for defining various dependency kinds. All dependency kinds 48.8 + * must at least support basic capabilities to tell the DOT engine how to render them. 48.9 + */ 48.10 + public interface DependencyKind { 48.11 + /** 48.12 + * Returns the DOT representation (to be used in a {@code style} attribute 48.13 + * that's most suited for this dependency kind. 48.14 + */ 48.15 + String getDotStyle(); 48.16 + } 48.17 + 48.18 + /** 48.19 * This class is a basic abstract class for representing a node. 48.20 * A node is associated with a given data. 48.21 */ 48.22 @@ -43,9 +55,20 @@ 48.23 this.data = data; 48.24 } 48.25 48.26 - public abstract Iterable<? extends Node<D>> getDependencies(); 48.27 + /** 48.28 + * Get an array of the dependency kinds supported by this node. 48.29 + */ 48.30 + public abstract DependencyKind[] getSupportedDependencyKinds(); 48.31 48.32 - public abstract String printDependency(Node<D> to); 48.33 + /** 48.34 + * Get all dependencies, regardless of their kind. 48.35 + */ 48.36 + public abstract Iterable<? extends Node<D>> getAllDependencies(); 48.37 + 48.38 + /** 48.39 + * Get a name for the dependency (of given kind) linking this node to a given node 48.40 + */ 48.41 + public abstract String getDependencyName(Node<D> to, DependencyKind dk); 48.42 48.43 @Override 48.44 public String toString() { 48.45 @@ -66,7 +89,9 @@ 48.46 super(data); 48.47 } 48.48 48.49 - public abstract Iterable<? extends TarjanNode<D>> getDependencies(); 48.50 + public abstract Iterable<? extends TarjanNode<D>> getAllDependencies(); 48.51 + 48.52 + public abstract Iterable<? extends TarjanNode<D>> getDependenciesByKind(DependencyKind dk); 48.53 48.54 public int compareTo(TarjanNode<D> o) { 48.55 return (index < o.index) ? -1 : (index == o.index) ? 0 : 1; 48.56 @@ -95,7 +120,7 @@ 48.57 index++; 48.58 stack.prepend(v); 48.59 v.active = true; 48.60 - for (TarjanNode<D> nd: v.getDependencies()) { 48.61 + for (TarjanNode<D> nd: v.getAllDependencies()) { 48.62 @SuppressWarnings("unchecked") 48.63 N n = (N)nd; 48.64 if (n.index == -1) { 48.65 @@ -134,9 +159,11 @@ 48.66 } 48.67 //dump arcs 48.68 for (TarjanNode<D> from : nodes) { 48.69 - for (TarjanNode<D> to : from.getDependencies()) { 48.70 - buf.append(String.format("%s -> %s [label = \" %s \"];\n", 48.71 - from.hashCode(), to.hashCode(), from.printDependency(to))); 48.72 + for (DependencyKind dk : from.getSupportedDependencyKinds()) { 48.73 + for (TarjanNode<D> to : from.getDependenciesByKind(dk)) { 48.74 + buf.append(String.format("%s -> %s [label = \" %s \" style = %s ];\n", 48.75 + from.hashCode(), to.hashCode(), from.getDependencyName(to, dk), dk.getDotStyle())); 48.76 + } 48.77 } 48.78 } 48.79 buf.append("}\n");
49.1 --- a/src/share/classes/com/sun/tools/javac/util/List.java Thu Sep 12 11:09:20 2013 -0700 49.2 +++ b/src/share/classes/com/sun/tools/javac/util/List.java Tue Sep 17 08:21:11 2013 -0700 49.3 @@ -116,6 +116,19 @@ 49.4 return buf.toList(); 49.5 } 49.6 49.7 + /** 49.8 + * Create a new list from the first {@code n} elements of this list 49.9 + */ 49.10 + public List<A> take(int n) { 49.11 + ListBuffer<A> buf = ListBuffer.lb(); 49.12 + int count = 0; 49.13 + for (A el : this) { 49.14 + if (count++ == n) break; 49.15 + buf.append(el); 49.16 + } 49.17 + return buf.toList(); 49.18 + } 49.19 + 49.20 /** Construct a list consisting of given element. 49.21 */ 49.22 public static <A> List<A> of(A x1) {
50.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotatedTypeImpl.java Thu Sep 12 11:09:20 2013 -0700 50.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotatedTypeImpl.java Tue Sep 17 08:21:11 2013 -0700 50.3 @@ -40,7 +40,7 @@ 50.4 public class AnnotatedTypeImpl 50.5 extends AbstractTypeImpl implements AnnotatedType { 50.6 50.7 - AnnotatedTypeImpl(DocEnv env, com.sun.tools.javac.code.Type.AnnotatedType type) { 50.8 + AnnotatedTypeImpl(DocEnv env, com.sun.tools.javac.code.Type type) { 50.9 super(env, type); 50.10 } 50.11 50.12 @@ -50,7 +50,7 @@ 50.13 */ 50.14 @Override 50.15 public AnnotationDesc[] annotations() { 50.16 - List<TypeCompound> tas = ((com.sun.tools.javac.code.Type.AnnotatedType)type).typeAnnotations; 50.17 + List<? extends TypeCompound> tas = type.getAnnotationMirrors(); 50.18 if (tas == null || 50.19 tas.isEmpty()) { 50.20 return new AnnotationDesc[0]; 50.21 @@ -65,7 +65,7 @@ 50.22 50.23 @Override 50.24 public com.sun.javadoc.Type underlyingType() { 50.25 - return TypeMaker.getType(env, ((com.sun.tools.javac.code.Type.AnnotatedType)type).underlyingType, true, false); 50.26 + return TypeMaker.getType(env, type.unannotatedType(), true, false); 50.27 } 50.28 50.29 @Override
51.1 --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Thu Sep 12 11:09:20 2013 -0700 51.2 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Tue Sep 17 08:21:11 2013 -0700 51.3 @@ -289,7 +289,7 @@ 51.4 } 51.5 51.6 public boolean isFunctionalInterface() { 51.7 - return env.types.isFunctionalInterface(tsym); 51.8 + return env.types.isFunctionalInterface(tsym) && env.source.allowLambda(); 51.9 } 51.10 51.11 /**
52.1 --- a/src/share/classes/com/sun/tools/javadoc/DocEnv.java Thu Sep 12 11:09:20 2013 -0700 52.2 +++ b/src/share/classes/com/sun/tools/javadoc/DocEnv.java Tue Sep 17 08:21:11 2013 -0700 52.3 @@ -124,6 +124,11 @@ 52.4 private boolean silent = false; 52.5 52.6 /** 52.7 + * The source language version. 52.8 + */ 52.9 + protected Source source; 52.10 + 52.11 + /** 52.12 * Constructor 52.13 * 52.14 * @param context Context for this javadoc instance. 52.15 @@ -144,6 +149,7 @@ 52.16 52.17 // Default. Should normally be reset with setLocale. 52.18 this.doclocale = new DocLocale(this, "", breakiterator); 52.19 + source = Source.instance(context); 52.20 } 52.21 52.22 public void setSilent(boolean silent) {
53.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Thu Sep 12 11:09:20 2013 -0700 53.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Tue Sep 17 08:21:11 2013 -0700 53.3 @@ -1,5 +1,5 @@ 53.4 /* 53.5 - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 53.6 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 53.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 53.8 * 53.9 * This code is free software; you can redistribute it and/or modify it 53.10 @@ -134,7 +134,7 @@ 53.11 docenv.setEncoding(encoding); 53.12 docenv.docClasses = docClasses; 53.13 docenv.legacyDoclet = legacyDoclet; 53.14 - javadocReader.sourceCompleter = docClasses ? null : this; 53.15 + javadocReader.sourceCompleter = docClasses ? null : thisCompleter; 53.16 53.17 ListBuffer<String> names = new ListBuffer<String>(); 53.18 ListBuffer<JCCompilationUnit> classTrees = new ListBuffer<JCCompilationUnit>();
54.1 --- a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Thu Sep 12 11:09:20 2013 -0700 54.2 +++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Tue Sep 17 08:21:11 2013 -0700 54.3 @@ -63,10 +63,8 @@ 54.4 t = env.types.erasure(t); 54.5 } 54.6 54.7 - if (considerAnnotations && 54.8 - t.isAnnotated()) { 54.9 - Type.AnnotatedType at = (Type.AnnotatedType) t; 54.10 - return new AnnotatedTypeImpl(env, at); 54.11 + if (considerAnnotations && t.isAnnotated()) { 54.12 + return new AnnotatedTypeImpl(env, t); 54.13 } 54.14 54.15 switch (t.getTag()) { 54.16 @@ -143,8 +141,7 @@ 54.17 static String getTypeString(DocEnv env, Type t, boolean full) { 54.18 // TODO: should annotations be included here? 54.19 if (t.isAnnotated()) { 54.20 - Type.AnnotatedType at = (Type.AnnotatedType)t; 54.21 - t = at.underlyingType; 54.22 + t = t.unannotatedType(); 54.23 } 54.24 switch (t.getTag()) { 54.25 case ARRAY:
55.1 --- a/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java Thu Sep 12 11:09:20 2013 -0700 55.2 +++ b/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java Tue Sep 17 08:21:11 2013 -0700 55.3 @@ -140,7 +140,7 @@ 55.4 if (!type.isAnnotated()) { 55.5 return new AnnotationDesc[0]; 55.6 } 55.7 - List<TypeCompound> tas = ((com.sun.tools.javac.code.Type.AnnotatedType) type).typeAnnotations; 55.8 + List<? extends TypeCompound> tas = type.getAnnotationMirrors(); 55.9 AnnotationDesc res[] = new AnnotationDesc[tas.length()]; 55.10 int i = 0; 55.11 for (Attribute.Compound a : tas) {
56.1 --- a/test/com/sun/javadoc/AccessSkipNav/AccessSkipNav.java Thu Sep 12 11:09:20 2013 -0700 56.2 +++ b/test/com/sun/javadoc/AccessSkipNav/AccessSkipNav.java Tue Sep 17 08:21:11 2013 -0700 56.3 @@ -1,5 +1,5 @@ 56.4 /* 56.5 - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 56.6 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. 56.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 56.8 * 56.9 * This code is free software; you can redistribute it and/or modify it 56.10 @@ -23,7 +23,7 @@ 56.11 56.12 /* 56.13 * @test 56.14 - * @bug 4638136 56.15 + * @bug 4638136 7198273 56.16 * @summary Add ability to skip over nav bar for accessibility 56.17 * @author dkramer 56.18 * @run main AccessSkipNav 56.19 @@ -42,7 +42,7 @@ 56.20 */ 56.21 public class AccessSkipNav { 56.22 56.23 - private static final String BUGID = "4638136"; 56.24 + private static final String BUGID = "4638136 - 7198273"; 56.25 private static final String BUGNAME = "AccessSkipNav"; 56.26 private static final String FS = System.getProperty("file.separator"); 56.27 private static final String PS = System.getProperty("path.separator"); 56.28 @@ -86,7 +86,7 @@ 56.29 // Testing only for the presence of the <a href> and <a name> 56.30 56.31 // Top navbar <a href> 56.32 - { "<a href=\"#skip-navbar_top\" title=\"Skip navigation links\"></a>", 56.33 + { "<a href=\"#skip-navbar_top\" title=\"Skip navigation links\">Skip navigation links</a>", 56.34 TMPDEST_DIR1 + "p1" + FS + "C1.html" }, 56.35 56.36 // Top navbar <a name> 56.37 @@ -95,7 +95,7 @@ 56.38 TMPDEST_DIR1 + "p1" + FS + "C1.html" }, 56.39 56.40 // Bottom navbar <a href> 56.41 - { "<a href=\"#skip-navbar_bottom\" title=\"Skip navigation links\"></a>", 56.42 + { "<a href=\"#skip-navbar_bottom\" title=\"Skip navigation links\">Skip navigation links</a>", 56.43 TMPDEST_DIR1 + "p1" + FS + "C1.html" }, 56.44 56.45 // Bottom navbar <a name>
57.1 --- a/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java Thu Sep 12 11:09:20 2013 -0700 57.2 +++ b/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java Tue Sep 17 08:21:11 2013 -0700 57.3 @@ -1,5 +1,5 @@ 57.4 /* 57.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 57.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 57.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 57.8 * 57.9 * This code is free software; you can redistribute it and/or modify it 57.10 @@ -23,7 +23,7 @@ 57.11 57.12 /* 57.13 * @test 57.14 - * @bug 8000418 57.15 + * @bug 8000418 8024288 57.16 * @summary Verify that files use a common Generated By string 57.17 * @library ../lib/ 57.18 * @build JavadocTester TestGeneratedBy 57.19 @@ -50,32 +50,44 @@ 57.20 "index.html" 57.21 }; 57.22 57.23 - private static final String[] ARGS = 57.24 + private static final String[] STD_ARGS = 57.25 new String[] { 57.26 "-d", OUTPUT_DIR, 57.27 "-sourcepath", SRC_DIR, 57.28 "pkg" 57.29 }; 57.30 - private static final String BUG_ID = "8000418"; 57.31 57.32 - private static String[][] getTests() { 57.33 + private static final String[] NO_TIMESTAMP_ARGS = 57.34 + new String[] { 57.35 + "-notimestamp", 57.36 + "-d", OUTPUT_DIR, 57.37 + "-sourcepath", SRC_DIR, 57.38 + "pkg" 57.39 + }; 57.40 + 57.41 + private static final String BUG_ID = "8000418-8024288"; 57.42 + 57.43 + private static String[][] getTests(boolean timestamp) { 57.44 String version = System.getProperty("java.version"); 57.45 String[][] tests = new String[FILES.length][]; 57.46 for (int i = 0; i < FILES.length; i++) { 57.47 + String genBy = "Generated by javadoc"; 57.48 + if (timestamp) genBy += " (" + version + ") on "; 57.49 tests[i] = new String[] { 57.50 - OUTPUT_DIR + FS + FILES[i], 57.51 - "Generated by javadoc (" + version + ") on " 57.52 + OUTPUT_DIR + FS + FILES[i], genBy 57.53 }; 57.54 } 57.55 return tests; 57.56 } 57.57 57.58 - private static String[][] getNegatedTests() { 57.59 + private static String[][] getNegatedTests(boolean timestamp) { 57.60 String[][] tests = new String[FILES.length][]; 57.61 for (int i = 0; i < FILES.length; i++) { 57.62 tests[i] = new String[] { 57.63 OUTPUT_DIR + FS + FILES[i], 57.64 - "Generated by javadoc (version", 57.65 + (timestamp 57.66 + ? "Generated by javadoc (version" 57.67 + : "Generated by javadoc ("), 57.68 "Generated by javadoc on" 57.69 }; 57.70 } 57.71 @@ -88,9 +100,10 @@ 57.72 */ 57.73 public static void main(String[] args) { 57.74 TestGeneratedBy tester = new TestGeneratedBy(); 57.75 - int exitCode = run(tester, ARGS, getTests(), getNegatedTests()); 57.76 + int ec1 = run(tester, STD_ARGS, getTests(true), getNegatedTests(true)); 57.77 + int ec2 = run(tester, NO_TIMESTAMP_ARGS, getTests(false), getNegatedTests(false)); 57.78 tester.printSummary(); 57.79 - if (exitCode != 0) { 57.80 + if (ec1 != 0 || ec2 != 0) { 57.81 throw new Error("Error found while executing Javadoc"); 57.82 } 57.83 }
58.1 --- a/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java Thu Sep 12 11:09:20 2013 -0700 58.2 +++ b/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java Tue Sep 17 08:21:11 2013 -0700 58.3 @@ -1,5 +1,5 @@ 58.4 /* 58.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 58.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 58.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 58.8 * 58.9 * This code is free software; you can redistribute it and/or modify it 58.10 @@ -23,7 +23,7 @@ 58.11 58.12 /* 58.13 * @test 58.14 - * @bug 8004893 58.15 + * @bug 8004893 8022738 58.16 * @summary Make sure that the lambda feature changes work fine in 58.17 * javadoc. 58.18 * @author bpatel 58.19 @@ -35,11 +35,15 @@ 58.20 public class TestLambdaFeature extends JavadocTester { 58.21 58.22 //Test information. 58.23 - private static final String BUG_ID = "8004893"; 58.24 + private static final String BUG_ID = "8004893-8022738"; 58.25 58.26 //Javadoc arguments. 58.27 private static final String[] ARGS = new String[] { 58.28 - "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg" 58.29 + "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg", "pkg1" 58.30 + }; 58.31 + 58.32 + private static final String[] ARGS_1 = new String[] { 58.33 + "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR, "-source", "1.5", "pkg1" 58.34 }; 58.35 58.36 //Input for string search tests. 58.37 @@ -63,6 +67,11 @@ 58.38 "<dl>" + NL + "<dt>Functional Interface:</dt>" + NL + 58.39 "<dd>This is a functional interface and can therefore be used as " + 58.40 "the assignment target for a lambda expression or method " + 58.41 + "reference.</dd>" + NL + "</dl>"}, 58.42 + {BUG_ID + FS + "pkg1" + FS + "FuncInf.html", 58.43 + "<dl>" + NL + "<dt>Functional Interface:</dt>" + NL + 58.44 + "<dd>This is a functional interface and can therefore be used as " + 58.45 + "the assignment target for a lambda expression or method " + 58.46 "reference.</dd>" + NL + "</dl>"} 58.47 }; 58.48 private static final String[][] NEGATED_TEST = { 58.49 @@ -75,6 +84,10 @@ 58.50 {BUG_ID + FS + "pkg" + FS + "B.html", 58.51 "<dl>" + NL + "<dt>Functional Interface:</dt>"} 58.52 }; 58.53 + private static final String[][] NEGATED_TEST_1 = { 58.54 + {BUG_ID + "-2" + FS + "pkg1" + FS + "FuncInf.html", 58.55 + "<dl>" + NL + "<dt>Functional Interface:</dt>"} 58.56 + }; 58.57 58.58 /** 58.59 * The entry point of the test. 58.60 @@ -83,6 +96,7 @@ 58.61 public static void main(String[] args) { 58.62 TestLambdaFeature tester = new TestLambdaFeature(); 58.63 run(tester, ARGS, TEST, NEGATED_TEST); 58.64 + run(tester, ARGS_1, NO_TEST, NEGATED_TEST_1); 58.65 tester.printSummary(); 58.66 } 58.67
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 59.2 +++ b/test/com/sun/javadoc/testLambdaFeature/pkg1/FuncInf.java Tue Sep 17 08:21:11 2013 -0700 59.3 @@ -0,0 +1,29 @@ 59.4 +/* 59.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 59.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 59.7 + * 59.8 + * This code is free software; you can redistribute it and/or modify it 59.9 + * under the terms of the GNU General Public License version 2 only, as 59.10 + * published by the Free Software Foundation. 59.11 + * 59.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 59.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 59.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 59.15 + * version 2 for more details (a copy is included in the LICENSE file that 59.16 + * accompanied this code). 59.17 + * 59.18 + * You should have received a copy of the GNU General Public License version 59.19 + * 2 along with this work; if not, write to the Free Software Foundation, 59.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 59.21 + * 59.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 59.23 + * or visit www.oracle.com if you need additional information or have any 59.24 + * questions. 59.25 + */ 59.26 + 59.27 +package pkg1; 59.28 + 59.29 +public interface FuncInf<V> { 59.30 + 59.31 + V call() throws Exception; 59.32 +}
60.1 --- a/test/com/sun/javadoc/testLegacyTaglet/C.java Thu Sep 12 11:09:20 2013 -0700 60.2 +++ b/test/com/sun/javadoc/testLegacyTaglet/C.java Tue Sep 17 08:21:11 2013 -0700 60.3 @@ -25,5 +25,13 @@ 60.4 /** 60.5 * This is an {@underline underline}. 60.6 * @todo Finish this class. 60.7 + * @check Check this. 60.8 */ 60.9 -public class C {} 60.10 +public class C { 60.11 + 60.12 + /** 60.13 + * @todo Tag in Method. 60.14 + */ 60.15 + public void mtd() { 60.16 + } 60.17 +}
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 61.2 +++ b/test/com/sun/javadoc/testLegacyTaglet/Check.java Tue Sep 17 08:21:11 2013 -0700 61.3 @@ -0,0 +1,143 @@ 61.4 +/* 61.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 61.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 61.7 + * 61.8 + * This code is free software; you can redistribute it and/or modify it 61.9 + * under the terms of the GNU General Public License version 2 only, as 61.10 + * published by the Free Software Foundation. 61.11 + * 61.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 61.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 61.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 61.15 + * version 2 for more details (a copy is included in the LICENSE file that 61.16 + * accompanied this code). 61.17 + * 61.18 + * You should have received a copy of the GNU General Public License version 61.19 + * 2 along with this work; if not, write to the Free Software Foundation, 61.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 61.21 + * 61.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 61.23 + * or visit www.oracle.com if you need additional information or have any 61.24 + * questions. 61.25 + */ 61.26 + 61.27 +import com.sun.tools.doclets.Taglet; 61.28 +import com.sun.javadoc.*; 61.29 +import java.util.Map; 61.30 + 61.31 +public class Check implements Taglet { 61.32 + 61.33 + private static final String TAG_NAME = "check"; 61.34 + private static final String TAG_HEADER = "Check:"; 61.35 + 61.36 + /** 61.37 + * Return true since the tag can be used in package documentation. 61.38 + * 61.39 + * @return true since the tag can be used in package documentation. 61.40 + */ 61.41 + public boolean inPackage() { 61.42 + return true; 61.43 + } 61.44 + 61.45 + /** 61.46 + * Return true since the tag can be used in overview documentation. 61.47 + * 61.48 + * @return true since the tag can be used in overview documentation. 61.49 + */ 61.50 + public boolean inOverview() { 61.51 + return true; 61.52 + } 61.53 + 61.54 + /** 61.55 + * Return true since the tag can be used in type (class/interface) 61.56 + * documentation. 61.57 + * 61.58 + * @return true since the tag can be used in type (class/interface) 61.59 + * documentation. 61.60 + */ 61.61 + public boolean inType() { 61.62 + return true; 61.63 + } 61.64 + 61.65 + /** 61.66 + * Return true since the tag can be used in constructor documentation. 61.67 + * 61.68 + * @return true since the tag can be used in constructor documentation. 61.69 + */ 61.70 + public boolean inConstructor() { 61.71 + return true; 61.72 + } 61.73 + 61.74 + /** 61.75 + * Return true since the tag can be used in field documentation. 61.76 + * 61.77 + * @return true since the tag can be used in field documentation. 61.78 + */ 61.79 + public boolean inField() { 61.80 + return true; 61.81 + } 61.82 + 61.83 + /** 61.84 + * Return true since the tag can be used in method documentation. 61.85 + * 61.86 + * @return true since the tag can be used in method documentation. 61.87 + */ 61.88 + public boolean inMethod() { 61.89 + return true; 61.90 + } 61.91 + 61.92 + /** 61.93 + * Return false since the tag is not an inline tag. 61.94 + * 61.95 + * @return false since the tag is not an inline tag. 61.96 + */ 61.97 + public boolean isInlineTag() { 61.98 + return false; 61.99 + } 61.100 + 61.101 + /** 61.102 + * Register this taglet. 61.103 + * 61.104 + * @param tagletMap the map to register this tag to. 61.105 + */ 61.106 + @SuppressWarnings("unchecked") 61.107 + public static void register(Map tagletMap) { 61.108 + Check tag = new Check(); 61.109 + Taglet t = (Taglet) tagletMap.get(tag.getName()); 61.110 + if (t != null) { 61.111 + tagletMap.remove(tag.getName()); 61.112 + } 61.113 + tagletMap.put(tag.getName(), tag); 61.114 + } 61.115 + 61.116 + /** 61.117 + * Return the name of this custom tag. 61.118 + * 61.119 + * @return the name of this tag. 61.120 + */ 61.121 + public String getName() { 61.122 + return TAG_NAME; 61.123 + } 61.124 + 61.125 + /** 61.126 + * Given the tag representation of this custom tag, return its string 61.127 + * representation. 61.128 + * 61.129 + * @param tag the tag representation of this custom tag. 61.130 + */ 61.131 + public String toString(Tag tag) { 61.132 + return "<dt><span class=\"strong\">" + TAG_HEADER + ":</span></dt><dd>" + tag.text() + 61.133 + "</dd>\n"; 61.134 + } 61.135 + 61.136 + /** 61.137 + * Given an array of tags representing this custom tag, return its string 61.138 + * representation. 61.139 + * 61.140 + * @param tags the array of tags representing of this custom tag. 61.141 + * @return null to test if the javadoc throws an exception or not. 61.142 + */ 61.143 + public String toString(Tag[] tags) { 61.144 + return null; 61.145 + } 61.146 +}
62.1 --- a/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java Thu Sep 12 11:09:20 2013 -0700 62.2 +++ b/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java Tue Sep 17 08:21:11 2013 -0700 62.3 @@ -1,5 +1,5 @@ 62.4 /* 62.5 - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. 62.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 62.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 62.8 * 62.9 * This code is free software; you can redistribute it and/or modify it 62.10 @@ -23,32 +23,33 @@ 62.11 62.12 /* 62.13 * @test 62.14 - * @bug 4638723 62.15 + * @bug 4638723 8015882 62.16 * @summary Test to ensure that the refactored version of the standard 62.17 * doclet still works with Taglets that implement the 1.4.0 interface. 62.18 * @author jamieh 62.19 * @library ../lib/ 62.20 - * @compile ../lib/JavadocTester.java 62.21 - * @compile TestLegacyTaglet.java 62.22 - * @compile ToDoTaglet.java 62.23 - * @compile UnderlineTaglet.java 62.24 + * @compile ../lib/JavadocTester.java TestLegacyTaglet.java ToDoTaglet.java UnderlineTaglet.java Check.java 62.25 * @run main TestLegacyTaglet 62.26 */ 62.27 62.28 public class TestLegacyTaglet extends JavadocTester { 62.29 62.30 - private static final String BUG_ID = "4638723"; 62.31 + private static final String BUG_ID = "4638723-8015882"; 62.32 62.33 private static final String[] ARGS = 62.34 new String[] {"-d", BUG_ID, "-sourcepath", SRC_DIR, 62.35 - "-tagletpath", SRC_DIR, "-taglet", "ToDoTaglet", 62.36 + "-tagletpath", SRC_DIR, "-taglet", "ToDoTaglet", "-taglet", "Check", 62.37 "-taglet", "UnderlineTaglet", SRC_DIR + FS + "C.java"}; 62.38 62.39 private static final String[][] TEST = new String[][] { 62.40 {BUG_ID + FS + "C.html", "This is an <u>underline</u>"}, 62.41 {BUG_ID + FS + "C.html", 62.42 "<DT><B>To Do:</B><DD><table cellpadding=2 cellspacing=0><tr>" + 62.43 - "<td bgcolor=\"yellow\">Finish this class.</td></tr></table></DD>"}}; 62.44 + "<td bgcolor=\"yellow\">Finish this class.</td></tr></table></DD>"}, 62.45 + {BUG_ID + FS + "C.html", 62.46 + "<DT><B>To Do:</B><DD><table cellpadding=2 cellspacing=0><tr>" + 62.47 + "<td bgcolor=\"yellow\">Tag in Method.</td></tr></table></DD>"} 62.48 + }; 62.49 62.50 private static final String[][] NEGATED_TEST = NO_TEST; 62.51 62.52 @@ -59,6 +60,9 @@ 62.53 public static void main(String[] args) { 62.54 TestLegacyTaglet tester = new TestLegacyTaglet(); 62.55 run(tester, ARGS, TEST, NEGATED_TEST); 62.56 + if (tester.getErrorOutput().contains("NullPointerException")) { 62.57 + throw new AssertionError("javadoc threw NullPointerException"); 62.58 + } 62.59 tester.printSummary(); 62.60 } 62.61
63.1 --- a/test/com/sun/javadoc/testNavigation/TestNavigation.java Thu Sep 12 11:09:20 2013 -0700 63.2 +++ b/test/com/sun/javadoc/testNavigation/TestNavigation.java Tue Sep 17 08:21:11 2013 -0700 63.3 @@ -23,13 +23,12 @@ 63.4 63.5 /* 63.6 * @test 63.7 - * @bug 4131628 4664607 7025314 63.8 + * @bug 4131628 4664607 7025314 8023700 7198273 63.9 * @summary Make sure the Next/Prev Class links iterate through all types. 63.10 * Make sure the navagation is 2 columns, not 3. 63.11 * @author jamieh 63.12 * @library ../lib/ 63.13 - * @build JavadocTester 63.14 - * @build TestNavigation 63.15 + * @build JavadocTester TestNavigation 63.16 * @run main TestNavigation 63.17 */ 63.18 63.19 @@ -45,23 +44,23 @@ 63.20 63.21 //Input for string search tests. 63.22 private static final String[][] TEST = { 63.23 - {BUG_ID + FS + "pkg" + FS + "A.html", "<li>Prev Class</li>"}, 63.24 + {BUG_ID + FS + "pkg" + FS + "A.html", "<li>Prev Class</li>"}, 63.25 {BUG_ID + FS + "pkg" + FS + "A.html", 63.26 - "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">Next Class</span></a>"}, 63.27 + "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">Next Class</span></a>"}, 63.28 {BUG_ID + FS + "pkg" + FS + "C.html", 63.29 - "<a href=\"../pkg/A.html\" title=\"annotation in pkg\"><span class=\"strong\">Prev Class</span></a>"}, 63.30 + "<a href=\"../pkg/A.html\" title=\"annotation in pkg\"><span class=\"strong\">Prev Class</span></a>"}, 63.31 {BUG_ID + FS + "pkg" + FS + "C.html", 63.32 - "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"strong\">Next Class</span></a>"}, 63.33 + "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"strong\">Next Class</span></a>"}, 63.34 {BUG_ID + FS + "pkg" + FS + "E.html", 63.35 - "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">Prev Class</span></a>"}, 63.36 + "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">Prev Class</span></a>"}, 63.37 {BUG_ID + FS + "pkg" + FS + "E.html", 63.38 - "<a href=\"../pkg/I.html\" title=\"interface in pkg\"><span class=\"strong\">Next Class</span></a>"}, 63.39 + "<a href=\"../pkg/I.html\" title=\"interface in pkg\"><span class=\"strong\">Next Class</span></a>"}, 63.40 {BUG_ID + FS + "pkg" + FS + "I.html", 63.41 - "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"strong\">Prev Class</span></a>"}, 63.42 - {BUG_ID + FS + "pkg" + FS + "I.html", "<li>Next Class</li>"}, 63.43 + "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"strong\">Prev Class</span></a>"}, 63.44 + {BUG_ID + FS + "pkg" + FS + "I.html", "<li>Next Class</li>"}, 63.45 // Test for 4664607 63.46 {BUG_ID + FS + "pkg" + FS + "I.html", 63.47 - "<a href=\"#skip-navbar_top\" title=\"Skip navigation links\"></a><a name=\"navbar_top_firstrow\">" + NL + 63.48 + "<div class=\"skipNav\"><a href=\"#skip-navbar_top\" title=\"Skip navigation links\">Skip navigation links</a></div>" + NL + "<a name=\"navbar_top_firstrow\">" + NL + 63.49 "<!-- -->" + NL + "</a>"} 63.50 }; 63.51 private static final String[][] NEGATED_TEST = NO_TEST;
64.1 --- a/test/com/sun/javadoc/testProfiles/TestProfiles.java Thu Sep 12 11:09:20 2013 -0700 64.2 +++ b/test/com/sun/javadoc/testProfiles/TestProfiles.java Tue Sep 17 08:21:11 2013 -0700 64.3 @@ -23,9 +23,9 @@ 64.4 64.5 /* 64.6 * @test 64.7 - * @bug 8006124 8009684 8016921 64.8 + * @bug 8006124 8009684 8016921 8023700 64.9 * @summary Test javadoc support for profiles. 64.10 - * @author Bhavesh Patel 64.11 + * @author Bhavesh Patel, Evgeniya Stepanova 64.12 * @library ../lib/ 64.13 * @build JavadocTester TestProfiles 64.14 * @run main TestProfiles 64.15 @@ -38,8 +38,9 @@ 64.16 private static final String PACKAGE_BUG_ID = BUG_ID + "-2"; 64.17 //Javadoc arguments. 64.18 private static final String[] ARGS1 = new String[]{ 64.19 - "-d", PROFILE_BUG_ID, "-sourcepath", SRC_DIR, "-Xprofilespath", SRC_DIR + FS 64.20 - + "profile-rtjar-includes.txt", "pkg1", "pkg2", "pkg3", "pkg4", "pkg5" 64.21 + "-d", PROFILE_BUG_ID, "-sourcepath", SRC_DIR, "-Xprofilespath", 64.22 + SRC_DIR + FS + "profile-rtjar-includes.txt", "pkg1", "pkg2", 64.23 + "pkg3", "pkg4", "pkg5", "pkgDeprecated" 64.24 }; 64.25 private static final String[] ARGS2 = new String[]{ 64.26 "-d", PACKAGE_BUG_ID, "-sourcepath", SRC_DIR, "pkg1", "pkg2", "pkg3", "pkg4", "pkg5" 64.27 @@ -49,7 +50,7 @@ 64.28 // Tests for profile-overview-frame.html listing all profiles. 64.29 {PROFILE_BUG_ID + FS + "profile-overview-frame.html", 64.30 "<span><a href=\"overview-frame.html\" " 64.31 - + "target=\"packageListFrame\">All Packages</a></span>" 64.32 + + "target=\"packageListFrame\">All Packages</a></span>" 64.33 }, 64.34 {PROFILE_BUG_ID + FS + "profile-overview-frame.html", 64.35 "<li><a href=\"compact1-frame.html\" target=\"packageListFrame\">" 64.36 @@ -58,8 +59,8 @@ 64.37 // Tests for profileName-frame.html listing all packages in a profile. 64.38 {PROFILE_BUG_ID + FS + "compact2-frame.html", 64.39 "<span><a href=\"overview-frame.html\" target=\"packageListFrame\">" 64.40 - + "All Packages</a></span><span><a href=\"profile-overview-frame.html\" " 64.41 - + "target=\"packageListFrame\">All Profiles</a></span>" 64.42 + + "All Packages</a></span><span><a href=\"profile-overview-frame.html\" " 64.43 + + "target=\"packageListFrame\">All Profiles</a></span>" 64.44 }, 64.45 {PROFILE_BUG_ID + FS + "compact2-frame.html", 64.46 "<li><a href=\"pkg4/compact2-package-frame.html\" " 64.47 @@ -74,8 +75,8 @@ 64.48 }, 64.49 // Tests for profileName-summary.html listing the summary for a profile. 64.50 {PROFILE_BUG_ID + FS + "compact2-summary.html", 64.51 - "<li><a href=\"compact1-summary.html\">Prev Profile</a></li>" + NL 64.52 - + "<li><a href=\"compact3-summary.html\">Next Profile</a></li>" 64.53 + "<li><a href=\"compact1-summary.html\">Prev Profile</a></li>" + NL 64.54 + + "<li><a href=\"compact3-summary.html\">Next Profile</a></li>" 64.55 }, 64.56 {PROFILE_BUG_ID + FS + "compact2-summary.html", 64.57 "<h1 title=\"Profile\" class=\"title\">Profile compact2</h1>" 64.58 @@ -87,7 +88,7 @@ 64.59 // Tests for profileName-package-summary.html listing the summary for a 64.60 // package in a profile. 64.61 {PROFILE_BUG_ID + FS + "pkg5" + FS + "compact3-package-summary.html", 64.62 - "<li><a href=\"../pkg4/compact3-package-summary.html\">Prev Package" 64.63 + "<li><a href=\"../pkg4/compact3-package-summary.html\">Prev Package" 64.64 + "</a></li>" 64.65 }, 64.66 {PROFILE_BUG_ID + FS + "pkg5" + FS + "compact3-package-summary.html", 64.67 @@ -96,7 +97,7 @@ 64.68 //Test for "overview-frame.html" showing the "All Profiles" link. 64.69 {PROFILE_BUG_ID + FS + "overview-frame.html", 64.70 "<span><a href=\"profile-overview-frame.html\" " 64.71 - + "target=\"packageListFrame\">All Profiles</a></span>" 64.72 + + "target=\"packageListFrame\">All Profiles</a></span>" 64.73 }, 64.74 //Test for "className.html" showing the profile information for the type. 64.75 {PROFILE_BUG_ID + FS + "pkg2" + FS + "Class1Pkg2.html", 64.76 @@ -113,6 +114,49 @@ 64.77 "target=\"classFrame\">compact2</a></li>" + NL + "<li><a href=\"" + 64.78 "compact3-summary.html\" target=\"classFrame\">compact3</a></li>" + NL + 64.79 "</ul>" 64.80 + }, 64.81 + //Test deprecated class in profiles 64.82 + {PROFILE_BUG_ID + FS + "compact1-summary.html","<td class=\"colFirst\">" 64.83 + + "<a href=\"pkg2/Class1Pkg2.html\" title=\"class in pkg2\">Class1Pkg2</a></td>" 64.84 + + NL + "<td class=\"colLast\">Deprecated" 64.85 + }, 64.86 + {PROFILE_BUG_ID + FS + "deprecated-list.html","<td class=\"colOne\">" 64.87 + + "<a href=\"pkg2/Class1Pkg2.html\" title=\"class in pkg2\">pkg2.Class1Pkg2</a>" 64.88 + + NL +"<div class=\"block\"><span class=\"italic\">Class1Pkg2. This class is deprecated</span></div>" 64.89 + }, 64.90 + //Test deprecated package in profile 64.91 + {PROFILE_BUG_ID + FS + "deprecated-list.html","<td class=\"colOne\">" 64.92 + + "<a href=\"pkgDeprecated/package-summary.html\">pkgDeprecated</a>" 64.93 + + NL +"<div class=\"block\"><span class=\"italic\">This package is <b>Deprecated</b>." 64.94 + + " Use pkg1.</span></div>" 64.95 + }, 64.96 + {PROFILE_BUG_ID + FS + "pkgDeprecated" + FS + "package-summary.html", 64.97 + "<div class=\"deprecatedContent\"><span class=\"strong\">Deprecated.</span>" 64.98 + + NL + "<div class=\"block\"><span class=\"italic\">This package is <b>Deprecated</b>." 64.99 + + " Use pkg1.</span></div>" 64.100 + }, 64.101 + // need to add teststring when JDK-8015496 will be fixed 64.102 + //Test exception in profiles 64.103 + {PROFILE_BUG_ID + FS + "compact1-summary.html","<table class=\"packageSummary\" " 64.104 + + "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" " 64.105 + + "summary=\"Exception Summary table, listing exceptions, and an explanation\">" 64.106 + + NL + "<caption><span>Exception Summary</span><span class=\"tabEnd\">" 64.107 + + " </span></caption>" + NL + "<tr>" + NL + "<th class=\"colFirst\" " 64.108 + + "scope=\"col\">Exception</th>" + NL + "<th class=\"colLast\" scope=\"col\">" 64.109 + + "Description</th>" + NL + "</tr>" + NL + "<tbody>" + NL + "<tr class=\"altColor\">" 64.110 + + NL + "<td class=\"colFirst\"><a href=\"pkg2/ClassException.html\"" 64.111 + + " title=\"class in pkg2\">ClassException</a></td>" 64.112 + }, 64.113 + //Test errors in profiles 64.114 + {PROFILE_BUG_ID + FS + "compact1-summary.html", 64.115 + "<table class=\"packageSummary\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\" " 64.116 + + "summary=\"Error Summary table, listing errors, and an explanation\">" 64.117 + + NL + "<caption><span>Error Summary</span><span class=\"tabEnd\"> " 64.118 + + "</span></caption>" + NL + "<tr>" + NL + "<th class=\"colFirst\"" 64.119 + + " scope=\"col\">Error</th>" + NL + "<th class=\"colLast\" " 64.120 + + "scope=\"col\">Description</th>" + NL + "</tr>" + NL + "<tbody>" 64.121 + + NL + "<tr class=\"altColor\">" + NL + "<td class=\"colFirst\">" 64.122 + + "<a href=\"pkg2/ClassError.html\" title=\"class in pkg2\">ClassError</a></td>" 64.123 } 64.124 }; 64.125 private static final String[][] PROFILES_NEGATED_TEST = { 64.126 @@ -125,6 +169,8 @@ 64.127 {PROFILE_BUG_ID + FS + "pkg4" + FS + "compact2-package-frame.html", 64.128 "<li><a href=\"Anno1Pkg4.html\" title=\"annotation in pkg4\" " 64.129 + "target=\"classFrame\">Anno1Pkg4</a></li>" 64.130 + }, 64.131 + {PROFILE_BUG_ID + FS + "compact1-summary.html","<li>Use</li>" 64.132 } 64.133 }; 64.134 private static final String[][] PACKAGES_TEST = { 64.135 @@ -143,12 +189,12 @@ 64.136 private static final String[][] PACKAGES_NEGATED_TEST = { 64.137 {PACKAGE_BUG_ID + FS + "profile-overview-frame.html", 64.138 "<span><a href=\"overview-frame.html\" " 64.139 - + "target=\"packageListFrame\">All Packages</a></span>" 64.140 + + "target=\"packageListFrame\">All Packages</a></span>" 64.141 }, 64.142 {PACKAGE_BUG_ID + FS + "compact2-frame.html", 64.143 "<span><a href=\"overview-frame.html\" target=\"packageListFrame\">" 64.144 - + "All Packages</a></span><span><a href=\"profile-overview-frame.html\" " 64.145 - + "target=\"packageListFrame\">All Profiles</a></span>" 64.146 + + "All Packages</a></span><span><a href=\"profile-overview-frame.html\" " 64.147 + + "target=\"packageListFrame\">All Profiles</a></span>" 64.148 }, 64.149 {PACKAGE_BUG_ID + FS + "pkg2" + FS + "compact2-package-frame.html", 64.150 "<a href=\"../compact2-summary.html\" target=\"classFrame\">" 64.151 @@ -163,7 +209,7 @@ 64.152 }, 64.153 {PACKAGE_BUG_ID + FS + "overview-frame.html", 64.154 "<span><a href=\"profile-overview-frame.html\" " 64.155 - + "target=\"packageListFrame\">All Profiles</a></span>" 64.156 + + "target=\"packageListFrame\">All Profiles</a></span>" 64.157 }, 64.158 {PACKAGE_BUG_ID + FS + "pkg2" + FS + "Class1Pkg2.html", 64.159 "<div class=\"subTitle\">compact1, compact2, compact3</div>"
65.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 65.2 +++ b/test/com/sun/javadoc/testProfiles/TestProfilesConfiguration.java Tue Sep 17 08:21:11 2013 -0700 65.3 @@ -0,0 +1,127 @@ 65.4 +/* 65.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 65.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 65.7 + * 65.8 + * This code is free software; you can redistribute it and/or modify it 65.9 + * under the terms of the GNU General Public License version 2 only, as 65.10 + * published by the Free Software Foundation. 65.11 + * 65.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 65.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 65.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 65.15 + * version 2 for more details (a copy is included in the LICENSE file that 65.16 + * accompanied this code). 65.17 + * 65.18 + * You should have received a copy of the GNU General Public License version 65.19 + * 2 along with this work; if not, write to the Free Software Foundation, 65.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 65.21 + * 65.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 65.23 + * or visit www.oracle.com if you need additional information or have any 65.24 + * questions. 65.25 + */ 65.26 + 65.27 +/* 65.28 + * @test 65.29 + * @bug 8006124 8009684 8015663 8015496 65.30 + * @summary Test javadoc options support for profiles. 65.31 + * @author Evgeniya Stepanova 65.32 + * @library ../lib/ 65.33 + * @build JavadocTester TestProfilesConfiguration 65.34 + * @run main TestProfilesConfiguration 65.35 + */ 65.36 +public class TestProfilesConfiguration extends JavadocTester { 65.37 + 65.38 + //Test information. 65.39 + private static final String BUG_ID = "8006124-8009684"; 65.40 + private static final String PROFILE_CONFIGURATION_BUG_ID = BUG_ID + "-3"; 65.41 + private static final String NODEPR_NOPKGS_BUG_ID = BUG_ID + "-4"; 65.42 + //Javadoc arguments. 65.43 + private static final String[] ARGS3 = new String[]{ 65.44 + "-d", PROFILE_CONFIGURATION_BUG_ID, "-sourcepath", SRC_DIR, "-nocomment", 65.45 + "-keywords", "-Xprofilespath", SRC_DIR + FS + "profile-rtjar-includes.txt", 65.46 + "-doctitle", "Simple doctitle", "-use", "pkg3", "pkg1", "pkg2", "pkg4", 65.47 + "pkg5", "-packagesheader", "Simple packages header","pkgDeprecated" 65.48 + }; 65.49 + private static final String[] ARGS4 = new String[]{ 65.50 + "-d", NODEPR_NOPKGS_BUG_ID, "-sourcepath", SRC_DIR, "-nocomment", "-nodeprecated", 65.51 + "-keywords", "-Xprofilespath", SRC_DIR + FS + "profile-rtjar-includes-nopkgs.txt", 65.52 + "-doctitle", "Simple doctitle", "-use", "-packagesheader", "Simple packages header", 65.53 + "pkg1", "pkg2", "pkg3", "pkg4", "pkg5", "pkgDeprecated" 65.54 + }; 65.55 + private static final String[][] NODEPR_NOPKGS_TEST = { 65.56 + {NODEPR_NOPKGS_BUG_ID + FS + "overview-summary.html", 65.57 + "<ul>" + NL + "<li><a href=\"compact2-summary.html\" target=\"classFrame\">" + 65.58 + "compact2</a></li>" + NL + "<li><a href=\"compact3-summary.html\" target=\"" + 65.59 + "classFrame\">compact3</a></li>" + NL + "</ul>" 65.60 + }, 65.61 + {NODEPR_NOPKGS_BUG_ID + FS + "profile-overview-frame.html", 65.62 + "<ul title=\"Profiles\">" + NL + "<li><a href=\"compact2-frame.html\" target=\"packageListFrame\">" + 65.63 + "compact2</a></li>" + NL + "<li><a href=\"compact3-frame.html\" target=\"" + 65.64 + "packageListFrame\">compact3</a></li>" + NL + "</ul>" 65.65 + } 65.66 + }; 65.67 + private static final String[][] NODEPR_NOPKGS_NEGATED_TEST = { 65.68 + {NODEPR_NOPKGS_BUG_ID + FS + "overview-summary.html", 65.69 + "compact1" 65.70 + } 65.71 + }; 65.72 + 65.73 + private static final String[][] PROFILES_CONFIGURATION_TEST = { 65.74 + //-use option test string fo profile view page 65.75 + {PROFILE_CONFIGURATION_BUG_ID + FS + "compact1-summary.html","<li>Use</li>" 65.76 + }, 65.77 + //-doctitle option test string 65.78 + {PROFILE_CONFIGURATION_BUG_ID + FS + "overview-summary.html", 65.79 + "<div class=\"header\">" + NL + "<h1 class=\"title\">Simple doctitle</h1>" 65.80 + }, 65.81 + //-packagesheader option test string fo profiles 65.82 + {PROFILE_CONFIGURATION_BUG_ID + FS + "profile-overview-frame.html", 65.83 + "<h1 title=\"Simple packages header\" class=\"bar\">Simple packages header</h1>" 65.84 + }, 65.85 + //-keywords option test string for profiles 65.86 + {PROFILE_CONFIGURATION_BUG_ID + FS + "compact1-summary.html", 65.87 + "<meta name=\"keywords\" content=\"compact1 profile\">" 65.88 + }, 65.89 + //Deprecated information on a package 65.90 + {PROFILE_CONFIGURATION_BUG_ID + FS + "compact1-summary.html", 65.91 + "<h3><a href=\"pkgDeprecated/compact1-package-summary.html\" target=\"" + 65.92 + "classFrame\">pkgDeprecated</a></h3>" + NL + "<div class=\"deprecatedContent\">" + 65.93 + "<span class=\"strong\">Deprecated.</span></div>" 65.94 + } 65.95 + }; 65.96 + private static final String[][] PROFILES_CONFIGURATION_NEGATED_TEST = { 65.97 + //-nocomments option test string 65.98 + {PROFILE_CONFIGURATION_BUG_ID + FS + "compact1-summary.html", 65.99 + "<div class=\"block\"><i>Class1Pkg2.</i></div>" 65.100 + } 65.101 + }; 65.102 + 65.103 + /** 65.104 + * The entry point of the test. 65.105 + * 65.106 + * @param args the array of command line arguments. 65.107 + */ 65.108 + public static void main(String[] args) { 65.109 + TestProfilesConfiguration tester = new TestProfilesConfiguration(); 65.110 + run(tester, ARGS3, PROFILES_CONFIGURATION_TEST, 65.111 + PROFILES_CONFIGURATION_NEGATED_TEST); 65.112 + run(tester, ARGS4, NODEPR_NOPKGS_TEST, 65.113 + NODEPR_NOPKGS_NEGATED_TEST); 65.114 + tester.printSummary(); 65.115 + } 65.116 + 65.117 + /** 65.118 + * {@inheritDoc} 65.119 + */ 65.120 + public String getBugId() { 65.121 + return BUG_ID; 65.122 + } 65.123 + 65.124 + /** 65.125 + * {@inheritDoc} 65.126 + */ 65.127 + public String getBugName() { 65.128 + return getClass().getName(); 65.129 + } 65.130 +}
66.1 --- a/test/com/sun/javadoc/testProfiles/pkg2/Class1Pkg2.java Thu Sep 12 11:09:20 2013 -0700 66.2 +++ b/test/com/sun/javadoc/testProfiles/pkg2/Class1Pkg2.java Tue Sep 17 08:21:11 2013 -0700 66.3 @@ -24,7 +24,7 @@ 66.4 package pkg2; 66.5 66.6 /** 66.7 - * Another test class. 66.8 + * @deprecated Class1Pkg2. This class is deprecated 66.9 * 66.10 * @author Bhavesh Patel 66.11 */
67.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 67.2 +++ b/test/com/sun/javadoc/testProfiles/pkg2/ClassError.java Tue Sep 17 08:21:11 2013 -0700 67.3 @@ -0,0 +1,31 @@ 67.4 +/* 67.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 67.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 67.7 + * 67.8 + * This code is free software; you can redistribute it and/or modify it 67.9 + * under the terms of the GNU General Public License version 2 only, as 67.10 + * published by the Free Software Foundation. 67.11 + * 67.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 67.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 67.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 67.15 + * version 2 for more details (a copy is included in the LICENSE file that 67.16 + * accompanied this code). 67.17 + * 67.18 + * You should have received a copy of the GNU General Public License version 67.19 + * 2 along with this work; if not, write to the Free Software Foundation, 67.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 67.21 + * 67.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 67.23 + * or visit www.oracle.com if you need additional information or have any 67.24 + * questions. 67.25 + */ 67.26 + 67.27 +package pkg2; 67.28 + 67.29 +/** 67.30 + * Simple error class. 67.31 + * 67.32 + * @author Evgeniya Stepanova 67.33 + */ 67.34 +public class ClassError extends Error {}
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 68.2 +++ b/test/com/sun/javadoc/testProfiles/pkg2/ClassException.java Tue Sep 17 08:21:11 2013 -0700 68.3 @@ -0,0 +1,31 @@ 68.4 +/* 68.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 68.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 68.7 + * 68.8 + * This code is free software; you can redistribute it and/or modify it 68.9 + * under the terms of the GNU General Public License version 2 only, as 68.10 + * published by the Free Software Foundation. 68.11 + * 68.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 68.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 68.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 68.15 + * version 2 for more details (a copy is included in the LICENSE file that 68.16 + * accompanied this code). 68.17 + * 68.18 + * You should have received a copy of the GNU General Public License version 68.19 + * 2 along with this work; if not, write to the Free Software Foundation, 68.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 68.21 + * 68.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 68.23 + * or visit www.oracle.com if you need additional information or have any 68.24 + * questions. 68.25 + */ 68.26 + 68.27 +package pkg2; 68.28 + 68.29 +/** 68.30 + * Simple exception class. 68.31 + * 68.32 + * @author Evgeniya Stepanova 68.33 + */ 68.34 +public class ClassException extends Exception {}
69.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 69.2 +++ b/test/com/sun/javadoc/testProfiles/pkgDeprecated/Class1PkgDeprecated.java Tue Sep 17 08:21:11 2013 -0700 69.3 @@ -0,0 +1,36 @@ 69.4 +/* 69.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 69.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 69.7 + * 69.8 + * This code is free software; you can redistribute it and/or modify it 69.9 + * under the terms of the GNU General Public License version 2 only, as 69.10 + * published by the Free Software Foundation. 69.11 + * 69.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 69.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 69.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 69.15 + * version 2 for more details (a copy is included in the LICENSE file that 69.16 + * accompanied this code). 69.17 + * 69.18 + * You should have received a copy of the GNU General Public License version 69.19 + * 2 along with this work; if not, write to the Free Software Foundation, 69.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 69.21 + * 69.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 69.23 + * or visit www.oracle.com if you need additional information or have any 69.24 + * questions. 69.25 + */ 69.26 + 69.27 +package pkgDeprecated; 69.28 + 69.29 +/** 69.30 + * Simple deprecated class of deprecated package. 69.31 + * 69.32 + * @author Evgeniya Stepanova 69.33 + */ 69.34 +public class Class1PkgDeprecated { 69.35 + 69.36 + public void method(int t) { 69.37 + return null; 69.38 + } 69.39 +}
70.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 70.2 +++ b/test/com/sun/javadoc/testProfiles/pkgDeprecated/package-info.java Tue Sep 17 08:21:11 2013 -0700 70.3 @@ -0,0 +1,29 @@ 70.4 +/* 70.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 70.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 70.7 + * 70.8 + * This code is free software; you can redistribute it and/or modify it 70.9 + * under the terms of the GNU General Public License version 2 only, as 70.10 + * published by the Free Software Foundation. 70.11 + * 70.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 70.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 70.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 70.15 + * version 2 for more details (a copy is included in the LICENSE file that 70.16 + * accompanied this code). 70.17 + * 70.18 + * You should have received a copy of the GNU General Public License version 70.19 + * 2 along with this work; if not, write to the Free Software Foundation, 70.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 70.21 + * 70.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 70.23 + * or visit www.oracle.com if you need additional information or have any 70.24 + * questions. 70.25 + */ 70.26 + 70.27 +/** 70.28 + * Deprecated package. 70.29 + * 70.30 + * @deprecated This package is <b>Deprecated</b>. Use pkg1. 70.31 + */ 70.32 +package pkgDeprecated;
71.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 71.2 +++ b/test/com/sun/javadoc/testProfiles/profile-rtjar-includes-nopkgs.txt Tue Sep 17 08:21:11 2013 -0700 71.3 @@ -0,0 +1,41 @@ 71.4 +PROFILE_1_RTJAR_INCLUDE_PACKAGES := 71.5 + 71.6 +PROFILE_1_RTJAR_INCLUDE_TYPES := 71.7 + 71.8 +PROFILE_1_RTJAR_EXCLUDE_TYPES := 71.9 + 71.10 +PROFILE_1_INCLUDE_METAINF_SERVICES := 71.11 + 71.12 + 71.13 +PROFILE_2_RTJAR_INCLUDE_PACKAGES := \ 71.14 + pkg4 \ 71.15 + pkgDeprecated 71.16 + 71.17 +PROFILE_2_RTJAR_INCLUDE_TYPES := 71.18 + 71.19 +PROFILE_2_RTJAR_EXCLUDE_TYPES := \ 71.20 + pkg4/Anno1Pkg4.class 71.21 + 71.22 +PROFILE_2_INCLUDE_METAINF_SERVICES := 71.23 + 71.24 + 71.25 +PROFILE_3_RTJAR_INCLUDE_PACKAGES := \ 71.26 + pkg5 71.27 + 71.28 +PROFILE_3_RTJAR_INCLUDE_TYPES := 71.29 + 71.30 +PROFILE_3_RTJAR_EXCLUDE_TYPES := 71.31 + 71.32 +PROFILE_3_INCLUDE_METAINF_SERVICES := 71.33 + 71.34 + 71.35 +PROFILE_4_RTJAR_INCLUDE_PACKAGES := \ 71.36 + pkg1 71.37 + 71.38 +PROFILE_4_RTJAR_INCLUDE_TYPES := 71.39 + 71.40 +PROFILE_4_RTJAR_EXCLUDE_TYPES := 71.41 + 71.42 +PROFILE_4_INCLUDE_METAINF_SERVICES := 71.43 + 71.44 +
72.1 --- a/test/com/sun/javadoc/testProfiles/profile-rtjar-includes.txt Thu Sep 12 11:09:20 2013 -0700 72.2 +++ b/test/com/sun/javadoc/testProfiles/profile-rtjar-includes.txt Tue Sep 17 08:21:11 2013 -0700 72.3 @@ -1,5 +1,6 @@ 72.4 PROFILE_1_RTJAR_INCLUDE_PACKAGES := \ 72.5 - pkg2 72.6 + pkg2 \ 72.7 + pkgDeprecated 72.8 72.9 PROFILE_1_RTJAR_INCLUDE_TYPES := \ 72.10 pkg3/Class1Pkg3.class
73.1 --- a/test/com/sun/javadoc/testStylesheet/TestStylesheet.java Thu Sep 12 11:09:20 2013 -0700 73.2 +++ b/test/com/sun/javadoc/testStylesheet/TestStylesheet.java Tue Sep 17 08:21:11 2013 -0700 73.3 @@ -23,7 +23,7 @@ 73.4 73.5 /* 73.6 * @test 73.7 - * @bug 4494033 7028815 7052425 8007338 73.8 + * @bug 4494033 7028815 7052425 8007338 8023608 73.9 * @summary Run tests on doclet stylesheet. 73.10 * @author jamieh 73.11 * @library ../lib/ 73.12 @@ -72,7 +72,46 @@ 73.13 " overflow:hidden;" + NL + 73.14 " padding:0px;" + NL + 73.15 " margin:0px;" + NL + 73.16 - " white-space:pre;" + NL + 73.17 + "}"}, 73.18 + {BUG_ID + FS + "stylesheet.css", 73.19 + ".overviewSummary caption span, .packageSummary caption span, " + 73.20 + ".contentContainer ul.blockList li.blockList caption span, " + 73.21 + ".summary caption span, .classUseContainer caption span, " + 73.22 + ".constantValuesContainer caption span {" + NL + 73.23 + " white-space:nowrap;" + NL + 73.24 + " padding-top:8px;" + NL + 73.25 + " padding-left:8px;" + NL + 73.26 + " display:inline-block;" + NL + 73.27 + " float:left;" + NL + 73.28 + " background-image:url(resources/titlebar.gif);" + NL + 73.29 + "}"}, 73.30 + {BUG_ID + FS + "stylesheet.css", 73.31 + ".contentContainer ul.blockList li.blockList caption " + 73.32 + "span.activeTableTab span {" + NL + 73.33 + " white-space:nowrap;" + NL + 73.34 + " padding-top:8px;" + NL + 73.35 + " padding-left:8px;" + NL + 73.36 + " display:inline-block;" + NL + 73.37 + " float:left;" + NL + 73.38 + " background-image:url(resources/activetitlebar.gif);" + NL + 73.39 + "}"}, 73.40 + {BUG_ID + FS + "stylesheet.css", 73.41 + ".contentContainer ul.blockList li.blockList caption span.tableTab span {" + NL + 73.42 + " white-space:nowrap;" + NL + 73.43 + " padding-top:8px;" + NL + 73.44 + " padding-left:8px;" + NL + 73.45 + " display:inline-block;" + NL + 73.46 + " float:left;" + NL + 73.47 + " background-image:url(resources/titlebar.gif);" + NL + 73.48 + "}"}, 73.49 + {BUG_ID + FS + "stylesheet.css", 73.50 + ".contentContainer ul.blockList li.blockList caption span.tableTab, " + 73.51 + ".contentContainer ul.blockList li.blockList caption span.activeTableTab {" + NL + 73.52 + " padding-top:0px;" + NL + 73.53 + " padding-left:0px;" + NL + 73.54 + " background-image:none;" + NL + 73.55 + " float:none;" + NL + 73.56 + " display:inline-block;" + NL + 73.57 "}"}, 73.58 // Test whether a link to the stylesheet file is inserted properly 73.59 // in the class documentation.
74.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 74.2 +++ b/test/lib/combo/TEST.properties Tue Sep 17 08:21:11 2013 -0700 74.3 @@ -0,0 +1,4 @@ 74.4 +# This file identifies root(s) of the test-ng hierarchy. 74.5 + 74.6 + 74.7 +TestNG.dirs = .
75.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 75.2 +++ b/test/lib/combo/tools/javac/combo/Diagnostics.java Tue Sep 17 08:21:11 2013 -0700 75.3 @@ -0,0 +1,82 @@ 75.4 +/* 75.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 75.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 75.7 + * 75.8 + * This code is free software; you can redistribute it and/or modify it 75.9 + * under the terms of the GNU General Public License version 2 only, as 75.10 + * published by the Free Software Foundation. 75.11 + * 75.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 75.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 75.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 75.15 + * version 2 for more details (a copy is included in the LICENSE file that 75.16 + * accompanied this code). 75.17 + * 75.18 + * You should have received a copy of the GNU General Public License version 75.19 + * 2 along with this work; if not, write to the Free Software Foundation, 75.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 75.21 + * 75.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 75.23 + * or visit www.oracle.com if you need additional information or have any 75.24 + * questions. 75.25 + */ 75.26 +package tools.javac.combo; 75.27 + 75.28 +import javax.tools.Diagnostic; 75.29 +import javax.tools.JavaFileObject; 75.30 +import java.util.ArrayList; 75.31 +import java.util.List; 75.32 + 75.33 +import static java.util.stream.Collectors.toList; 75.34 + 75.35 +/** 75.36 +* A container for compiler diagnostics, separated into errors and warnings, 75.37 + * used by JavacTemplateTestBase. 75.38 + * 75.39 + * @author Brian Goetz 75.40 +*/ 75.41 +public class Diagnostics implements javax.tools.DiagnosticListener<JavaFileObject> { 75.42 + 75.43 + protected List<Diagnostic<? extends JavaFileObject>> diags = new ArrayList<>(); 75.44 + protected boolean foundErrors = false; 75.45 + 75.46 + public void report(Diagnostic<? extends JavaFileObject> diagnostic) { 75.47 + diags.add(diagnostic); 75.48 + foundErrors = foundErrors || diagnostic.getKind() == Diagnostic.Kind.ERROR; 75.49 + } 75.50 + 75.51 + /** Were there any errors found? */ 75.52 + public boolean errorsFound() { 75.53 + return foundErrors; 75.54 + } 75.55 + 75.56 + /** Get all diagnostic keys */ 75.57 + public List<String> keys() { 75.58 + return diags.stream() 75.59 + .map(Diagnostic::getCode) 75.60 + .collect(toList()); 75.61 + } 75.62 + 75.63 + /** Do the diagnostics contain the specified error key? */ 75.64 + public boolean containsErrorKey(String key) { 75.65 + return diags.stream() 75.66 + .filter(d -> d.getKind() == Diagnostic.Kind.ERROR) 75.67 + .anyMatch(d -> d.getCode().equals(key)); 75.68 + } 75.69 + 75.70 + /** Get the error keys */ 75.71 + public List<String> errorKeys() { 75.72 + return diags.stream() 75.73 + .filter(d -> d.getKind() == Diagnostic.Kind.ERROR) 75.74 + .map(Diagnostic::getCode) 75.75 + .collect(toList()); 75.76 + } 75.77 + 75.78 + public String toString() { return keys().toString(); } 75.79 + 75.80 + /** Clear all diagnostic state */ 75.81 + public void reset() { 75.82 + diags.clear(); 75.83 + foundErrors = false; 75.84 + } 75.85 +}
76.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 76.2 +++ b/test/lib/combo/tools/javac/combo/JavacTemplateTestBase.java Tue Sep 17 08:21:11 2013 -0700 76.3 @@ -0,0 +1,362 @@ 76.4 +/* 76.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 76.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 76.7 + * 76.8 + * This code is free software; you can redistribute it and/or modify it 76.9 + * under the terms of the GNU General Public License version 2 only, as 76.10 + * published by the Free Software Foundation. 76.11 + * 76.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 76.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 76.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 76.15 + * version 2 for more details (a copy is included in the LICENSE file that 76.16 + * accompanied this code). 76.17 + * 76.18 + * You should have received a copy of the GNU General Public License version 76.19 + * 2 along with this work; if not, write to the Free Software Foundation, 76.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 76.21 + * 76.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 76.23 + * or visit www.oracle.com if you need additional information or have any 76.24 + * questions. 76.25 + */ 76.26 +package tools.javac.combo; 76.27 + 76.28 +import java.io.File; 76.29 +import java.io.IOException; 76.30 +import java.net.MalformedURLException; 76.31 +import java.net.URI; 76.32 +import java.net.URL; 76.33 +import java.net.URLClassLoader; 76.34 +import java.util.ArrayList; 76.35 +import java.util.Arrays; 76.36 +import java.util.Collections; 76.37 +import java.util.HashMap; 76.38 +import java.util.HashSet; 76.39 +import java.util.List; 76.40 +import java.util.Map; 76.41 +import java.util.Set; 76.42 +import java.util.concurrent.atomic.AtomicInteger; 76.43 +import javax.tools.JavaCompiler; 76.44 +import javax.tools.JavaFileObject; 76.45 +import javax.tools.SimpleJavaFileObject; 76.46 +import javax.tools.StandardJavaFileManager; 76.47 +import javax.tools.StandardLocation; 76.48 +import javax.tools.ToolProvider; 76.49 + 76.50 +import com.sun.source.util.JavacTask; 76.51 +import com.sun.tools.javac.util.Pair; 76.52 +import org.testng.ITestResult; 76.53 +import org.testng.annotations.AfterMethod; 76.54 +import org.testng.annotations.AfterSuite; 76.55 +import org.testng.annotations.BeforeMethod; 76.56 +import org.testng.annotations.Test; 76.57 + 76.58 +import static org.testng.Assert.fail; 76.59 + 76.60 +/** 76.61 + * Base class for template-driven TestNG javac tests that support on-the-fly 76.62 + * source file generation, compilation, classloading, execution, and separate 76.63 + * compilation. 76.64 + * 76.65 + * <p>Manages a set of templates (which have embedded tags of the form 76.66 + * {@code #\{NAME\}}), source files (which are also templates), and compile 76.67 + * options. Test cases can register templates and source files, cause them to 76.68 + * be compiled, validate whether the set of diagnostic messages output by the 76.69 + * compiler is correct, and optionally load and run the compiled classes. 76.70 + * 76.71 + * @author Brian Goetz 76.72 + */ 76.73 +@Test 76.74 +public abstract class JavacTemplateTestBase { 76.75 + private static final Set<String> suiteErrors = Collections.synchronizedSet(new HashSet<>()); 76.76 + private static final AtomicInteger counter = new AtomicInteger(); 76.77 + private static final File root = new File("gen"); 76.78 + private static final File nullDir = new File("empty"); 76.79 + 76.80 + protected final Map<String, Template> templates = new HashMap<>(); 76.81 + protected final Diagnostics diags = new Diagnostics(); 76.82 + protected final List<Pair<String, Template>> sourceFiles = new ArrayList<>(); 76.83 + protected final List<String> compileOptions = new ArrayList<>(); 76.84 + protected final List<File> classpaths = new ArrayList<>(); 76.85 + protected final Template.Resolver defaultResolver = new MapResolver(templates); 76.86 + 76.87 + private Template.Resolver currentResolver = defaultResolver; 76.88 + 76.89 + /** Add a template with a specified name */ 76.90 + protected void addTemplate(String name, Template t) { 76.91 + templates.put(name, t); 76.92 + } 76.93 + 76.94 + /** Add a template with a specified name */ 76.95 + protected void addTemplate(String name, String s) { 76.96 + templates.put(name, new StringTemplate(s)); 76.97 + } 76.98 + 76.99 + /** Add a source file */ 76.100 + protected void addSourceFile(String name, Template t) { 76.101 + sourceFiles.add(new Pair<>(name, t)); 76.102 + } 76.103 + 76.104 + /** Add a File to the class path to be used when loading classes; File values 76.105 + * will generally be the result of a previous call to {@link #compile()}. 76.106 + * This enables testing of separate compilation scenarios if the class path 76.107 + * is set up properly. 76.108 + */ 76.109 + protected void addClassPath(File path) { 76.110 + classpaths.add(path); 76.111 + } 76.112 + 76.113 + /** 76.114 + * Add a set of compilation command-line options 76.115 + */ 76.116 + protected void addCompileOptions(String... opts) { 76.117 + Collections.addAll(compileOptions, opts); 76.118 + } 76.119 + 76.120 + /** Reset the compile options to the default (empty) value */ 76.121 + protected void resetCompileOptions() { compileOptions.clear(); } 76.122 + 76.123 + /** Remove all templates */ 76.124 + protected void resetTemplates() { templates.clear(); } 76.125 + 76.126 + /** Remove accumulated diagnostics */ 76.127 + protected void resetDiagnostics() { diags.reset(); } 76.128 + 76.129 + /** Remove all source files */ 76.130 + protected void resetSourceFiles() { sourceFiles.clear(); } 76.131 + 76.132 + /** Remove registered class paths */ 76.133 + protected void resetClassPaths() { classpaths.clear(); } 76.134 + 76.135 + // Before each test method, reset everything 76.136 + @BeforeMethod 76.137 + public void reset() { 76.138 + resetCompileOptions(); 76.139 + resetDiagnostics(); 76.140 + resetSourceFiles(); 76.141 + resetTemplates(); 76.142 + resetClassPaths(); 76.143 + } 76.144 + 76.145 + // After each test method, if the test failed, capture source files and diagnostics and put them in the log 76.146 + @AfterMethod 76.147 + public void copyErrors(ITestResult result) { 76.148 + if (!result.isSuccess()) { 76.149 + suiteErrors.addAll(diags.errorKeys()); 76.150 + 76.151 + List<Object> list = new ArrayList<>(); 76.152 + Collections.addAll(list, result.getParameters()); 76.153 + list.add("Test case: " + getTestCaseDescription()); 76.154 + for (Pair<String, Template> e : sourceFiles) 76.155 + list.add("Source file " + e.fst + ": " + e.snd); 76.156 + if (diags.errorsFound()) 76.157 + list.add("Compile diagnostics: " + diags.toString()); 76.158 + result.setParameters(list.toArray(new Object[list.size()])); 76.159 + } 76.160 + } 76.161 + 76.162 + @AfterSuite 76.163 + // After the suite is done, dump any errors to output 76.164 + public void dumpErrors() { 76.165 + if (!suiteErrors.isEmpty()) 76.166 + System.err.println("Errors found in test suite: " + suiteErrors); 76.167 + } 76.168 + 76.169 + /** 76.170 + * Get a description of this test case; since test cases may be combinatorially 76.171 + * generated, this should include all information needed to describe the test case 76.172 + */ 76.173 + protected String getTestCaseDescription() { 76.174 + return this.toString(); 76.175 + } 76.176 + 76.177 + /** Assert that all previous calls to compile() succeeded */ 76.178 + protected void assertCompileSucceeded() { 76.179 + if (diags.errorsFound()) 76.180 + fail("Expected successful compilation"); 76.181 + } 76.182 + 76.183 + /** 76.184 + * If the provided boolean is true, assert all previous compiles succeeded, 76.185 + * otherwise assert that a compile failed. 76.186 + * */ 76.187 + protected void assertCompileSucceededIff(boolean b) { 76.188 + if (b) 76.189 + assertCompileSucceeded(); 76.190 + else 76.191 + assertCompileFailed(); 76.192 + } 76.193 + 76.194 + /** Assert that a previous call to compile() failed */ 76.195 + protected void assertCompileFailed() { 76.196 + if (!diags.errorsFound()) 76.197 + fail("Expected failed compilation"); 76.198 + } 76.199 + 76.200 + /** Assert that a previous call to compile() failed with a specific error key */ 76.201 + protected void assertCompileFailed(String message) { 76.202 + if (!diags.errorsFound()) 76.203 + fail("Expected failed compilation: " + message); 76.204 + } 76.205 + 76.206 + /** Assert that a previous call to compile() failed with all of the specified error keys */ 76.207 + protected void assertCompileErrors(String... keys) { 76.208 + if (!diags.errorsFound()) 76.209 + fail("Expected failed compilation"); 76.210 + for (String k : keys) 76.211 + if (!diags.containsErrorKey(k)) 76.212 + fail("Expected compilation error " + k); 76.213 + } 76.214 + 76.215 + /** Convert an object, which may be a Template or a String, into a Template */ 76.216 + protected Template asTemplate(Object o) { 76.217 + if (o instanceof Template) 76.218 + return (Template) o; 76.219 + else if (o instanceof String) 76.220 + return new StringTemplate((String) o); 76.221 + else 76.222 + return new StringTemplate(o.toString()); 76.223 + } 76.224 + 76.225 + /** Compile all registered source files */ 76.226 + protected void compile() throws IOException { 76.227 + compile(false); 76.228 + } 76.229 + 76.230 + /** Compile all registered source files, optionally generating class files 76.231 + * and returning a File describing the directory to which they were written */ 76.232 + protected File compile(boolean generate) throws IOException { 76.233 + List<JavaFileObject> files = new ArrayList<>(); 76.234 + for (Pair<String, Template> e : sourceFiles) 76.235 + files.add(new FileAdapter(e.fst, asTemplate(e.snd))); 76.236 + return compile(classpaths, files, generate); 76.237 + } 76.238 + 76.239 + /** Compile all registered source files, using the provided list of class paths 76.240 + * for finding required classfiles, optionally generating class files 76.241 + * and returning a File describing the directory to which they were written */ 76.242 + protected File compile(List<File> classpaths, boolean generate) throws IOException { 76.243 + List<JavaFileObject> files = new ArrayList<>(); 76.244 + for (Pair<String, Template> e : sourceFiles) 76.245 + files.add(new FileAdapter(e.fst, asTemplate(e.snd))); 76.246 + return compile(classpaths, files, generate); 76.247 + } 76.248 + 76.249 + private File compile(List<File> classpaths, List<JavaFileObject> files, boolean generate) throws IOException { 76.250 + JavaCompiler systemJavaCompiler = ToolProvider.getSystemJavaCompiler(); 76.251 + StandardJavaFileManager fm = systemJavaCompiler.getStandardFileManager(null, null, null); 76.252 + if (classpaths.size() > 0) 76.253 + fm.setLocation(StandardLocation.CLASS_PATH, classpaths); 76.254 + JavacTask ct = (JavacTask) systemJavaCompiler.getTask(null, fm, diags, compileOptions, null, files); 76.255 + if (generate) { 76.256 + File destDir = new File(root, Integer.toString(counter.incrementAndGet())); 76.257 + // @@@ Assert that this directory didn't exist, or start counter at max+1 76.258 + destDir.mkdirs(); 76.259 + fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir)); 76.260 + ct.generate(); 76.261 + return destDir; 76.262 + } 76.263 + else { 76.264 + ct.analyze(); 76.265 + return nullDir; 76.266 + } 76.267 + } 76.268 + 76.269 + /** Load the given class using the provided list of class paths */ 76.270 + protected Class<?> loadClass(String className, File... destDirs) { 76.271 + try { 76.272 + List<URL> list = new ArrayList<>(); 76.273 + for (File f : destDirs) 76.274 + list.add(new URL("file:" + f.toString().replace("\\", "/") + "/")); 76.275 + return Class.forName(className, true, new URLClassLoader(list.toArray(new URL[list.size()]))); 76.276 + } catch (ClassNotFoundException | MalformedURLException e) { 76.277 + throw new RuntimeException("Error loading class " + className, e); 76.278 + } 76.279 + } 76.280 + 76.281 + /** An implementation of Template which is backed by a String */ 76.282 + protected class StringTemplate implements Template { 76.283 + protected final String template; 76.284 + 76.285 + public StringTemplate(String template) { 76.286 + this.template = template; 76.287 + } 76.288 + 76.289 + public String expand(String selector) { 76.290 + return Behavior.expandTemplate(template, currentResolver); 76.291 + } 76.292 + 76.293 + public String toString() { 76.294 + return expand(""); 76.295 + } 76.296 + 76.297 + public StringTemplate with(final String key, final String value) { 76.298 + return new StringTemplateWithResolver(template, new KeyResolver(key, value)); 76.299 + } 76.300 + 76.301 + } 76.302 + 76.303 + /** An implementation of Template which is backed by a String and which 76.304 + * encapsulates a Resolver for resolving embedded tags. */ 76.305 + protected class StringTemplateWithResolver extends StringTemplate { 76.306 + private final Resolver localResolver; 76.307 + 76.308 + public StringTemplateWithResolver(String template, Resolver localResolver) { 76.309 + super(template); 76.310 + this.localResolver = localResolver; 76.311 + } 76.312 + 76.313 + @Override 76.314 + public String expand(String selector) { 76.315 + Resolver saved = currentResolver; 76.316 + currentResolver = new ChainedResolver(currentResolver, localResolver); 76.317 + try { 76.318 + return super.expand(selector); 76.319 + } 76.320 + finally { 76.321 + currentResolver = saved; 76.322 + } 76.323 + } 76.324 + 76.325 + @Override 76.326 + public StringTemplate with(String key, String value) { 76.327 + return new StringTemplateWithResolver(template, new ChainedResolver(localResolver, new KeyResolver(key, value))); 76.328 + } 76.329 + } 76.330 + 76.331 + /** A Resolver which uses a Map to resolve tags */ 76.332 + private class KeyResolver implements Template.Resolver { 76.333 + private final String key; 76.334 + private final String value; 76.335 + 76.336 + public KeyResolver(String key, String value) { 76.337 + this.key = key; 76.338 + this.value = value; 76.339 + } 76.340 + 76.341 + @Override 76.342 + public Template lookup(String k) { 76.343 + return key.equals(k) ? new StringTemplate(value) : null; 76.344 + } 76.345 + } 76.346 + 76.347 + private class FileAdapter extends SimpleJavaFileObject { 76.348 + private final String filename; 76.349 + private final Template template; 76.350 + 76.351 + public FileAdapter(String filename, Template template) { 76.352 + super(URI.create("myfo:/" + filename), Kind.SOURCE); 76.353 + this.template = template; 76.354 + this.filename = filename; 76.355 + } 76.356 + 76.357 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 76.358 + return toString(); 76.359 + } 76.360 + 76.361 + public String toString() { 76.362 + return Template.Behavior.expandTemplate(template.expand(filename), defaultResolver); 76.363 + } 76.364 + } 76.365 +}
77.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 77.2 +++ b/test/lib/combo/tools/javac/combo/Template.java Tue Sep 17 08:21:11 2013 -0700 77.3 @@ -0,0 +1,123 @@ 77.4 +/* 77.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 77.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 77.7 + * 77.8 + * This code is free software; you can redistribute it and/or modify it 77.9 + * under the terms of the GNU General Public License version 2 only, as 77.10 + * published by the Free Software Foundation. 77.11 + * 77.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 77.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 77.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 77.15 + * version 2 for more details (a copy is included in the LICENSE file that 77.16 + * accompanied this code). 77.17 + * 77.18 + * You should have received a copy of the GNU General Public License version 77.19 + * 2 along with this work; if not, write to the Free Software Foundation, 77.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 77.21 + * 77.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 77.23 + * or visit www.oracle.com if you need additional information or have any 77.24 + * questions. 77.25 + */ 77.26 +package tools.javac.combo; 77.27 + 77.28 +import java.util.Map; 77.29 +import java.util.regex.Matcher; 77.30 +import java.util.regex.Pattern; 77.31 + 77.32 +/** 77.33 + * A template into which tags of the form {@code #\{KEY\}} or 77.34 + * {@code #\{KEY.SUBKEY\}} can be expanded. 77.35 + */ 77.36 +public interface Template { 77.37 + String expand(String selector); 77.38 + 77.39 + interface Resolver { 77.40 + public Template lookup(String key); 77.41 + } 77.42 + 77.43 + public static class Behavior { 77.44 + /* Looks for expandable keys. An expandable key can take the form: 77.45 + * #{MAJOR} 77.46 + * #{MAJOR.} 77.47 + * #{MAJOR.MINOR} 77.48 + * where MAJOR can be IDENTIFIER or IDENTIFIER[NUMERIC_INDEX] 77.49 + * and MINOR can be an identifier. 77.50 + * 77.51 + * The ability to have an empty minor is provided on the 77.52 + * assumption that some tests that can be written with this 77.53 + * will find it useful to make a distinction akin to 77.54 + * distinguishing F from F(), where F is a function pointer, 77.55 + * and also cases of #{FOO.#{BAR}}, where BAR expands to an 77.56 + * empty string. 77.57 + * 77.58 + * However, this being a general-purpose framework, the exact 77.59 + * use is left up to the test writers. 77.60 + */ 77.61 + private static final Pattern pattern = Pattern.compile("#\\{([A-Z_][A-Z0-9_]*(?:\\[\\d+\\])?)(?:\\.([A-Z0-9_]*))?\\}"); 77.62 + 77.63 + public static String expandTemplate(String template, final Map<String, Template> vars) { 77.64 + return expandTemplate(template, new MapResolver(vars)); 77.65 + } 77.66 + 77.67 + public static String expandTemplate(String template, Resolver res) { 77.68 + CharSequence in = template; 77.69 + StringBuffer out = new StringBuffer(); 77.70 + while (true) { 77.71 + boolean more = false; 77.72 + Matcher m = pattern.matcher(in); 77.73 + while (m.find()) { 77.74 + String major = m.group(1); 77.75 + String minor = m.group(2); 77.76 + Template key = res.lookup(major); 77.77 + if (key == null) 77.78 + throw new IllegalStateException("Unknown major key " + major); 77.79 + 77.80 + String replacement = key.expand(minor == null ? "" : minor); 77.81 + more |= pattern.matcher(replacement).find(); 77.82 + m.appendReplacement(out, replacement); 77.83 + } 77.84 + m.appendTail(out); 77.85 + if (!more) 77.86 + return out.toString(); 77.87 + else { 77.88 + in = out; 77.89 + out = new StringBuffer(); 77.90 + } 77.91 + } 77.92 + } 77.93 + 77.94 + } 77.95 +} 77.96 + 77.97 +class MapResolver implements Template.Resolver { 77.98 + private final Map<String, Template> vars; 77.99 + 77.100 + public MapResolver(Map<String, Template> vars) {this.vars = vars;} 77.101 + 77.102 + public Template lookup(String key) { 77.103 + return vars.get(key); 77.104 + } 77.105 +} 77.106 + 77.107 +class ChainedResolver implements Template.Resolver { 77.108 + private final Template.Resolver upstreamResolver, thisResolver; 77.109 + 77.110 + public ChainedResolver(Template.Resolver upstreamResolver, Template.Resolver thisResolver) { 77.111 + this.upstreamResolver = upstreamResolver; 77.112 + this.thisResolver = thisResolver; 77.113 + } 77.114 + 77.115 + public Template.Resolver getUpstreamResolver() { 77.116 + return upstreamResolver; 77.117 + } 77.118 + 77.119 + @Override 77.120 + public Template lookup(String key) { 77.121 + Template result = thisResolver.lookup(key); 77.122 + if (result == null) 77.123 + result = upstreamResolver.lookup(key); 77.124 + return result; 77.125 + } 77.126 +}
78.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 78.2 +++ b/test/lib/combo/tools/javac/combo/TemplateTest.java Tue Sep 17 08:21:11 2013 -0700 78.3 @@ -0,0 +1,94 @@ 78.4 +/* 78.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 78.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 78.7 + * 78.8 + * This code is free software; you can redistribute it and/or modify it 78.9 + * under the terms of the GNU General Public License version 2 only, as 78.10 + * published by the Free Software Foundation. 78.11 + * 78.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 78.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 78.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 78.15 + * version 2 for more details (a copy is included in the LICENSE file that 78.16 + * accompanied this code). 78.17 + * 78.18 + * You should have received a copy of the GNU General Public License version 78.19 + * 2 along with this work; if not, write to the Free Software Foundation, 78.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 78.21 + * 78.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 78.23 + * or visit www.oracle.com if you need additional information or have any 78.24 + * questions. 78.25 + * 78.26 + */ 78.27 +package tools.javac.combo; 78.28 + 78.29 +import org.testng.annotations.BeforeTest; 78.30 +import org.testng.annotations.Test; 78.31 + 78.32 +import java.util.HashMap; 78.33 +import java.util.Map; 78.34 + 78.35 +import static org.testng.Assert.assertEquals; 78.36 + 78.37 +/** 78.38 + * TemplateTest 78.39 + */ 78.40 +@Test 78.41 +public class TemplateTest { 78.42 + Map<String, Template> vars = new HashMap<>(); 78.43 + 78.44 + @BeforeTest 78.45 + void before() { vars.clear(); } 78.46 + 78.47 + private void assertTemplate(String expected, String template) { 78.48 + String result = Template.Behavior.expandTemplate(template, vars); 78.49 + assertEquals(result, expected, "for " + template); 78.50 + } 78.51 + 78.52 + private String dotIf(String s) { 78.53 + return s == null || s.isEmpty() ? "" : "." + s; 78.54 + } 78.55 + 78.56 + public void testTemplateExpansion() { 78.57 + vars.put("A", s -> "a" + dotIf(s)); 78.58 + vars.put("B", s -> "b" + dotIf(s)); 78.59 + vars.put("C", s -> "#{A}#{B}"); 78.60 + vars.put("D", s -> "#{A" + dotIf(s) + "}#{B" + dotIf(s) + "}"); 78.61 + vars.put("_D", s -> "d"); 78.62 + 78.63 + assertTemplate("", ""); 78.64 + assertTemplate("foo", "foo"); 78.65 + assertTemplate("a", "#{A}"); 78.66 + assertTemplate("a", "#{A.}"); 78.67 + assertTemplate("a.FOO", "#{A.FOO}"); 78.68 + assertTemplate("aa", "#{A}#{A}"); 78.69 + assertTemplate("ab", "#{C}"); 78.70 + assertTemplate("ab", "#{C.FOO}"); 78.71 + assertTemplate("ab", "#{C.}"); 78.72 + assertTemplate("a.FOOb.FOO", "#{D.FOO}"); 78.73 + assertTemplate("ab", "#{D}"); 78.74 + assertTemplate("d", "#{_D}"); 78.75 + assertTemplate("#{A", "#{A"); 78.76 + } 78.77 + 78.78 + public void testIndexedTemplate() { 78.79 + vars.put("A[0]", s -> "a" ); 78.80 + vars.put("A[1]", s -> "b" ); 78.81 + vars.put("A[2]", s -> "c" ); 78.82 + vars.put("X", s -> "0"); 78.83 + assertTemplate("a", "#{A[0]}"); 78.84 + assertTemplate("b", "#{A[1]}"); 78.85 + assertTemplate("c", "#{A[2]}"); 78.86 + } 78.87 + 78.88 + public void testAngleBrackets() { 78.89 + vars.put("X", s -> "xyz"); 78.90 + assertTemplate("List<String> ls = xyz;", "List<String> ls = #{X};"); 78.91 + } 78.92 + 78.93 + @Test(expectedExceptions = IllegalStateException.class ) 78.94 + public void testUnknownKey() { 78.95 + assertTemplate("#{Q}", "#{Q}"); 78.96 + } 78.97 +}
79.1 --- a/test/tools/javac/Diagnostics/compressed/T8012003c.out Thu Sep 12 11:09:20 2013 -0700 79.2 +++ b/test/tools/javac/Diagnostics/compressed/T8012003c.out Tue Sep 17 08:21:11 2013 -0700 79.3 @@ -1,3 +1,2 @@ 79.4 T8012003c.java:18:15: compiler.err.report.access: m(), private, P 79.5 -- compiler.note.compressed.diags 79.6 1 error
80.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 80.2 +++ b/test/tools/javac/T8022162/IncorrectSignatureDeterminationForInnerClassesTest.java Tue Sep 17 08:21:11 2013 -0700 80.3 @@ -0,0 +1,89 @@ 80.4 +/* 80.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 80.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 80.7 + * 80.8 + * This code is free software; you can redistribute it and/or modify it 80.9 + * under the terms of the GNU General Public License version 2 only, as 80.10 + * published by the Free Software Foundation. 80.11 + * 80.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 80.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 80.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 80.15 + * version 2 for more details (a copy is included in the LICENSE file that 80.16 + * accompanied this code). 80.17 + * 80.18 + * You should have received a copy of the GNU General Public License version 80.19 + * 2 along with this work; if not, write to the Free Software Foundation, 80.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 80.21 + * 80.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 80.23 + * or visit www.oracle.com if you need additional information or have any 80.24 + * questions. 80.25 + */ 80.26 + 80.27 +/* 80.28 + * @test 80.29 + * @bug 8022162 80.30 + * @summary Incorrect signature determination for certain inner class generics 80.31 + * @library /tools/javac/lib 80.32 + * @build ToolBox 80.33 + * @run main IncorrectSignatureDeterminationForInnerClassesTest 80.34 + */ 80.35 + 80.36 +import java.nio.file.Files; 80.37 +import java.nio.file.Paths; 80.38 + 80.39 +public class IncorrectSignatureDeterminationForInnerClassesTest { 80.40 + 80.41 + private static final String DSrc = 80.42 + "package p1;\n" + 80.43 + 80.44 + "public class D<T> {\n" + 80.45 + "}\n" + 80.46 + 80.47 + "abstract class Q<T> {\n" + 80.48 + " protected void m(M.E e) {}\n" + 80.49 + 80.50 + " public class M extends D<T> {\n" + 80.51 + " public class E {}\n" + 80.52 + " }\n" + 80.53 + "}"; 80.54 + 80.55 + private static final String HSrc = 80.56 + "package p1;\n" + 80.57 + 80.58 + "public class H {\n" + 80.59 + " static class EQ extends Q<Object> {\n" + 80.60 + " private void m2(M.E item) {\n" + 80.61 + " m(item);\n" + 80.62 + " }\n" + 80.63 + " }\n" + 80.64 + "}"; 80.65 + 80.66 + public static void main(String args[]) throws Exception { 80.67 + new IncorrectSignatureDeterminationForInnerClassesTest().run(); 80.68 + } 80.69 + 80.70 + void run() throws Exception { 80.71 + compile(); 80.72 + } 80.73 + 80.74 + void compile() throws Exception { 80.75 + Files.createDirectory(Paths.get("classes")); 80.76 + 80.77 + ToolBox.JavaToolArgs javacParams = 80.78 + new ToolBox.JavaToolArgs() 80.79 + .appendArgs("-d", "classes") 80.80 + .setSources(DSrc); 80.81 + 80.82 + ToolBox.javac(javacParams); 80.83 + 80.84 + // compile class H against the class files for classes D and Q 80.85 + javacParams = 80.86 + new ToolBox.JavaToolArgs() 80.87 + .appendArgs("-d", "classes", "-cp", "classes") 80.88 + .setSources(HSrc); 80.89 + ToolBox.javac(javacParams); 80.90 + } 80.91 + 80.92 +}
81.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 81.2 +++ b/test/tools/javac/T8023545/MisleadingErrorMsgDiamondPlusPrivateCtorTest.java Tue Sep 17 08:21:11 2013 -0700 81.3 @@ -0,0 +1,16 @@ 81.4 +/* 81.5 + * @test /nodynamiccopyright/ 81.6 + * @bug 8023545 81.7 + * @summary Misleading error message when using diamond operator with private constructor 81.8 + * @compile/fail/ref=MisleadingErrorMsgDiamondPlusPrivateCtorTest.out -XDrawDiagnostics MisleadingErrorMsgDiamondPlusPrivateCtorTest.java 81.9 + */ 81.10 + 81.11 +public class MisleadingErrorMsgDiamondPlusPrivateCtorTest { 81.12 + public void foo() { 81.13 + MyClass<Object> foo = new MyClass<>(); 81.14 + } 81.15 +} 81.16 + 81.17 +class MyClass<E> { 81.18 + private MyClass() {} 81.19 +}
82.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 82.2 +++ b/test/tools/javac/T8023545/MisleadingErrorMsgDiamondPlusPrivateCtorTest.out Tue Sep 17 08:21:11 2013 -0700 82.3 @@ -0,0 +1,2 @@ 82.4 +MisleadingErrorMsgDiamondPlusPrivateCtorTest.java:10:31: compiler.err.report.access: <E>MyClass(), private, MyClass 82.5 +1 error
83.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 83.2 +++ b/test/tools/javac/T8024039/NoDeadCodeGenerationOnTrySmtTest.java Tue Sep 17 08:21:11 2013 -0700 83.3 @@ -0,0 +1,124 @@ 83.4 +/* 83.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 83.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 83.7 + * 83.8 + * This code is free software; you can redistribute it and/or modify it 83.9 + * under the terms of the GNU General Public License version 2 only, as 83.10 + * published by the Free Software Foundation. Oracle designates this 83.11 + * particular file as subject to the "Classpath" exception as provided 83.12 + * by Oracle in the LICENSE file that accompanied this code. 83.13 + * 83.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 83.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 83.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 83.17 + * version 2 for more details (a copy is included in the LICENSE file that 83.18 + * accompanied this code). 83.19 + * 83.20 + * You should have received a copy of the GNU General Public License version 83.21 + * 2 along with this work; if not, write to the Free Software Foundation, 83.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 83.23 + * 83.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 83.25 + * or visit www.oracle.com if you need additional information or have any 83.26 + * questions. 83.27 + */ 83.28 + 83.29 +/* 83.30 + * @test 83.31 + * @bug 8024039 83.32 + * @summary javac, previous solution for JDK-8022186 was incorrect 83.33 + * @library /tools/javac/lib 83.34 + * @build ToolBox 83.35 + * @run main NoDeadCodeGenerationOnTrySmtTest 83.36 + */ 83.37 + 83.38 +import java.io.File; 83.39 +import java.nio.file.Paths; 83.40 + 83.41 +import com.sun.tools.classfile.ClassFile; 83.42 +import com.sun.tools.classfile.Code_attribute; 83.43 +import com.sun.tools.classfile.Code_attribute.Exception_data; 83.44 +import com.sun.tools.classfile.Method; 83.45 +import com.sun.tools.javac.util.Assert; 83.46 + 83.47 +public class NoDeadCodeGenerationOnTrySmtTest { 83.48 + 83.49 + static final String testSource = 83.50 + "public class Test {\n" + 83.51 + " void m1(int arg) {\n" + 83.52 + " synchronized (new Integer(arg)) {\n" + 83.53 + " {\n" + 83.54 + " label0:\n" + 83.55 + " do {\n" + 83.56 + " break label0;\n" + 83.57 + " } while (arg != 0);\n" + 83.58 + " }\n" + 83.59 + " }\n" + 83.60 + " }\n" + 83.61 + 83.62 + " void m2(int arg) {\n" + 83.63 + " synchronized (new Integer(arg)) {\n" + 83.64 + " {\n" + 83.65 + " label0:\n" + 83.66 + " {\n" + 83.67 + " break label0;\n" + 83.68 + " }\n" + 83.69 + " }\n" + 83.70 + " }\n" + 83.71 + " }\n" + 83.72 + "}"; 83.73 + 83.74 + static final int[][] expectedExceptionTable = { 83.75 + // {from, to, target, type}, 83.76 + {11, 13, 16, 0}, 83.77 + {16, 19, 16, 0} 83.78 + }; 83.79 + 83.80 + static final String[] methodsToLookFor = {"m1", "m2"}; 83.81 + 83.82 + public static void main(String[] args) throws Exception { 83.83 + new NoDeadCodeGenerationOnTrySmtTest().run(); 83.84 + } 83.85 + 83.86 + void run() throws Exception { 83.87 + compileTestClass(); 83.88 + checkClassFile(new File(Paths.get(System.getProperty("user.dir"), 83.89 + "Test.class").toUri()), methodsToLookFor); 83.90 + } 83.91 + 83.92 + void compileTestClass() throws Exception { 83.93 + ToolBox.JavaToolArgs javacSuccessArgs = 83.94 + new ToolBox.JavaToolArgs().setSources(testSource); 83.95 + ToolBox.javac(javacSuccessArgs); 83.96 + } 83.97 + 83.98 + void checkClassFile(final File cfile, String[] methodsToFind) throws Exception { 83.99 + ClassFile classFile = ClassFile.read(cfile); 83.100 + int numberOfmethodsFound = 0; 83.101 + for (String methodToFind : methodsToFind) { 83.102 + for (Method method : classFile.methods) { 83.103 + if (method.getName(classFile.constant_pool).equals(methodToFind)) { 83.104 + numberOfmethodsFound++; 83.105 + Code_attribute code = (Code_attribute) method.attributes.get("Code"); 83.106 + Assert.check(code.exception_table_langth == expectedExceptionTable.length, 83.107 + "The ExceptionTable found has a length different to the expected one"); 83.108 + int i = 0; 83.109 + for (Exception_data entry: code.exception_table) { 83.110 + Assert.check(entry.start_pc == expectedExceptionTable[i][0] && 83.111 + entry.end_pc == expectedExceptionTable[i][1] && 83.112 + entry.handler_pc == expectedExceptionTable[i][2] && 83.113 + entry.catch_type == expectedExceptionTable[i][3], 83.114 + "Exception table entry at pos " + i + " differ from expected."); 83.115 + i++; 83.116 + } 83.117 + } 83.118 + } 83.119 + } 83.120 + Assert.check(numberOfmethodsFound == 2, "Some seek methods were not found"); 83.121 + } 83.122 + 83.123 + void error(String msg) { 83.124 + throw new AssertionError(msg); 83.125 + } 83.126 + 83.127 +}
84.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 84.2 +++ b/test/tools/javac/T8024207/FlowCrashTest.java Tue Sep 17 08:21:11 2013 -0700 84.3 @@ -0,0 +1,23 @@ 84.4 +/* 84.5 + * @test /nodynamiccopyright/ 84.6 + * @bug 8024207 84.7 + * @summary javac crash in Flow$AssignAnalyzer.visitIdent 84.8 + * @compile/fail/ref=FlowCrashTest.out -XDrawDiagnostics FlowCrashTest.java 84.9 + */ 84.10 + 84.11 +import java.util.*; 84.12 +import java.util.stream.*; 84.13 + 84.14 +public class FlowCrashTest { 84.15 + static class ViewId { } 84.16 + 84.17 + public void crash() { 84.18 + 84.19 + Map<ViewId,String> viewToProfile = null; 84.20 + new TreeMap<>(viewToProfile.entrySet().stream() 84.21 + .collect(Collectors.toMap((vid, prn) -> prn, 84.22 + (vid, prn) -> Arrays.asList(vid), 84.23 + (a, b) -> { a.addAll(b); return a; }))); 84.24 + 84.25 + } 84.26 +}
85.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 85.2 +++ b/test/tools/javac/T8024207/FlowCrashTest.out Tue Sep 17 08:21:11 2013 -0700 85.3 @@ -0,0 +1,2 @@ 85.4 +FlowCrashTest.java:18:42: compiler.err.cant.apply.symbols: kindname.method, toMap, @475,@542,@624,{(compiler.misc.inapplicable.method: kindname.method, java.util.stream.Collectors, <T,K,U>toMap(java.util.function.Function<? super T,? extends K>,java.util.function.Function<? super T,? extends U>), (compiler.misc.infer.arg.length.mismatch: T,K,U)),(compiler.misc.inapplicable.method: kindname.method, java.util.stream.Collectors, <T,K,U>toMap(java.util.function.Function<? super T,? extends K>,java.util.function.Function<? super T,? extends U>,java.util.function.BinaryOperator<U>), (compiler.misc.infer.no.conforming.assignment.exists: T,K,U, (compiler.misc.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, java.util.stream.Collectors, <T,K,U,M>toMap(java.util.function.Function<? super T,? extends K>,java.util.function.Function<? super T,? extends U>,java.util.function.BinaryOperator<U>,java.util.function.Supplier<M>), (compiler.misc.infer.arg.length.mismatch: T,K,U,M))} 85.5 +1 error
86.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 86.2 +++ b/test/tools/javac/T8024398/NPETryTest.java Tue Sep 17 08:21:11 2013 -0700 86.3 @@ -0,0 +1,49 @@ 86.4 +/* 86.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 86.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 86.7 + * 86.8 + * This code is free software; you can redistribute it and/or modify it 86.9 + * under the terms of the GNU General Public License version 2 only, as 86.10 + * published by the Free Software Foundation. Oracle designates this 86.11 + * particular file as subject to the "Classpath" exception as provided 86.12 + * by Oracle in the LICENSE file that accompanied this code. 86.13 + * 86.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 86.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 86.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 86.17 + * version 2 for more details (a copy is included in the LICENSE file that 86.18 + * accompanied this code). 86.19 + * 86.20 + * You should have received a copy of the GNU General Public License version 86.21 + * 2 along with this work; if not, write to the Free Software Foundation, 86.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 86.23 + * 86.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 86.25 + * or visit www.oracle.com if you need additional information or have any 86.26 + * questions. 86.27 + */ 86.28 + 86.29 +/* 86.30 + * @test 86.31 + * @bug 8024398 86.32 + * @summary javac, compiler crashes with try with empty body 86.33 + * @compile NPETryTest.java 86.34 + */ 86.35 + 86.36 +public class NPETryTest { 86.37 + void m() 86.38 + { 86.39 + /* This is the statement provoking the error the rest are provided as 86.40 + * additional tests 86.41 + */ 86.42 + try {} 86.43 + catch (Exception e) {} 86.44 + 86.45 + try {} 86.46 + catch (Exception e) {} 86.47 + finally {} 86.48 + 86.49 + try {} 86.50 + finally {} 86.51 + } 86.52 +}
87.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 87.2 +++ b/test/tools/javac/annotations/neg/NoDefault.java Tue Sep 17 08:21:11 2013 -0700 87.3 @@ -0,0 +1,9 @@ 87.4 +/* 87.5 + * @test /nodynamiccopyright/ 87.6 + * @bug 8022322 87.7 + * @summary Default methods are not allowed in an annotation. 87.8 + * @compile/fail/ref=NoDefault.out -XDrawDiagnostics NoDefault.java 87.9 + */ 87.10 +@interface NoDefault { 87.11 + default int m() {return 0;} 87.12 +}
88.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 88.2 +++ b/test/tools/javac/annotations/neg/NoDefault.out Tue Sep 17 08:21:11 2013 -0700 88.3 @@ -0,0 +1,3 @@ 88.4 +NoDefault.java:8:17: compiler.err.mod.not.allowed.here: default 88.5 +NoDefault.java:8:21: compiler.err.intf.meth.cant.have.body 88.6 +2 errors 88.7 \ No newline at end of file
89.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 89.2 +++ b/test/tools/javac/annotations/neg/NoDefaultAbstract.java Tue Sep 17 08:21:11 2013 -0700 89.3 @@ -0,0 +1,9 @@ 89.4 +/* 89.5 + * @test /nodynamiccopyright/ 89.6 + * @bug 8022322 89.7 + * @summary Default methods are not allowed in an annotation. 89.8 + * @compile/fail/ref=NoDefaultAbstract.out -XDrawDiagnostics NoDefaultAbstract.java 89.9 + */ 89.10 +@interface NoDefaultAbstract { 89.11 + default int m(); 89.12 +}
90.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 90.2 +++ b/test/tools/javac/annotations/neg/NoDefaultAbstract.out Tue Sep 17 08:21:11 2013 -0700 90.3 @@ -0,0 +1,2 @@ 90.4 +NoDefaultAbstract.java:8:17: compiler.err.mod.not.allowed.here: default 90.5 +1 error
91.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 91.2 +++ b/test/tools/javac/annotations/neg/NoStatic.java Tue Sep 17 08:21:11 2013 -0700 91.3 @@ -0,0 +1,10 @@ 91.4 +/* 91.5 + * @test /nodynamiccopyright/ 91.6 + * @bug 8022322 91.7 + * @summary Static methods are not allowed in an annotation. 91.8 + * @compile/fail/ref=NoStatic.out -XDrawDiagnostics NoStatic.java 91.9 + */ 91.10 + 91.11 +@interface NoStatic { 91.12 + static int m() {return 0;} 91.13 +}
92.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 92.2 +++ b/test/tools/javac/annotations/neg/NoStatic.out Tue Sep 17 08:21:11 2013 -0700 92.3 @@ -0,0 +1,3 @@ 92.4 +NoStatic.java:9:16: compiler.err.mod.not.allowed.here: static 92.5 +NoStatic.java:9:20: compiler.err.intf.meth.cant.have.body 92.6 +2 errors
93.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 93.2 +++ b/test/tools/javac/annotations/neg/NoStaticAbstract.java Tue Sep 17 08:21:11 2013 -0700 93.3 @@ -0,0 +1,10 @@ 93.4 +/* 93.5 + * @test /nodynamiccopyright/ 93.6 + * @bug 8022322 93.7 + * @summary Static methods are not allowed in an annotation. 93.8 + * @compile/fail/ref=NoStaticAbstract.out -XDrawDiagnostics NoStaticAbstract.java 93.9 + */ 93.10 + 93.11 +@interface NoStaticAbstract { 93.12 + static int m(); 93.13 +}
94.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 94.2 +++ b/test/tools/javac/annotations/neg/NoStaticAbstract.out Tue Sep 17 08:21:11 2013 -0700 94.3 @@ -0,0 +1,2 @@ 94.4 +NoStaticAbstract.java:9:16: compiler.err.mod.not.allowed.here: static 94.5 +1 error
95.1 --- a/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java Thu Sep 12 11:09:20 2013 -0700 95.2 +++ b/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java Tue Sep 17 08:21:11 2013 -0700 95.3 @@ -1,5 +1,5 @@ 95.4 /* 95.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 95.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 95.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 95.8 * 95.9 * This code is free software; you can redistribute it and/or modify it 95.10 @@ -23,6 +23,7 @@ 95.11 95.12 /* 95.13 * @test 95.14 + * @bug 7192246 95.15 * @summary check that default methods don't cause ClassReader to complete classes recursively 95.16 * @author Maurizio Cimadamore 95.17 * @compile pkg/Foo.java
96.1 --- a/test/tools/javac/defaultMethods/Neg01.java Thu Sep 12 11:09:20 2013 -0700 96.2 +++ b/test/tools/javac/defaultMethods/Neg01.java Tue Sep 17 08:21:11 2013 -0700 96.3 @@ -1,5 +1,5 @@ 96.4 -/* 96.5 - * @test /nodynamiccopyright/ 96.6 +/* @test /nodynamiccopyright/ 96.7 + * @bug 7192246 96.8 * @summary negative test for ambiguous defaults 96.9 * @compile/fail/ref=Neg01.out -XDrawDiagnostics Neg01.java 96.10 */
97.1 --- a/test/tools/javac/defaultMethods/Neg02.java Thu Sep 12 11:09:20 2013 -0700 97.2 +++ b/test/tools/javac/defaultMethods/Neg02.java Tue Sep 17 08:21:11 2013 -0700 97.3 @@ -1,5 +1,5 @@ 97.4 -/* 97.5 - * @test /nodynamiccopyright/ 97.6 +/* @test /nodynamiccopyright/ 97.7 + * @bug 7192246 97.8 * @summary check that ill-formed MI hierarchies do not compile 97.9 * @compile/fail/ref=Neg02.out -XDrawDiagnostics Neg02.java 97.10 */
98.1 --- a/test/tools/javac/defaultMethods/Neg03.java Thu Sep 12 11:09:20 2013 -0700 98.2 +++ b/test/tools/javac/defaultMethods/Neg03.java Tue Sep 17 08:21:11 2013 -0700 98.3 @@ -1,5 +1,5 @@ 98.4 -/* 98.5 - * @test /nodynamiccopyright/ 98.6 +/* @test /nodynamiccopyright/ 98.7 + * @bug 7192246 98.8 * @summary check that re-abstraction works properly 98.9 * @compile/fail/ref=Neg03.out -XDrawDiagnostics Neg03.java 98.10 */
99.1 --- a/test/tools/javac/defaultMethods/Neg04.java Thu Sep 12 11:09:20 2013 -0700 99.2 +++ b/test/tools/javac/defaultMethods/Neg04.java Tue Sep 17 08:21:11 2013 -0700 99.3 @@ -1,5 +1,5 @@ 99.4 -/* 99.5 - * @test /nodynamiccopyright/ 99.6 +/* @test /nodynamiccopyright/ 99.7 + * @bug 7192246 99.8 * @summary check that default method must have most specific return type 99.9 * @compile/fail/ref=Neg04.out -XDrawDiagnostics Neg04.java 99.10 */
100.1 --- a/test/tools/javac/defaultMethods/Neg05.java Thu Sep 12 11:09:20 2013 -0700 100.2 +++ b/test/tools/javac/defaultMethods/Neg05.java Tue Sep 17 08:21:11 2013 -0700 100.3 @@ -1,5 +1,5 @@ 100.4 -/* 100.5 - * @test /nodynamiccopyright/ 100.6 +/* @test /nodynamiccopyright/ 100.7 + * @bug 7192246 100.8 * @summary check that abstract methods are compatible with inherited defaults 100.9 * @compile/fail/ref=Neg05.out -XDrawDiagnostics Neg05.java 100.10 */
101.1 --- a/test/tools/javac/defaultMethods/Neg06.java Thu Sep 12 11:09:20 2013 -0700 101.2 +++ b/test/tools/javac/defaultMethods/Neg06.java Tue Sep 17 08:21:11 2013 -0700 101.3 @@ -1,5 +1,5 @@ 101.4 -/* 101.5 - * @test /nodynamiccopyright/ 101.6 +/* @test /nodynamiccopyright/ 101.7 + * @bug 7192246 101.8 * @summary flow analysis is not run on inlined default bodies 101.9 * @compile/fail/ref=Neg06.out -XDrawDiagnostics Neg06.java 101.10 */
102.1 --- a/test/tools/javac/defaultMethods/Neg07.java Thu Sep 12 11:09:20 2013 -0700 102.2 +++ b/test/tools/javac/defaultMethods/Neg07.java Tue Sep 17 08:21:11 2013 -0700 102.3 @@ -1,5 +1,5 @@ 102.4 -/* 102.5 - * @test /nodynamiccopyright/ 102.6 +/* @test /nodynamiccopyright/ 102.7 + * @bug 7192246 102.8 * @summary check that default overrides are properly type-checked 102.9 * @compile/fail/ref=Neg07.out -XDrawDiagnostics Neg07.java 102.10 */
103.1 --- a/test/tools/javac/defaultMethods/Neg08.java Thu Sep 12 11:09:20 2013 -0700 103.2 +++ b/test/tools/javac/defaultMethods/Neg08.java Tue Sep 17 08:21:11 2013 -0700 103.3 @@ -1,5 +1,5 @@ 103.4 -/* 103.5 - * @test /nodynamiccopyright/ 103.6 +/* @test /nodynamiccopyright/ 103.7 + * @bug 7192246 103.8 * @summary check that default overrides are properly type-checked 103.9 * @compile/fail/ref=Neg08.out -XDrawDiagnostics Neg08.java 103.10 */
104.1 --- a/test/tools/javac/defaultMethods/Neg09.java Thu Sep 12 11:09:20 2013 -0700 104.2 +++ b/test/tools/javac/defaultMethods/Neg09.java Tue Sep 17 08:21:11 2013 -0700 104.3 @@ -1,5 +1,5 @@ 104.4 -/* 104.5 - * @test /nodynamiccopyright/ 104.6 +/* @test /nodynamiccopyright/ 104.7 + * @bug 7192246 104.8 * @summary check that default overrides are properly type-checked 104.9 * @compile/fail/ref=Neg09.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg09.java 104.10 */
105.1 --- a/test/tools/javac/defaultMethods/Neg10.java Thu Sep 12 11:09:20 2013 -0700 105.2 +++ b/test/tools/javac/defaultMethods/Neg10.java Tue Sep 17 08:21:11 2013 -0700 105.3 @@ -1,5 +1,5 @@ 105.4 -/* 105.5 - * @test /nodynamiccopyright/ 105.6 +/* @test /nodynamiccopyright/ 105.7 + * @bug 7192246 105.8 * @summary check that default overrides are properly type-checked 105.9 * @compile/fail/ref=Neg10.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg10.java 105.10 */
106.1 --- a/test/tools/javac/defaultMethods/Neg11.java Thu Sep 12 11:09:20 2013 -0700 106.2 +++ b/test/tools/javac/defaultMethods/Neg11.java Tue Sep 17 08:21:11 2013 -0700 106.3 @@ -1,5 +1,5 @@ 106.4 -/* 106.5 - * @test /nodynamiccopyright/ 106.6 +/* @test /nodynamiccopyright/ 106.7 + * @bug 7192246 106.8 * @summary check that default overrides are properly type-checked 106.9 * @compile/fail/ref=Neg11.out -XDrawDiagnostics Neg11.java 106.10 */
107.1 --- a/test/tools/javac/defaultMethods/Neg12.java Thu Sep 12 11:09:20 2013 -0700 107.2 +++ b/test/tools/javac/defaultMethods/Neg12.java Tue Sep 17 08:21:11 2013 -0700 107.3 @@ -1,5 +1,5 @@ 107.4 -/* 107.5 - * @test /nodynamiccopyright/ 107.6 +/* @test /nodynamiccopyright/ 107.7 + * @bug 7192246 107.8 * @summary check that abstract methods are discarded in overload resolution diags 107.9 * @compile/fail/ref=Neg12.out -XDrawDiagnostics Neg12.java 107.10 */
108.1 --- a/test/tools/javac/defaultMethods/Neg13.java Thu Sep 12 11:09:20 2013 -0700 108.2 +++ b/test/tools/javac/defaultMethods/Neg13.java Tue Sep 17 08:21:11 2013 -0700 108.3 @@ -1,5 +1,5 @@ 108.4 -/* 108.5 - * @test /nodynamiccopyright/ 108.6 +/* @test /nodynamiccopyright/ 108.7 + * @bug 7192246 108.8 * @summary check that default method overriding object members are flagged as error 108.9 * @compile/fail/ref=Neg13.out -XDrawDiagnostics Neg13.java 108.10 */
109.1 --- a/test/tools/javac/defaultMethods/Neg14.java Thu Sep 12 11:09:20 2013 -0700 109.2 +++ b/test/tools/javac/defaultMethods/Neg14.java Tue Sep 17 08:21:11 2013 -0700 109.3 @@ -1,5 +1,5 @@ 109.4 -/* 109.5 - * @test /nodynamiccopyright/ 109.6 +/* @test /nodynamiccopyright/ 109.7 + * @bug 7192246 109.8 * @summary check that a class cannot have two sibling interfaces with a default and abstract method 109.9 * @compile/fail/ref=Neg14.out -XDrawDiagnostics Neg14.java 109.10 */
110.1 --- a/test/tools/javac/defaultMethods/Neg15.java Thu Sep 12 11:09:20 2013 -0700 110.2 +++ b/test/tools/javac/defaultMethods/Neg15.java Tue Sep 17 08:21:11 2013 -0700 110.3 @@ -1,5 +1,5 @@ 110.4 -/* 110.5 - * @test /nodynamiccopyright/ 110.6 +/* @test /nodynamiccopyright/ 110.7 + * @bug 7192246 110.8 * @summary check that level skipping in default super calls is correctly rejected 110.9 * @compile/fail/ref=Neg15.out -XDrawDiagnostics Neg15.java 110.10 */
111.1 --- a/test/tools/javac/defaultMethods/Neg16.java Thu Sep 12 11:09:20 2013 -0700 111.2 +++ b/test/tools/javac/defaultMethods/Neg16.java Tue Sep 17 08:21:11 2013 -0700 111.3 @@ -1,5 +1,5 @@ 111.4 -/* 111.5 - * @test /nodynamiccopyright/ 111.6 +/* @test /nodynamiccopyright/ 111.7 + * @bug 7192246 111.8 * @summary check that level skipping in default super calls is correctly rejected 111.9 * @compile/fail/ref=Neg16.out -XDrawDiagnostics Neg16.java 111.10 */
112.1 --- a/test/tools/javac/defaultMethods/Pos01.java Thu Sep 12 11:09:20 2013 -0700 112.2 +++ b/test/tools/javac/defaultMethods/Pos01.java Tue Sep 17 08:21:11 2013 -0700 112.3 @@ -1,5 +1,5 @@ 112.4 /* 112.5 - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 112.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 112.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 112.8 * 112.9 * This code is free software; you can redistribute it and/or modify it 112.10 @@ -23,6 +23,7 @@ 112.11 112.12 /* 112.13 * @test 112.14 + * @bug 7192246 112.15 * @summary basic test for default methods 112.16 * @author Maurizio Cimadamore 112.17 */
113.1 --- a/test/tools/javac/defaultMethods/Pos02.java Thu Sep 12 11:09:20 2013 -0700 113.2 +++ b/test/tools/javac/defaultMethods/Pos02.java Tue Sep 17 08:21:11 2013 -0700 113.3 @@ -1,5 +1,5 @@ 113.4 /* 113.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 113.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 113.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 113.8 * 113.9 * This code is free software; you can redistribute it and/or modify it 113.10 @@ -23,6 +23,7 @@ 113.11 113.12 /* 113.13 * @test 113.14 + * @bug 7192246 113.15 * @summary test for explicit resolution of ambiguous default methods 113.16 * @author Maurizio Cimadamore 113.17 * @compile Pos02.java
114.1 --- a/test/tools/javac/defaultMethods/Pos04.java Thu Sep 12 11:09:20 2013 -0700 114.2 +++ b/test/tools/javac/defaultMethods/Pos04.java Tue Sep 17 08:21:11 2013 -0700 114.3 @@ -1,5 +1,5 @@ 114.4 /* 114.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 114.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 114.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 114.8 * 114.9 * This code is free software; you can redistribute it and/or modify it 114.10 @@ -23,6 +23,7 @@ 114.11 114.12 /* 114.13 * @test 114.14 + * @bug 7192246 114.15 * @summary test for overriding with default method 114.16 * @author Maurizio Cimadamore 114.17 * @compile Pos04.java
115.1 --- a/test/tools/javac/defaultMethods/Pos05.java Thu Sep 12 11:09:20 2013 -0700 115.2 +++ b/test/tools/javac/defaultMethods/Pos05.java Tue Sep 17 08:21:11 2013 -0700 115.3 @@ -1,5 +1,5 @@ 115.4 /* 115.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 115.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 115.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 115.8 * 115.9 * This code is free software; you can redistribute it and/or modify it 115.10 @@ -23,6 +23,7 @@ 115.11 115.12 /* 115.13 * @test 115.14 + * @bug 7192246 115.15 * @summary check that indirectly inherited default methods are discovered during resolution 115.16 * @author Maurizio Cimadamore 115.17 * @compile Pos05.java
116.1 --- a/test/tools/javac/defaultMethods/Pos06.java Thu Sep 12 11:09:20 2013 -0700 116.2 +++ b/test/tools/javac/defaultMethods/Pos06.java Tue Sep 17 08:21:11 2013 -0700 116.3 @@ -1,5 +1,5 @@ 116.4 /* 116.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 116.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 116.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 116.8 * 116.9 * This code is free software; you can redistribute it and/or modify it 116.10 @@ -23,6 +23,7 @@ 116.11 116.12 /* 116.13 * @test 116.14 + * @bug 7192246 116.15 * @summary check that well-formed MI hierarchies behaves well w.r.t. method resolution (i.e. no ambiguities) 116.16 * @author Maurizio Cimadamore 116.17 * @compile Pos06.java
117.1 --- a/test/tools/javac/defaultMethods/Pos07.java Thu Sep 12 11:09:20 2013 -0700 117.2 +++ b/test/tools/javac/defaultMethods/Pos07.java Tue Sep 17 08:21:11 2013 -0700 117.3 @@ -1,5 +1,5 @@ 117.4 /* 117.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 117.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 117.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 117.8 * 117.9 * This code is free software; you can redistribute it and/or modify it 117.10 @@ -23,6 +23,7 @@ 117.11 117.12 /* 117.13 * @test 117.14 + * @bug 7192246 117.15 * @summary check that compilation order does not matter 117.16 * @author Maurizio Cimadamore 117.17 * @compile Pos07.java
118.1 --- a/test/tools/javac/defaultMethods/Pos08.java Thu Sep 12 11:09:20 2013 -0700 118.2 +++ b/test/tools/javac/defaultMethods/Pos08.java Tue Sep 17 08:21:11 2013 -0700 118.3 @@ -1,5 +1,5 @@ 118.4 /* 118.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 118.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 118.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 118.8 * 118.9 * This code is free software; you can redistribute it and/or modify it 118.10 @@ -23,6 +23,7 @@ 118.11 118.12 /* 118.13 * @test 118.14 + * @bug 7192246 118.15 * @summary check that common overrider solves default method conflicts 118.16 * @author Maurizio Cimadamore 118.17 * @compile Pos08.java
119.1 --- a/test/tools/javac/defaultMethods/Pos10.java Thu Sep 12 11:09:20 2013 -0700 119.2 +++ b/test/tools/javac/defaultMethods/Pos10.java Tue Sep 17 08:21:11 2013 -0700 119.3 @@ -1,5 +1,5 @@ 119.4 /* 119.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 119.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 119.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 119.8 * 119.9 * This code is free software; you can redistribute it and/or modify it 119.10 @@ -23,6 +23,7 @@ 119.11 119.12 /* 119.13 * @test 119.14 + * @bug 7192246 119.15 * @summary check that type-variables in generic extension decl can be accessed from default impl 119.16 * @author Maurizio Cimadamore 119.17 * @compile Pos10.java
120.1 --- a/test/tools/javac/defaultMethods/Pos11.java Thu Sep 12 11:09:20 2013 -0700 120.2 +++ b/test/tools/javac/defaultMethods/Pos11.java Tue Sep 17 08:21:11 2013 -0700 120.3 @@ -1,5 +1,5 @@ 120.4 /* 120.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 120.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 120.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 120.8 * 120.9 * This code is free software; you can redistribute it and/or modify it 120.10 @@ -23,6 +23,7 @@ 120.11 120.12 /* 120.13 * @test 120.14 + * @bug 7192246 120.15 * @summary complex test with conflict resolution via overriding 120.16 * @author Brian Goetz 120.17 * @compile Pos11.java
121.1 --- a/test/tools/javac/defaultMethods/Pos12.java Thu Sep 12 11:09:20 2013 -0700 121.2 +++ b/test/tools/javac/defaultMethods/Pos12.java Tue Sep 17 08:21:11 2013 -0700 121.3 @@ -1,5 +1,5 @@ 121.4 /* 121.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 121.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 121.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 121.8 * 121.9 * This code is free software; you can redistribute it and/or modify it 121.10 @@ -23,6 +23,7 @@ 121.11 121.12 /* 121.13 * @test 121.14 + * @bug 7192246 121.15 * @summary check that 'this' can be used from within an extension method 121.16 * @compile Pos12.java 121.17 */
122.1 --- a/test/tools/javac/defaultMethods/Pos13.java Thu Sep 12 11:09:20 2013 -0700 122.2 +++ b/test/tools/javac/defaultMethods/Pos13.java Tue Sep 17 08:21:11 2013 -0700 122.3 @@ -1,5 +1,5 @@ 122.4 /* 122.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 122.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 122.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 122.8 * 122.9 * This code is free software; you can redistribute it and/or modify it 122.10 @@ -23,6 +23,7 @@ 122.11 122.12 /* 122.13 * @test 122.14 + * @bug 7192246 122.15 * @summary qualified 'this' inside default method causes StackOverflowException 122.16 * @compile Pos13.java 122.17 */
123.1 --- a/test/tools/javac/defaultMethods/Pos14.java Thu Sep 12 11:09:20 2013 -0700 123.2 +++ b/test/tools/javac/defaultMethods/Pos14.java Tue Sep 17 08:21:11 2013 -0700 123.3 @@ -1,5 +1,5 @@ 123.4 /* 123.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 123.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 123.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 123.8 * 123.9 * This code is free software; you can redistribute it and/or modify it 123.10 @@ -23,6 +23,7 @@ 123.11 123.12 /* 123.13 * @test 123.14 + * @bug 7192246 123.15 * @summary check that overload resolution selects most specific signature 123.16 * @compile Pos14.java 123.17 */
124.1 --- a/test/tools/javac/defaultMethods/Pos15.java Thu Sep 12 11:09:20 2013 -0700 124.2 +++ b/test/tools/javac/defaultMethods/Pos15.java Tue Sep 17 08:21:11 2013 -0700 124.3 @@ -1,5 +1,5 @@ 124.4 /* 124.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 124.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 124.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 124.8 * 124.9 * This code is free software; you can redistribute it and/or modify it 124.10 @@ -23,6 +23,7 @@ 124.11 124.12 /* 124.13 * @test 124.14 + * @bug 7192246 124.15 * @summary check that overload resolution selects most specific signature 124.16 * @compile Pos15.java 124.17 */
125.1 --- a/test/tools/javac/defaultMethods/Pos16.java Thu Sep 12 11:09:20 2013 -0700 125.2 +++ b/test/tools/javac/defaultMethods/Pos16.java Tue Sep 17 08:21:11 2013 -0700 125.3 @@ -1,5 +1,5 @@ 125.4 /* 125.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 125.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 125.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 125.8 * 125.9 * This code is free software; you can redistribute it and/or modify it 125.10 @@ -23,6 +23,7 @@ 125.11 125.12 /* 125.13 * @test 125.14 + * @bug 7192246 125.15 * @summary 'class wins' should not short-circuit overload resolution 125.16 * @compile Pos16.java 125.17 */
126.1 --- a/test/tools/javac/defaultMethods/TestDefaultBody.java Thu Sep 12 11:09:20 2013 -0700 126.2 +++ b/test/tools/javac/defaultMethods/TestDefaultBody.java Tue Sep 17 08:21:11 2013 -0700 126.3 @@ -1,5 +1,5 @@ 126.4 /* 126.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 126.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 126.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 126.8 * 126.9 * This code is free software; you can redistribute it and/or modify it 126.10 @@ -23,6 +23,7 @@ 126.11 126.12 /* 126.13 * @test 126.14 + * @bug 7192246 126.15 * @summary check that code attributed for default methods is correctly generated 126.16 */ 126.17
127.1 --- a/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java Thu Sep 12 11:09:20 2013 -0700 127.2 +++ b/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java Tue Sep 17 08:21:11 2013 -0700 127.3 @@ -1,5 +1,5 @@ 127.4 /* 127.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 127.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 127.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 127.8 * 127.9 * This code is free software; you can redistribute it and/or modify it 127.10 @@ -23,6 +23,7 @@ 127.11 127.12 /* 127.13 * @test 127.14 + * @bug 7192246 127.15 * @summary check that javac does not generate bridge methods for defaults 127.16 */ 127.17
128.1 --- a/test/tools/javac/defaultMethods/crossCompile/CrossCompile.java Thu Sep 12 11:09:20 2013 -0700 128.2 +++ b/test/tools/javac/defaultMethods/crossCompile/CrossCompile.java Tue Sep 17 08:21:11 2013 -0700 128.3 @@ -1,5 +1,5 @@ 128.4 /* 128.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 128.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 128.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 128.8 * 128.9 * This code is free software; you can redistribute it and/or modify it 128.10 @@ -23,6 +23,7 @@ 128.11 128.12 /* 128.13 * @test 128.14 + * @bug 7192246 128.15 * @summary check that clinit in interface doesn't cause spurious default method diagnostics 128.16 * @compile -source 1.4 -target 1.4 Clinit.java 128.17 * @compile CrossCompile.java
129.1 --- a/test/tools/javac/defaultMethods/separate/Separate.java Thu Sep 12 11:09:20 2013 -0700 129.2 +++ b/test/tools/javac/defaultMethods/separate/Separate.java Tue Sep 17 08:21:11 2013 -0700 129.3 @@ -1,5 +1,5 @@ 129.4 /* 129.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 129.6 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 129.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 129.8 * 129.9 * This code is free software; you can redistribute it and/or modify it 129.10 @@ -23,6 +23,7 @@ 129.11 129.12 /* 129.13 * @test 129.14 + * @bug 7192246 129.15 * @summary smoke test for separate compilation of default methods 129.16 * @author Maurizio Cimadamore 129.17 * @compile pkg1/A.java
130.1 --- a/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java Thu Sep 12 11:09:20 2013 -0700 130.2 +++ b/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java Tue Sep 17 08:21:11 2013 -0700 130.3 @@ -23,7 +23,7 @@ 130.4 130.5 /* 130.6 * @test 130.7 - * @bug 8006694 130.8 + * @bug 7192246 8006694 130.9 * @summary Automatic test for checking correctness of default super/this resolution 130.10 * temporarily workaround combo tests are causing time out in several platforms 130.11 * @library ../../lib
131.1 --- a/test/tools/javac/depDocComment/SuppressDeprecation.out Thu Sep 12 11:09:20 2013 -0700 131.2 +++ b/test/tools/javac/depDocComment/SuppressDeprecation.out Tue Sep 17 08:21:11 2013 -0700 131.3 @@ -1,8 +1,8 @@ 131.4 -SuppressDeprecation.java:130:17: compiler.warn.has.been.deprecated: X, compiler.misc.unnamed.package 131.5 SuppressDeprecation.java:82:10: compiler.warn.has.been.deprecated: g(), T 131.6 SuppressDeprecation.java:83:14: compiler.warn.has.been.deprecated: g(), T 131.7 SuppressDeprecation.java:84:9: compiler.warn.has.been.deprecated: var, T 131.8 SuppressDeprecation.java:87:9: compiler.warn.has.been.deprecated: T(), T 131.9 SuppressDeprecation.java:90:9: compiler.warn.has.been.deprecated: T(int), T 131.10 SuppressDeprecation.java:98:1: compiler.warn.has.been.deprecated: T(), T 131.11 +SuppressDeprecation.java:130:17: compiler.warn.has.been.deprecated: X, compiler.misc.unnamed.package 131.12 7 warnings
132.1 --- a/test/tools/javac/diags/examples/BadArgTypesInLambda.java Thu Sep 12 11:09:20 2013 -0700 132.2 +++ b/test/tools/javac/diags/examples/BadArgTypesInLambda.java Tue Sep 17 08:21:11 2013 -0700 132.3 @@ -21,9 +21,6 @@ 132.4 * questions. 132.5 */ 132.6 132.7 -// key: compiler.err.cant.apply.symbol 132.8 -// key: compiler.misc.no.conforming.assignment.exists 132.9 -// key: compiler.misc.bad.arg.types.in.lambda 132.10 // key: compiler.err.prob.found.req 132.11 // key: compiler.misc.inconvertible.types 132.12 // options: -Xdiags:verbose
133.1 --- a/test/tools/javac/diags/examples/CyclicInference.java Thu Sep 12 11:09:20 2013 -0700 133.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 133.3 @@ -1,37 +0,0 @@ 133.4 -/* 133.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 133.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 133.7 - * 133.8 - * This code is free software; you can redistribute it and/or modify it 133.9 - * under the terms of the GNU General Public License version 2 only, as 133.10 - * published by the Free Software Foundation. 133.11 - * 133.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 133.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 133.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 133.15 - * version 2 for more details (a copy is included in the LICENSE file that 133.16 - * accompanied this code). 133.17 - * 133.18 - * You should have received a copy of the GNU General Public License version 133.19 - * 2 along with this work; if not, write to the Free Software Foundation, 133.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 133.21 - * 133.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 133.23 - * or visit www.oracle.com if you need additional information or have any 133.24 - * questions. 133.25 - */ 133.26 - 133.27 -// key: compiler.err.prob.found.req 133.28 -// key: compiler.misc.cyclic.inference 133.29 - 133.30 -class CyclicInference { 133.31 - interface SAM<X> { 133.32 - void m(X x); 133.33 - } 133.34 - 133.35 - <Z> void g(SAM<Z> sz) { } 133.36 - 133.37 - void test() { 133.38 - g(x-> {}); 133.39 - } 133.40 -}
134.1 --- a/test/tools/javac/diags/examples/IncompatibleArgTypesInMethodRef.java Thu Sep 12 11:09:20 2013 -0700 134.2 +++ b/test/tools/javac/diags/examples/IncompatibleArgTypesInMethodRef.java Tue Sep 17 08:21:11 2013 -0700 134.3 @@ -31,6 +31,7 @@ 134.4 } 134.5 134.6 void g(String s, Integer i) { } 134.7 + void g(Integer i, String s) { } 134.8 134.9 <Z> void m(SAM<Z> s) { } 134.10
135.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 135.2 +++ b/test/tools/javac/diags/examples/MrefInferAndExplicitParams.java Tue Sep 17 08:21:11 2013 -0700 135.3 @@ -0,0 +1,35 @@ 135.4 +/* 135.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 135.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 135.7 + * 135.8 + * This code is free software; you can redistribute it and/or modify it 135.9 + * under the terms of the GNU General Public License version 2 only, as 135.10 + * published by the Free Software Foundation. 135.11 + * 135.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 135.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 135.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 135.15 + * version 2 for more details (a copy is included in the LICENSE file that 135.16 + * accompanied this code). 135.17 + * 135.18 + * You should have received a copy of the GNU General Public License version 135.19 + * 2 along with this work; if not, write to the Free Software Foundation, 135.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 135.21 + * 135.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 135.23 + * or visit www.oracle.com if you need additional information or have any 135.24 + * questions. 135.25 + */ 135.26 + 135.27 +// key: compiler.err.invalid.mref 135.28 +// key: compiler.misc.mref.infer.and.explicit.params 135.29 + 135.30 +public class MrefInferAndExplicitParams { 135.31 + static class Foo<X> {} 135.32 + 135.33 + interface Supplier<X> { 135.34 + X make(); 135.35 + } 135.36 + 135.37 + Supplier<Foo<String>> sfs = Foo::<Number>new; 135.38 +}
136.1 --- a/test/tools/javac/diags/examples/MrefStat.java.rej Thu Sep 12 11:09:20 2013 -0700 136.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 136.3 @@ -1,34 +0,0 @@ 136.4 ---- MrefStat.java 136.5 -+++ MrefStat.java 136.6 -@@ -0,0 +1,31 @@ 136.7 -+/* 136.8 -+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 136.9 -+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 136.10 -+ * 136.11 -+ * This code is free software; you can redistribute it and/or modify it 136.12 -+ * under the terms of the GNU General Public License version 2 only, as 136.13 -+ * published by the Free Software Foundation. 136.14 -+ * 136.15 -+ * This code is distributed in the hope that it will be useful, but WITHOUT 136.16 -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 136.17 -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 136.18 -+ * version 2 for more details (a copy is included in the LICENSE file that 136.19 -+ * accompanied this code). 136.20 -+ * 136.21 -+ * You should have received a copy of the GNU General Public License version 136.22 -+ * 2 along with this work; if not, write to the Free Software Foundation, 136.23 -+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 136.24 -+ * 136.25 -+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 136.26 -+ * or visit www.oracle.com if you need additional information or have any 136.27 -+ * questions. 136.28 -+ */ 136.29 -+ 136.30 -+// key: compiler.note.mref.stat 136.31 -+// options: -XDdumpLambdaToMethodStats 136.32 -+ 136.33 -+class MrefStat { 136.34 -+ Runnable r = MrefStat::m; 136.35 -+ 136.36 -+ static void m() { } 136.37 -+}
137.1 --- a/test/tools/javac/diags/examples/MrefStat1.java.rej Thu Sep 12 11:09:20 2013 -0700 137.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 137.3 @@ -1,37 +0,0 @@ 137.4 ---- MrefStat1.java 137.5 -+++ MrefStat1.java 137.6 -@@ -0,0 +1,34 @@ 137.7 -+/* 137.8 -+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 137.9 -+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 137.10 -+ * 137.11 -+ * This code is free software; you can redistribute it and/or modify it 137.12 -+ * under the terms of the GNU General Public License version 2 only, as 137.13 -+ * published by the Free Software Foundation. 137.14 -+ * 137.15 -+ * This code is distributed in the hope that it will be useful, but WITHOUT 137.16 -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 137.17 -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 137.18 -+ * version 2 for more details (a copy is included in the LICENSE file that 137.19 -+ * accompanied this code). 137.20 -+ * 137.21 -+ * You should have received a copy of the GNU General Public License version 137.22 -+ * 2 along with this work; if not, write to the Free Software Foundation, 137.23 -+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 137.24 -+ * 137.25 -+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 137.26 -+ * or visit www.oracle.com if you need additional information or have any 137.27 -+ * questions. 137.28 -+ */ 137.29 -+ 137.30 -+// key: compiler.note.mref.stat.1 137.31 -+// options: -XDdumpLambdaToMethodStats 137.32 -+ 137.33 -+class MrefStat1 { 137.34 -+ 137.35 -+ void m() { } 137.36 -+ 137.37 -+ static class Sub extends MrefStat1 { 137.38 -+ Runnable r = super::m; 137.39 -+ } 137.40 -+}
138.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 138.2 +++ b/test/tools/javac/diags/examples/PotentiallyAmbiguousOverload.java Tue Sep 17 08:21:11 2013 -0700 138.3 @@ -0,0 +1,38 @@ 138.4 +/* 138.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 138.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 138.7 + * 138.8 + * This code is free software; you can redistribute it and/or modify it 138.9 + * under the terms of the GNU General Public License version 2 only, as 138.10 + * published by the Free Software Foundation. 138.11 + * 138.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 138.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 138.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 138.15 + * version 2 for more details (a copy is included in the LICENSE file that 138.16 + * accompanied this code). 138.17 + * 138.18 + * You should have received a copy of the GNU General Public License version 138.19 + * 2 along with this work; if not, write to the Free Software Foundation, 138.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 138.21 + * 138.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 138.23 + * or visit www.oracle.com if you need additional information or have any 138.24 + * questions. 138.25 + */ 138.26 + 138.27 +// key: compiler.warn.potentially.ambiguous.overload 138.28 +// options: -Xlint:overloads 138.29 + 138.30 +class PotentiallyAmbiguousOverload { 138.31 + interface F1 { 138.32 + void m(String s); 138.33 + } 138.34 + 138.35 + interface F2 { 138.36 + void m(Integer s); 138.37 + } 138.38 + 138.39 + void m(F1 f1) { } 138.40 + void m(F2 f2) { } 138.41 +}
139.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 139.2 +++ b/test/tools/javac/flow/AliveRanges.java Tue Sep 17 08:21:11 2013 -0700 139.3 @@ -0,0 +1,34 @@ 139.4 +/* 139.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 139.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 139.7 + * 139.8 + * This code is free software; you can redistribute it and/or modify it 139.9 + * under the terms of the GNU General Public License version 2 only, as 139.10 + * published by the Free Software Foundation. 139.11 + * 139.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 139.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 139.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 139.15 + * version 2 for more details (a copy is included in the LICENSE file that 139.16 + * accompanied this code). 139.17 + * 139.18 + * You should have received a copy of the GNU General Public License version 139.19 + * 2 along with this work; if not, write to the Free Software Foundation, 139.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 139.21 + * 139.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 139.23 + * or visit www.oracle.com if you need additional information or have any 139.24 + * questions. 139.25 + */ 139.26 +import java.lang.annotation.*; 139.27 + 139.28 +@Repeatable(AliveRanges.class) 139.29 +@Target({ElementType.METHOD}) 139.30 +@interface AliveRange { 139.31 + String varName(); 139.32 + int bytecodeStart(); 139.33 + int bytecodeLength(); 139.34 +} 139.35 + 139.36 +@Target({ElementType.METHOD}) 139.37 +@interface AliveRanges {AliveRange[] value();}
140.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 140.2 +++ b/test/tools/javac/flow/LVTHarness.java Tue Sep 17 08:21:11 2013 -0700 140.3 @@ -0,0 +1,280 @@ 140.4 +/* 140.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 140.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 140.7 + * 140.8 + * This code is free software; you can redistribute it and/or modify it 140.9 + * under the terms of the GNU General Public License version 2 only, as 140.10 + * published by the Free Software Foundation. 140.11 + * 140.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 140.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 140.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 140.15 + * version 2 for more details (a copy is included in the LICENSE file that 140.16 + * accompanied this code). 140.17 + * 140.18 + * You should have received a copy of the GNU General Public License version 140.19 + * 2 along with this work; if not, write to the Free Software Foundation, 140.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 140.21 + * 140.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 140.23 + * or visit www.oracle.com if you need additional information or have any 140.24 + * questions. 140.25 + */ 140.26 + 140.27 +/* 140.28 + * @test 140.29 + * @bug 7047734 140.30 + * @summary The LVT is not generated correctly during some try/catch scenarios 140.31 + * @library /tools/javac/lib 140.32 + * @build JavacTestingAbstractProcessor LVTHarness 140.33 + * @run main LVTHarness 140.34 + */ 140.35 + 140.36 +import java.io.File; 140.37 +import java.io.IOException; 140.38 +import java.lang.annotation.Annotation; 140.39 +import java.util.Set; 140.40 +import java.util.Arrays; 140.41 +import java.util.ArrayList; 140.42 +import java.util.Collections; 140.43 +import java.util.HashMap; 140.44 +import java.util.HashSet; 140.45 +import java.util.List; 140.46 +import java.util.Map; 140.47 + 140.48 +import javax.annotation.processing.RoundEnvironment; 140.49 +import javax.lang.model.element.Element; 140.50 +import javax.lang.model.element.TypeElement; 140.51 +import javax.tools.JavaCompiler; 140.52 +import javax.tools.JavaFileObject; 140.53 +import javax.tools.StandardJavaFileManager; 140.54 +import javax.tools.ToolProvider; 140.55 + 140.56 +import com.sun.source.util.JavacTask; 140.57 +import com.sun.tools.classfile.Attribute; 140.58 +import com.sun.tools.classfile.ClassFile; 140.59 +import com.sun.tools.classfile.ConstantPool; 140.60 +import com.sun.tools.classfile.ConstantPoolException; 140.61 +import com.sun.tools.classfile.Code_attribute; 140.62 +import com.sun.tools.classfile.ConstantPool.InvalidIndex; 140.63 +import com.sun.tools.classfile.ConstantPool.UnexpectedEntry; 140.64 +import com.sun.tools.classfile.Descriptor.InvalidDescriptor; 140.65 +import com.sun.tools.classfile.LocalVariableTable_attribute; 140.66 +import com.sun.tools.classfile.Method; 140.67 + 140.68 +import static javax.tools.StandardLocation.*; 140.69 +import static com.sun.tools.classfile.LocalVariableTable_attribute.Entry; 140.70 + 140.71 +public class LVTHarness { 140.72 + 140.73 + static int nerrors = 0; 140.74 + 140.75 + static final JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); 140.76 + static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); 140.77 + 140.78 + public static void main(String[] args) throws Exception { 140.79 + fm.setLocation(SOURCE_PATH, 140.80 + Arrays.asList(new File(System.getProperty("test.src"), "tests"))); 140.81 + for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", 140.82 + Collections.singleton(JavaFileObject.Kind.SOURCE), true)) { 140.83 + new LVTHarness(jfo).check(); 140.84 + } 140.85 + if (nerrors > 0) { 140.86 + throw new AssertionError("Errors were found"); 140.87 + } 140.88 + } 140.89 + 140.90 + 140.91 + JavaFileObject jfo; 140.92 + Map<ElementKey, AliveRanges> aliveRangeMap = 140.93 + new HashMap<ElementKey, AliveRanges>(); 140.94 + Set<String> declaredKeys = new HashSet<>(); 140.95 + List<ElementKey> seenAliveRanges = new ArrayList<>(); 140.96 + 140.97 + protected LVTHarness(JavaFileObject jfo) { 140.98 + this.jfo = jfo; 140.99 + } 140.100 + 140.101 + protected void check() throws Exception { 140.102 + JavacTask ct = (JavacTask)comp.getTask(null, fm, null, Arrays.asList("-g"), 140.103 + null, Arrays.asList(jfo)); 140.104 + System.err.println("compiling code " + jfo.toString()); 140.105 + ct.setProcessors(Collections.singleton(new AliveRangeFinder())); 140.106 + if (!ct.call()) { 140.107 + throw new AssertionError("Error during compilation"); 140.108 + } 140.109 + 140.110 + checkClassFile(new File(jfo.getName().replace(".java", ".class"))); 140.111 + 140.112 + //check all candidates have been used up 140.113 + for (Map.Entry<ElementKey, AliveRanges> entry : aliveRangeMap.entrySet()) { 140.114 + if (!seenAliveRanges.contains(entry.getKey())) { 140.115 + error("Redundant @AliveRanges annotation on method " + 140.116 + entry.getKey().elem); 140.117 + } 140.118 + } 140.119 + } 140.120 + 140.121 + void checkClassFile(File file) 140.122 + throws IOException, ConstantPoolException, InvalidDescriptor { 140.123 + ClassFile classFile = ClassFile.read(file); 140.124 + ConstantPool constantPool = classFile.constant_pool; 140.125 + 140.126 + //lets get all the methods in the class file. 140.127 + for (Method method : classFile.methods) { 140.128 + for (ElementKey elementKey: aliveRangeMap.keySet()) { 140.129 + String methodDesc = method.getName(constantPool) + 140.130 + method.descriptor.getParameterTypes(constantPool); 140.131 + if (methodDesc.equals(elementKey.elem.toString())) { 140.132 + checkMethod(constantPool, method, aliveRangeMap.get(elementKey)); 140.133 + seenAliveRanges.add(elementKey); 140.134 + } 140.135 + } 140.136 + } 140.137 + } 140.138 + 140.139 + void checkMethod(ConstantPool constantPool, Method method, AliveRanges ranges) 140.140 + throws InvalidIndex, UnexpectedEntry { 140.141 + Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code); 140.142 + LocalVariableTable_attribute lvt = 140.143 + (LocalVariableTable_attribute) (code.attributes.get(Attribute.LocalVariableTable)); 140.144 + List<String> infoFromRanges = convertToStringList(ranges); 140.145 + List<String> infoFromLVT = convertToStringList(constantPool, lvt); 140.146 + 140.147 + // infoFromRanges most be contained in infoFromLVT 140.148 + int i = 0; 140.149 + int j = 0; 140.150 + while (i < infoFromRanges.size() && j < infoFromLVT.size()) { 140.151 + int comparison = infoFromRanges.get(i).compareTo(infoFromLVT.get(j)); 140.152 + if (comparison == 0) { 140.153 + i++; j++; 140.154 + } else if (comparison > 0) { 140.155 + j++; 140.156 + } else { 140.157 + break; 140.158 + } 140.159 + } 140.160 + 140.161 + if (i < infoFromRanges.size()) { 140.162 + error(infoFromLVT, infoFromRanges); 140.163 + } 140.164 + } 140.165 + 140.166 + List<String> convertToStringList(AliveRanges ranges) { 140.167 + List<String> result = new ArrayList<>(); 140.168 + for (Annotation anno : ranges.value()) { 140.169 + AliveRange range = (AliveRange)anno; 140.170 + String str = formatLocalVariableData(range.varName(), 140.171 + range.bytecodeStart(), range.bytecodeLength()); 140.172 + result.add(str); 140.173 + } 140.174 + Collections.sort(result); 140.175 + return result; 140.176 + } 140.177 + 140.178 + List<String> convertToStringList(ConstantPool constantPool, 140.179 + LocalVariableTable_attribute lvt) throws InvalidIndex, UnexpectedEntry { 140.180 + List<String> result = new ArrayList<>(); 140.181 + for (Entry entry : lvt.local_variable_table) { 140.182 + String str = formatLocalVariableData(constantPool.getUTF8Value(entry.name_index), 140.183 + entry.start_pc, entry.length); 140.184 + result.add(str); 140.185 + } 140.186 + Collections.sort(result); 140.187 + return result; 140.188 + } 140.189 + 140.190 + String formatLocalVariableData(String varName, int start, int length) { 140.191 + StringBuilder sb = new StringBuilder() 140.192 + .append("var name: ").append(varName) 140.193 + .append(" start: ").append(start) 140.194 + .append(" length: ").append(length); 140.195 + return sb.toString(); 140.196 + } 140.197 + 140.198 + protected void error(List<String> infoFromLVT, List<String> infoFromRanges) { 140.199 + nerrors++; 140.200 + System.err.printf("Error occurred while checking file: %s\n", jfo.getName()); 140.201 + System.err.println("The range info from the annotations is"); 140.202 + printStringListToErrOutput(infoFromRanges); 140.203 + System.err.println(); 140.204 + System.err.println("And the range info from the class file is"); 140.205 + printStringListToErrOutput(infoFromLVT); 140.206 + System.err.println(); 140.207 + } 140.208 + 140.209 + void printStringListToErrOutput(List<String> list) { 140.210 + for (String s : list) { 140.211 + System.err.println("\t" + s); 140.212 + } 140.213 + } 140.214 + 140.215 + protected void error(String msg) { 140.216 + nerrors++; 140.217 + System.err.printf("Error occurred while checking file: %s\nreason: %s\n", 140.218 + jfo.getName(), msg); 140.219 + } 140.220 + 140.221 + class AliveRangeFinder extends JavacTestingAbstractProcessor { 140.222 + 140.223 + @Override 140.224 + public boolean process(Set<? extends TypeElement> annotations, 140.225 + RoundEnvironment roundEnv) { 140.226 + if (roundEnv.processingOver()) 140.227 + return true; 140.228 + 140.229 + TypeElement aliveRangeAnno = elements.getTypeElement("AliveRanges"); 140.230 + 140.231 + if (!annotations.contains(aliveRangeAnno)) { 140.232 + error("no @AliveRanges annotation found in test class"); 140.233 + } 140.234 + 140.235 + for (Element elem: roundEnv.getElementsAnnotatedWith(aliveRangeAnno)) { 140.236 + Annotation annotation = elem.getAnnotation(AliveRanges.class); 140.237 + aliveRangeMap.put(new ElementKey(elem), (AliveRanges)annotation); 140.238 + } 140.239 + return true; 140.240 + } 140.241 + } 140.242 + 140.243 + class ElementKey { 140.244 + 140.245 + String key; 140.246 + Element elem; 140.247 + 140.248 + public ElementKey(Element elem) { 140.249 + this.elem = elem; 140.250 + this.key = computeKey(elem); 140.251 + } 140.252 + 140.253 + @Override 140.254 + public boolean equals(Object obj) { 140.255 + if (obj instanceof ElementKey) { 140.256 + ElementKey other = (ElementKey)obj; 140.257 + return other.key.equals(key); 140.258 + } 140.259 + return false; 140.260 + } 140.261 + 140.262 + @Override 140.263 + public int hashCode() { 140.264 + return key.hashCode(); 140.265 + } 140.266 + 140.267 + String computeKey(Element e) { 140.268 + StringBuilder buf = new StringBuilder(); 140.269 + while (e != null) { 140.270 + buf.append(e.toString()); 140.271 + e = e.getEnclosingElement(); 140.272 + } 140.273 + buf.append(jfo.getName()); 140.274 + return buf.toString(); 140.275 + } 140.276 + 140.277 + @Override 140.278 + public String toString() { 140.279 + return "Key{" + key + "}"; 140.280 + } 140.281 + } 140.282 + 140.283 +}
141.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 141.2 +++ b/test/tools/javac/flow/tests/TestCaseConditional.java Tue Sep 17 08:21:11 2013 -0700 141.3 @@ -0,0 +1,16 @@ 141.4 +/* /nodynamiccopyright/ */ 141.5 + 141.6 +public class TestCaseConditional { 141.7 + 141.8 + @AliveRange(varName="o", bytecodeStart=5, bytecodeLength=33) 141.9 + @AliveRange(varName="oo", bytecodeStart=23, bytecodeLength=15) 141.10 + void m(String[] args) { 141.11 + Boolean o; 141.12 + Boolean oo = ((o = Boolean.TRUE).booleanValue()) ? 141.13 + o = Boolean.TRUE : 141.14 + Boolean.FALSE; 141.15 + oo.hashCode(); 141.16 + o = Boolean.FALSE; 141.17 + o.hashCode(); 141.18 + } 141.19 +}
142.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 142.2 +++ b/test/tools/javac/flow/tests/TestCaseDoLoop.java Tue Sep 17 08:21:11 2013 -0700 142.3 @@ -0,0 +1,15 @@ 142.4 +/* /nodynamiccopyright/ */ 142.5 + 142.6 +public class TestCaseDoLoop { 142.7 + 142.8 + @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=15) 142.9 + @AliveRange(varName="args", bytecodeStart=0, bytecodeLength=18) 142.10 + void m(String[] args) { 142.11 + Object o; 142.12 + do { 142.13 + o = ""; 142.14 + o.hashCode(); 142.15 + } while (args[0] != null); 142.16 + o = ""; 142.17 + } 142.18 +}
143.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 143.2 +++ b/test/tools/javac/flow/tests/TestCaseFor.java Tue Sep 17 08:21:11 2013 -0700 143.3 @@ -0,0 +1,27 @@ 143.4 +/* /nodynamiccopyright/ */ 143.5 + 143.6 +public class TestCaseFor { 143.7 + 143.8 + @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) 143.9 + @AliveRange(varName="o", bytecodeStart=24, bytecodeLength=1) 143.10 + void m1(String[] args) { 143.11 + Object o; 143.12 + for (int i = 0; i < 5; i++) { 143.13 + o = ""; 143.14 + o.hashCode(); 143.15 + } 143.16 + o = ""; 143.17 + } 143.18 + 143.19 + @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) 143.20 + @AliveRange(varName="o", bytecodeStart=24, bytecodeLength=1) 143.21 + void m2(String[] args) { 143.22 + Object o; 143.23 + for (int i = 0; i < 5; i++) { 143.24 + o = ""; 143.25 + o.hashCode(); 143.26 + continue; 143.27 + } 143.28 + o = ""; 143.29 + } 143.30 +}
144.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 144.2 +++ b/test/tools/javac/flow/tests/TestCaseForEach.java Tue Sep 17 08:21:11 2013 -0700 144.3 @@ -0,0 +1,15 @@ 144.4 +/* /nodynamiccopyright/ */ 144.5 + 144.6 +public class TestCaseForEach { 144.7 + 144.8 + @AliveRange(varName="o", bytecodeStart=25, bytecodeLength=8) 144.9 + @AliveRange(varName="o", bytecodeStart=39, bytecodeLength=1) 144.10 + void m(String[] args) { 144.11 + Object o; 144.12 + for (String s : args) { 144.13 + o = ""; 144.14 + o.hashCode(); 144.15 + } 144.16 + o = ""; 144.17 + } 144.18 +}
145.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 145.2 +++ b/test/tools/javac/flow/tests/TestCaseIf.java Tue Sep 17 08:21:11 2013 -0700 145.3 @@ -0,0 +1,61 @@ 145.4 +/* /nodynamiccopyright/ */ 145.5 + 145.6 +public class TestCaseIf { 145.7 + 145.8 + @AliveRange(varName="o", bytecodeStart=9, bytecodeLength=5) 145.9 + @AliveRange(varName="o", bytecodeStart=17, bytecodeLength=1) 145.10 + void m0(String[] args) { 145.11 + Object o; 145.12 + if (args[0] != null) { 145.13 + o = ""; 145.14 + o.hashCode(); 145.15 + } 145.16 + o = ""; 145.17 + } 145.18 + 145.19 + @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=5) 145.20 + @AliveRange(varName="o", bytecodeStart=18, bytecodeLength=1) 145.21 + void m1() { 145.22 + Object o; 145.23 + int i = 5; 145.24 + if (i == 5) { 145.25 + o = ""; 145.26 + o.hashCode(); 145.27 + } 145.28 + o = ""; 145.29 + } 145.30 + 145.31 + @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=5) 145.32 + @AliveRange(varName="o", bytecodeStart=18, bytecodeLength=1) 145.33 + void m2() { 145.34 + Object o; 145.35 + int i = 5; 145.36 + if (!(i == 5)) { 145.37 + o = ""; 145.38 + o.hashCode(); 145.39 + } 145.40 + o = ""; 145.41 + } 145.42 + 145.43 + @AliveRange(varName="o", bytecodeStart=15, bytecodeLength=5) 145.44 + @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=1) 145.45 + void m3(String[] args) { 145.46 + Object o; 145.47 + if (args[0] != null && args[1] != null) { 145.48 + o = ""; 145.49 + o.hashCode(); 145.50 + } 145.51 + o = ""; 145.52 + } 145.53 + 145.54 + @AliveRange(varName="o", bytecodeStart=15, bytecodeLength=5) 145.55 + @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=1) 145.56 + void m4(String[] args) { 145.57 + Object o; 145.58 + if (args[0] != null || args[1] != null) { 145.59 + o = ""; 145.60 + o.hashCode(); 145.61 + } 145.62 + o = ""; 145.63 + } 145.64 +}
146.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 146.2 +++ b/test/tools/javac/flow/tests/TestCaseIfElse.java Tue Sep 17 08:21:11 2013 -0700 146.3 @@ -0,0 +1,48 @@ 146.4 +/* /nodynamiccopyright/ */ 146.5 + 146.6 +public class TestCaseIfElse { 146.7 + 146.8 + @AliveRange(varName="o", bytecodeStart=9, bytecodeLength=8) 146.9 + @AliveRange(varName="o", bytecodeStart=20, bytecodeLength=9) 146.10 + void m0(String[] args) { 146.11 + Object o; 146.12 + if (args[0] != null) { 146.13 + o = "then"; 146.14 + o.hashCode(); 146.15 + } else { 146.16 + o = "else"; 146.17 + o.hashCode(); 146.18 + } 146.19 + o = "finish"; 146.20 + } 146.21 + 146.22 + @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) 146.23 + @AliveRange(varName="o", bytecodeStart=21, bytecodeLength=9) 146.24 + void m1() { 146.25 + Object o; 146.26 + int i = 5; 146.27 + if (i == 5) { 146.28 + o = "then"; 146.29 + o.hashCode(); 146.30 + } else { 146.31 + o = "else"; 146.32 + o.hashCode(); 146.33 + } 146.34 + o = "finish"; 146.35 + } 146.36 + 146.37 + @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) 146.38 + @AliveRange(varName="o", bytecodeStart=21, bytecodeLength=9) 146.39 + void m2(String[] args) { 146.40 + Object o; 146.41 + int i = 5; 146.42 + if (i != 5) { 146.43 + o = "then"; 146.44 + o.hashCode(); 146.45 + } else { 146.46 + o = "else"; 146.47 + o.hashCode(); 146.48 + } 146.49 + o = "finish"; 146.50 + } 146.51 +}
147.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 147.2 +++ b/test/tools/javac/flow/tests/TestCaseSwitch.java Tue Sep 17 08:21:11 2013 -0700 147.3 @@ -0,0 +1,73 @@ 147.4 +/* /nodynamiccopyright/ */ 147.5 + 147.6 +public class TestCaseSwitch { 147.7 + 147.8 + @AliveRange(varName="o", bytecodeStart=31, bytecodeLength=16) 147.9 + @AliveRange(varName="o", bytecodeStart=50, bytecodeLength=15) 147.10 + @AliveRange(varName="o", bytecodeStart=68, bytecodeLength=1) 147.11 + @AliveRange(varName="oo", bytecodeStart=39, bytecodeLength=26) 147.12 + @AliveRange(varName="uu", bytecodeStart=59, bytecodeLength=6) 147.13 + void m1(String[] args) { 147.14 + Object o; 147.15 + switch (args.length) { 147.16 + case 0: 147.17 + o = "0"; 147.18 + o.hashCode(); 147.19 + Object oo = "oo"; 147.20 + oo.hashCode(); 147.21 + break; 147.22 + case 1: 147.23 + o = "1"; 147.24 + o.hashCode(); 147.25 + Object uu = "uu"; 147.26 + uu.hashCode(); 147.27 + break; 147.28 + } 147.29 + o = "return"; 147.30 + } 147.31 + 147.32 + @AliveRange(varName="o", bytecodeStart=95, bytecodeLength=18) 147.33 + @AliveRange(varName="o", bytecodeStart=116, bytecodeLength=15) 147.34 + @AliveRange(varName="o", bytecodeStart=134, bytecodeLength=1) 147.35 + @AliveRange(varName="oo", bytecodeStart=104, bytecodeLength=27) 147.36 + @AliveRange(varName="uu", bytecodeStart=125, bytecodeLength=6) 147.37 + void m2(String[] args) { 147.38 + Object o; 147.39 + switch (args[0]) { 147.40 + case "string0": 147.41 + o = "0"; 147.42 + o.hashCode(); 147.43 + Object oo = "oo"; 147.44 + oo.hashCode(); 147.45 + break; 147.46 + case "string1": 147.47 + o = "1"; 147.48 + o.hashCode(); 147.49 + Object uu = "uu"; 147.50 + uu.hashCode(); 147.51 + break; 147.52 + } 147.53 + o = "return"; 147.54 + } 147.55 + 147.56 + @AliveRange(varName="o", bytecodeStart=31, bytecodeLength=8) 147.57 + @AliveRange(varName="o", bytecodeStart=42, bytecodeLength=8) 147.58 + @AliveRange(varName="o", bytecodeStart=53, bytecodeLength=9) 147.59 + void m3(String[] args) { 147.60 + Object o; 147.61 + switch (args.length) { 147.62 + case 0: 147.63 + o = "0"; 147.64 + o.hashCode(); 147.65 + break; 147.66 + case 1: 147.67 + o = "1"; 147.68 + o.hashCode(); 147.69 + break; 147.70 + default: 147.71 + o = "default"; 147.72 + o.hashCode(); 147.73 + } 147.74 + o = "finish"; 147.75 + } 147.76 +}
148.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 148.2 +++ b/test/tools/javac/flow/tests/TestCaseTry.java Tue Sep 17 08:21:11 2013 -0700 148.3 @@ -0,0 +1,76 @@ 148.4 +/* /nodynamiccopyright/ */ 148.5 + 148.6 +import java.io.BufferedReader; 148.7 +import java.io.FileReader; 148.8 + 148.9 +public class TestCaseTry { 148.10 + 148.11 + @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=8) 148.12 + @AliveRange(varName="o", bytecodeStart=15, bytecodeLength=1) 148.13 + void m0(String[] args) { 148.14 + Object o; 148.15 + try { 148.16 + o = ""; 148.17 + o.hashCode(); 148.18 + } catch (RuntimeException e) {} 148.19 + o = ""; 148.20 + } 148.21 + 148.22 + @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16) 148.23 + @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=23) 148.24 + void m1() { 148.25 + Object o; 148.26 + try { 148.27 + o = ""; 148.28 + o.hashCode(); 148.29 + } catch (RuntimeException e) { 148.30 + } 148.31 + finally { 148.32 + o = "finally"; 148.33 + o.hashCode(); 148.34 + } 148.35 + o = ""; 148.36 + } 148.37 + 148.38 + @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16) 148.39 + @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=31) 148.40 + void m2() { 148.41 + Object o; 148.42 + try { 148.43 + o = ""; 148.44 + o.hashCode(); 148.45 + } catch (RuntimeException e) { 148.46 + o = "catch"; 148.47 + o.hashCode(); 148.48 + } 148.49 + finally { 148.50 + o = "finally"; 148.51 + o.hashCode(); 148.52 + } 148.53 + o = ""; 148.54 + } 148.55 + 148.56 + @AliveRange(varName="o", bytecodeStart=22, bytecodeLength=38) 148.57 + @AliveRange(varName="o", bytecodeStart=103, bytecodeLength=8) 148.58 + void m3() { 148.59 + Object o; 148.60 + try (BufferedReader br = 148.61 + new BufferedReader(new FileReader("aFile"))) { 148.62 + o = "inside try"; 148.63 + o.hashCode(); 148.64 + } catch (Exception e) {} 148.65 + o = ""; 148.66 + } 148.67 + 148.68 + @AliveRange(varName="o", bytecodeStart=12, bytecodeLength=96) 148.69 + @AliveRange(varName="o", bytecodeStart=112, bytecodeLength=1) 148.70 + void m4() { 148.71 + String o; 148.72 + try (BufferedReader br = 148.73 + new BufferedReader(new FileReader(o = "aFile"))) { 148.74 + o = "inside try"; 148.75 + o.hashCode(); 148.76 + } catch (Exception e) {} 148.77 + o = ""; 148.78 + } 148.79 +}
149.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 149.2 +++ b/test/tools/javac/flow/tests/TestCaseWhile.java Tue Sep 17 08:21:11 2013 -0700 149.3 @@ -0,0 +1,15 @@ 149.4 +/* /nodynamiccopyright/ */ 149.5 + 149.6 +public class TestCaseWhile { 149.7 + 149.8 + @AliveRange(varName="o", bytecodeStart=9, bytecodeLength=5) 149.9 + @AliveRange(varName="o", bytecodeStart=20, bytecodeLength=1) 149.10 + void m(String[] args) { 149.11 + Object o; 149.12 + while (args[0] != null) { 149.13 + o = ""; 149.14 + o.hashCode(); 149.15 + } 149.16 + o = ""; 149.17 + } 149.18 +}
150.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 150.2 +++ b/test/tools/javac/generics/neg/OrderedIntersections.java Tue Sep 17 08:21:11 2013 -0700 150.3 @@ -0,0 +1,21 @@ 150.4 +/* 150.5 + * @test /nodynamiccopyright/ 150.6 + * @bug 6962494 150.7 + * @summary The order of elements of intersection types shouldn't matter 150.8 + * @compile/fail/ref=OrderedIntersections.out -XDrawDiagnostics OrderedIntersections.java 150.9 + */ 150.10 + 150.11 +interface i1 {} 150.12 +interface i2 {} 150.13 + 150.14 +public class OrderedIntersections { 150.15 + static <t1 extends i1 & i2> Object smf(t1 x) { 150.16 + System.out.println( " smf1 " ); 150.17 + return null; 150.18 + } 150.19 + 150.20 + static <t2 extends i2 & i1> Object smf(t2 x) { 150.21 + System.out.println( " smf2 " ); 150.22 + return null; 150.23 + } 150.24 +}
151.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 151.2 +++ b/test/tools/javac/generics/neg/OrderedIntersections.out Tue Sep 17 08:21:11 2013 -0700 151.3 @@ -0,0 +1,2 @@ 151.4 +OrderedIntersections.java:17:40: compiler.err.already.defined: kindname.method, <t1>smf(t1), kindname.class, OrderedIntersections 151.5 +1 error
152.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 152.2 +++ b/test/tools/javac/lambda/8016177/T8016177a.java Tue Sep 17 08:21:11 2013 -0700 152.3 @@ -0,0 +1,45 @@ 152.4 +/* 152.5 + * @test /nodynamiccopyright/ 152.6 + * @bug 8016177 8016178 152.7 + * @summary structural most specific and stuckness 152.8 + * @compile/fail/ref=T8016177a.out -XDrawDiagnostics T8016177a.java 152.9 + */ 152.10 +import java.util.List; 152.11 + 152.12 +class T8016177a { 152.13 + 152.14 + interface ToIntFunction<X> { 152.15 + int m(X x); 152.16 + } 152.17 + 152.18 + interface Function<X, Y> { 152.19 + Y m(X x); 152.20 + } 152.21 + 152.22 + <T,R> void m1(List<T> s, Function<T,R> f) { } 152.23 + <T,R> void m1(List<T> s, ToIntFunction<T> f) { } 152.24 + 152.25 + <T,R> List<R> m2(List<T> s, Function<T,R> f) { return null; } 152.26 + <T,R> List<R> m2(List<T> s, ToIntFunction<T> f) { return null; } 152.27 + 152.28 + <T,R> List<T> m3(List<T> s, Function<T,R> f) { return null; } 152.29 + <T,R> List<R> m3(List<T> s, ToIntFunction<T> f) { return null; } 152.30 + 152.31 + <T,R> List<T> m4(List<T> s, Function<T,R> f) { return null; } 152.32 + <T,R> List<T> m4(List<T> s, ToIntFunction<T> f) { return null; } 152.33 + 152.34 + <T,R> List<R> m5(List<T> s, Function<T,R> f) { return null; } 152.35 + <T,R> List<T> m5(List<T> s, ToIntFunction<T> f) { return null; } 152.36 + 152.37 + <T extends R,R> List<R> m6(List<T> s, Function<T,R> f) { return null; } 152.38 + <T extends R,R> List<T> m6(List<T> s, ToIntFunction<T> f) { return null; } 152.39 + 152.40 + void test(List<String> ss) { 152.41 + m1(ss, s->s.length()); //ambiguous 152.42 + m2(ss, s->s.length()); //ambiguous 152.43 + m3(ss, s->s.length()); //ambiguous 152.44 + m4(ss, s->s.length()); //ambiguous 152.45 + m5(ss, s->s.length()); //ambiguous 152.46 + m6(ss, s->s.length()); //ambiguous 152.47 + } 152.48 +}
153.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 153.2 +++ b/test/tools/javac/lambda/8016177/T8016177a.out Tue Sep 17 08:21:11 2013 -0700 153.3 @@ -0,0 +1,8 @@ 153.4 +T8016177a.java:38:10: compiler.err.ref.ambiguous: m1, kindname.method, <T,R>m1(java.util.List<T>,T8016177a.Function<T,R>), T8016177a, kindname.method, <T,R>m1(java.util.List<T>,T8016177a.ToIntFunction<T>), T8016177a 153.5 +T8016177a.java:39:10: compiler.err.ref.ambiguous: m2, kindname.method, <T,R>m2(java.util.List<T>,T8016177a.Function<T,R>), T8016177a, kindname.method, <T,R>m2(java.util.List<T>,T8016177a.ToIntFunction<T>), T8016177a 153.6 +T8016177a.java:40:10: compiler.err.ref.ambiguous: m3, kindname.method, <T,R>m3(java.util.List<T>,T8016177a.Function<T,R>), T8016177a, kindname.method, <T,R>m3(java.util.List<T>,T8016177a.ToIntFunction<T>), T8016177a 153.7 +T8016177a.java:41:10: compiler.err.ref.ambiguous: m4, kindname.method, <T,R>m4(java.util.List<T>,T8016177a.Function<T,R>), T8016177a, kindname.method, <T,R>m4(java.util.List<T>,T8016177a.ToIntFunction<T>), T8016177a 153.8 +T8016177a.java:42:10: compiler.err.ref.ambiguous: m5, kindname.method, <T,R>m5(java.util.List<T>,T8016177a.Function<T,R>), T8016177a, kindname.method, <T,R>m5(java.util.List<T>,T8016177a.ToIntFunction<T>), T8016177a 153.9 +T8016177a.java:43:10: compiler.err.ref.ambiguous: m6, kindname.method, <T,R>m6(java.util.List<T>,T8016177a.Function<T,R>), T8016177a, kindname.method, <T,R>m6(java.util.List<T>,T8016177a.ToIntFunction<T>), T8016177a 153.10 +T8016177a.java:43:12: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: T,R, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String))) 153.11 +7 errors
154.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 154.2 +++ b/test/tools/javac/lambda/8016177/T8016177b.java Tue Sep 17 08:21:11 2013 -0700 154.3 @@ -0,0 +1,34 @@ 154.4 +/* 154.5 + * @test /nodynamiccopyright/ 154.6 + * @bug 8016177 8016178 154.7 + * @summary structural most specific and stuckness 154.8 + * @compile/fail/ref=T8016177b.out -XDrawDiagnostics T8016177b.java 154.9 + */ 154.10 +class T8016177b { 154.11 + interface ToIntFunction<X> { 154.12 + int m(X x); 154.13 + } 154.14 + 154.15 + interface Function<X, Y> { 154.16 + Y m(X x); 154.17 + } 154.18 + 154.19 + <U, V> Function<U, V> id(Function<U, V> arg) { return null; } 154.20 + 154.21 + <U, V> Function<U, V> id2(Function<U, V> arg) { return null; } 154.22 + <U> ToIntFunction<U> id2(ToIntFunction<U> arg) { return null; } 154.23 + 154.24 + 154.25 + <X,Y,Z> X f(Y arg, Function<Y, Z> f) { return null; } 154.26 + 154.27 + <X,Y,Z> X f2(Y arg, Function<Y, Z> f) { return null; } 154.28 + <X,Y> X f2(Y arg, ToIntFunction<Y> f) { return null; } 154.29 + 154.30 + <T> T g(T arg) { return null; } 154.31 + 154.32 + void test() { 154.33 + g(f("hi", id(x->1))); //ok 154.34 + g(f("hi", id2(x->1))); //ambiguous 154.35 + g(f2("hi", id(x->1))); //ok 154.36 + } 154.37 +}
155.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 155.2 +++ b/test/tools/javac/lambda/8016177/T8016177b.out Tue Sep 17 08:21:11 2013 -0700 155.3 @@ -0,0 +1,2 @@ 155.4 +T8016177b.java:31:19: compiler.err.ref.ambiguous: id2, kindname.method, <U,V>id2(T8016177b.Function<U,V>), T8016177b, kindname.method, <U>id2(T8016177b.ToIntFunction<U>), T8016177b 155.5 +1 error
156.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 156.2 +++ b/test/tools/javac/lambda/8016177/T8016177c.java Tue Sep 17 08:21:11 2013 -0700 156.3 @@ -0,0 +1,47 @@ 156.4 +/* 156.5 + * @test /nodynamiccopyright/ 156.6 + * @bug 8016081 8016178 156.7 + * @summary structural most specific and stuckness 156.8 + * @compile/fail/ref=T8016177c.out -XDrawDiagnostics T8016177c.java 156.9 + */ 156.10 + 156.11 +class T8016177c { 156.12 + 156.13 + interface Function<X, Y> { 156.14 + Y m(X x); 156.15 + } 156.16 + 156.17 + interface ExtFunction<X, Y> extends Function<X, Y> { } 156.18 + 156.19 + <U, V> U m1(Function<U, V> f) { return null; } 156.20 + <U, V> U m1(ExtFunction<U, V> f) { return null; } 156.21 + 156.22 + void m2(Function<Integer, Integer> f) { } 156.23 + void m2(ExtFunction<Integer, Integer> f) { } 156.24 + 156.25 + void m3(Function<Integer, Integer> f) { } 156.26 + void m3(ExtFunction<Object, Integer> f) { } 156.27 + 156.28 + int g1(Object s) { return 1; } 156.29 + 156.30 + int g2(Number s) { return 1; } 156.31 + int g2(Object s) { return 1; } 156.32 + 156.33 + void test() { 156.34 + m1((Integer x)->x); //ok - explicit lambda - subtyping picks most specific 156.35 + m2((Integer x)->x); //ok - explicit lambda - subtyping picks most specific 156.36 + m3((Integer x)->x); //ok - explicit lambda (only one applicable) 156.37 + 156.38 + m1(x->1); //ok - stuck lambda but nominal most specific wins 156.39 + m2(x->1); //ok - stuck lambda but nominal most specific wins 156.40 + m3(x->1); //ambiguous - implicit lambda & different params 156.41 + 156.42 + m1(this::g1); //ok - unambiguous ref - subtyping picks most specific 156.43 + m2(this::g1); //ok - unambiguous ref - subtyping picks most specific 156.44 + m3(this::g1); //ambiguous - both applicable, neither most specific 156.45 + 156.46 + m1(this::g2); //ok - stuck mref but nominal most specific wins 156.47 + m2(this::g2); //ok - stuck mref but nominal most specific wins 156.48 + m3(this::g2); //ambiguous - different params 156.49 + } 156.50 +}
157.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 157.2 +++ b/test/tools/javac/lambda/8016177/T8016177c.out Tue Sep 17 08:21:11 2013 -0700 157.3 @@ -0,0 +1,4 @@ 157.4 +T8016177c.java:37:9: compiler.err.ref.ambiguous: m3, kindname.method, m3(T8016177c.Function<java.lang.Integer,java.lang.Integer>), T8016177c, kindname.method, m3(T8016177c.ExtFunction<java.lang.Object,java.lang.Integer>), T8016177c 157.5 +T8016177c.java:41:9: compiler.err.ref.ambiguous: m3, kindname.method, m3(T8016177c.Function<java.lang.Integer,java.lang.Integer>), T8016177c, kindname.method, m3(T8016177c.ExtFunction<java.lang.Object,java.lang.Integer>), T8016177c 157.6 +T8016177c.java:45:9: compiler.err.ref.ambiguous: m3, kindname.method, m3(T8016177c.Function<java.lang.Integer,java.lang.Integer>), T8016177c, kindname.method, m3(T8016177c.ExtFunction<java.lang.Object,java.lang.Integer>), T8016177c 157.7 +3 errors
158.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 158.2 +++ b/test/tools/javac/lambda/8016177/T8016177d.java Tue Sep 17 08:21:11 2013 -0700 158.3 @@ -0,0 +1,58 @@ 158.4 +/* 158.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 158.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 158.7 + * 158.8 + * This code is free software; you can redistribute it and/or modify it 158.9 + * under the terms of the GNU General Public License version 2 only, as 158.10 + * published by the Free Software Foundation. 158.11 + * 158.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 158.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 158.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 158.15 + * version 2 for more details (a copy is included in the LICENSE file that 158.16 + * accompanied this code). 158.17 + * 158.18 + * You should have received a copy of the GNU General Public License version 158.19 + * 2 along with this work; if not, write to the Free Software Foundation, 158.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 158.21 + * 158.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 158.23 + * or visit www.oracle.com if you need additional information or have any 158.24 + * questions. 158.25 + */ 158.26 + 158.27 +/* 158.28 + * @test 158.29 + * @bug 8016081 8016178 158.30 + * @summary structural most specific and stuckness 158.31 + * @compile T8016177d.java 158.32 + */ 158.33 +import java.util.*; 158.34 + 158.35 +class T8016177d { 158.36 + 158.37 + interface UnaryOperator<X> { 158.38 + X m(X x); 158.39 + } 158.40 + 158.41 + interface IntStream { 158.42 + IntStream sorted(); 158.43 + IntStream distinct(); 158.44 + IntStream limit(int i); 158.45 + } 158.46 + 158.47 + abstract class WrappingUnaryOperator<S> implements UnaryOperator<S> { } 158.48 + 158.49 + <S1> WrappingUnaryOperator<S1> wrap1(UnaryOperator<S1> uo) { return null; } 158.50 + <S2> WrappingUnaryOperator<S2> wrap2(UnaryOperator<S2> uo) { return null; } 158.51 + <S3> WrappingUnaryOperator<S3> wrap3(UnaryOperator<S3> uo) { return null; } 158.52 + 158.53 + <P> List<List<P>> perm(List<P> l) { return null; } 158.54 + 158.55 + List<List<WrappingUnaryOperator<IntStream>>> intPermutationOfFunctions = 158.56 + perm(Arrays.asList( 158.57 + wrap1(s -> s.sorted()), 158.58 + wrap2(s -> s.distinct()), 158.59 + wrap3(s -> s.limit(5)) 158.60 + )); 158.61 +}
159.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 159.2 +++ b/test/tools/javac/lambda/8016177/T8016177e.java Tue Sep 17 08:21:11 2013 -0700 159.3 @@ -0,0 +1,46 @@ 159.4 +/* 159.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 159.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 159.7 + * 159.8 + * This code is free software; you can redistribute it and/or modify it 159.9 + * under the terms of the GNU General Public License version 2 only, as 159.10 + * published by the Free Software Foundation. 159.11 + * 159.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 159.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 159.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 159.15 + * version 2 for more details (a copy is included in the LICENSE file that 159.16 + * accompanied this code). 159.17 + * 159.18 + * You should have received a copy of the GNU General Public License version 159.19 + * 2 along with this work; if not, write to the Free Software Foundation, 159.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 159.21 + * 159.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 159.23 + * or visit www.oracle.com if you need additional information or have any 159.24 + * questions. 159.25 + */ 159.26 + 159.27 +/* 159.28 + * @test 159.29 + * @bug 8016081 8016178 159.30 + * @summary structural most specific and stuckness 159.31 + * @compile T8016177e.java 159.32 + */ 159.33 +import java.util.*; 159.34 + 159.35 +class T8016177e { 159.36 + 159.37 + interface TerminalOp<X, Y> { } 159.38 + 159.39 + interface Consumer<X> { 159.40 + void m(X x); 159.41 + } 159.42 + 159.43 + <T> TerminalOp<T, Void> makeRef(Consumer<? super T> action) { return null; } 159.44 + 159.45 + <T> void test() { 159.46 + Map<T, Boolean> map = null; 159.47 + TerminalOp<T, Void> forEachOp = makeRef(t -> { map.put(t, null); }); 159.48 + } 159.49 +}
160.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 160.2 +++ b/test/tools/javac/lambda/8016177/T8016177f.java Tue Sep 17 08:21:11 2013 -0700 160.3 @@ -0,0 +1,94 @@ 160.4 +/* 160.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 160.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 160.7 + * 160.8 + * This code is free software; you can redistribute it and/or modify it 160.9 + * under the terms of the GNU General Public License version 2 only, as 160.10 + * published by the Free Software Foundation. 160.11 + * 160.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 160.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 160.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 160.15 + * version 2 for more details (a copy is included in the LICENSE file that 160.16 + * accompanied this code). 160.17 + * 160.18 + * You should have received a copy of the GNU General Public License version 160.19 + * 2 along with this work; if not, write to the Free Software Foundation, 160.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 160.21 + * 160.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 160.23 + * or visit www.oracle.com if you need additional information or have any 160.24 + * questions. 160.25 + */ 160.26 + 160.27 +/* 160.28 + * @test 160.29 + * @bug 8016081 8016178 160.30 + * @summary structural most specific and stuckness 160.31 + * @compile T8016177f.java 160.32 + */ 160.33 +import java.util.*; 160.34 + 160.35 +class T8016177f { 160.36 + 160.37 + interface Function<S, T> { 160.38 + T apply(S s); 160.39 + } 160.40 + 160.41 + interface IntFunction<T> { 160.42 + T apply(int s); 160.43 + } 160.44 + 160.45 + 160.46 + interface BiConsumer<X,Y> { 160.47 + void m(X x, Y y); 160.48 + } 160.49 + 160.50 + interface Consumer<X> { 160.51 + void m(X x); 160.52 + } 160.53 + 160.54 + interface Supplier<X> { 160.55 + X make(); 160.56 + } 160.57 + 160.58 + interface TestData<T, S extends BaseStream<T, S>> { 160.59 + interface OfRef<T> extends TestData<T, Stream<T>> { } 160.60 + interface OfDouble extends TestData<Double, DoubleStream> { } 160.61 + } 160.62 + 160.63 + interface BaseStream<T, S extends BaseStream<T, S>> { } 160.64 + 160.65 + interface Stream<T> extends BaseStream<T, Stream<T>> { 160.66 + <M> Stream<M> map(Function<T, M> s); 160.67 + <R> R collect(Supplier<R> resultFactory, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner); 160.68 + <Z> Z[] toArray(IntFunction<Z[]> s); 160.69 + } 160.70 + 160.71 + interface DoubleStream extends BaseStream<Double, DoubleStream> { 160.72 + DoubleStream filter(DoublePredicate dp); 160.73 + double[] toArray(); 160.74 + } 160.75 + 160.76 + interface DoublePredicate { 160.77 + boolean p(double d); 160.78 + } 160.79 + 160.80 + <T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> 160.81 + R exerciseTerminalOps(TestData<T, S_IN> data, 160.82 + Function<S_IN, S_OUT> streamF, 160.83 + Function<S_OUT, R> terminalF) { return null; } 160.84 + 160.85 + <O> TestData.OfRef<O> ofCollection(Collection<O> collection) { return null; } 160.86 + 160.87 + void test1(TestData.OfDouble data, DoublePredicate dp) { 160.88 + exerciseTerminalOps(data, s -> s.filter(dp), s -> s.toArray()); 160.89 + } 160.90 + 160.91 + void test2(Function<Double, Integer> fdi, TestData.OfRef<Double> td, Stream<Integer> si) { 160.92 + exerciseTerminalOps( 160.93 + ofCollection((List<Double>)null), 160.94 + s -> s.map(fdi), 160.95 + s -> s.toArray(Integer[]::new)); 160.96 + } 160.97 +}
161.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 161.2 +++ b/test/tools/javac/lambda/8016177/T8016177g.java Tue Sep 17 08:21:11 2013 -0700 161.3 @@ -0,0 +1,37 @@ 161.4 +/* 161.5 + * @test /nodynamiccopyright/ 161.6 + * @bug 8016081 8016178 161.7 + * @summary structural most specific and stuckness 161.8 + * @compile/fail/ref=T8016177g.out -XDrawDiagnostics T8016177g.java 161.9 + */ 161.10 + 161.11 + 161.12 +class Test { 161.13 + 161.14 + interface Function<X, Y> { 161.15 + Y m(X x); 161.16 + } 161.17 + 161.18 + interface Box<T> { 161.19 + T get(); 161.20 + <R> R map(Function<T,R> f); 161.21 + } 161.22 + 161.23 + static class Person { 161.24 + Person(String name) { } 161.25 + } 161.26 + 161.27 + void print(Object arg) { } 161.28 + void print(String arg) { } 161.29 + 161.30 + int abs(int a) { return 0; } 161.31 + long abs(long a) { return 0; } 161.32 + float abs(float a) { return 0; } 161.33 + double abs(double a) { return 0; } 161.34 + 161.35 + void test() { 161.36 + Box<String> b = null; 161.37 + print(b.map(s -> new Person(s))); 161.38 + int i = abs(b.map(s -> Double.valueOf(s))); 161.39 + } 161.40 +}
162.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 162.2 +++ b/test/tools/javac/lambda/8016177/T8016177g.out Tue Sep 17 08:21:11 2013 -0700 162.3 @@ -0,0 +1,2 @@ 162.4 +T8016177g.java:35:20: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, int) 162.5 +1 error
163.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 163.2 +++ b/test/tools/javac/lambda/8023389/T8023389.java Tue Sep 17 08:21:11 2013 -0700 163.3 @@ -0,0 +1,46 @@ 163.4 +/* 163.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 163.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 163.7 + * 163.8 + * This code is free software; you can redistribute it and/or modify it 163.9 + * under the terms of the GNU General Public License version 2 only, as 163.10 + * published by the Free Software Foundation. 163.11 + * 163.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 163.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 163.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 163.15 + * version 2 for more details (a copy is included in the LICENSE file that 163.16 + * accompanied this code). 163.17 + * 163.18 + * You should have received a copy of the GNU General Public License version 163.19 + * 2 along with this work; if not, write to the Free Software Foundation, 163.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 163.21 + * 163.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 163.23 + * or visit www.oracle.com if you need additional information or have any 163.24 + * questions. 163.25 + */ 163.26 + 163.27 +/* 163.28 + * @test 163.29 + * @bug 8023389 163.30 + * @summary Javac fails to infer type for lambda used with intersection type and wildcards 163.31 + * @compile T8023389.java 163.32 + */ 163.33 +public class T8023389 { 163.34 + 163.35 + static class U1 {} 163.36 + static class X1 extends U1 {} 163.37 + 163.38 + interface I { } 163.39 + 163.40 + interface SAM<T> { 163.41 + void m(T t); 163.42 + } 163.43 + 163.44 + /* Strictly speaking only the second of the following declarations provokes the bug. 163.45 + * But the first line is also a useful test case. 163.46 + */ 163.47 + SAM<? extends U1> sam1 = (SAM<? extends U1>) (X1 x) -> { }; 163.48 + SAM<? extends U1> sam2 = (SAM<? extends U1> & I) (X1 x) -> { }; 163.49 +}
164.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 164.2 +++ b/test/tools/javac/lambda/8023549/T8023549.java Tue Sep 17 08:21:11 2013 -0700 164.3 @@ -0,0 +1,27 @@ 164.4 +/* 164.5 + * @test /nodynamiccopyright/ 164.6 + * @bug 8023549 164.7 + * @summary Compiler emitting spurious errors when constructor reference type is inferred and explicit type arguments are supplied 164.8 + * @compile/fail/ref=T8023549.out -XDrawDiagnostics T8023549.java 164.9 + */ 164.10 + 164.11 +public class T8023549 { 164.12 + static class Foo<X> { } 164.13 + 164.14 + interface Supplier<X> { 164.15 + X make(); 164.16 + } 164.17 + 164.18 + interface ExtSupplier<X> extends Supplier<X> { } 164.19 + 164.20 + void m1(Supplier<Foo<String>> sfs) { } 164.21 + 164.22 + void m2(Supplier<Foo<String>> sfs) { } 164.23 + void m2(ExtSupplier<Foo<Integer>> sfs) { } 164.24 + 164.25 + void test() { 164.26 + Supplier<Foo<String>> sfs = Foo::<Number>new; 164.27 + m1(Foo::<Number>new); 164.28 + m2(Foo::<Number>new); 164.29 + } 164.30 +}
165.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 165.2 +++ b/test/tools/javac/lambda/8023549/T8023549.out Tue Sep 17 08:21:11 2013 -0700 165.3 @@ -0,0 +1,5 @@ 165.4 +T8023549.java:23:37: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.mref.infer.and.explicit.params) 165.5 +T8023549.java:24:12: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.mref.infer.and.explicit.params) 165.6 +T8023549.java:25:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(T8023549.Supplier<T8023549.Foo<java.lang.String>>), T8023549, kindname.method, m2(T8023549.ExtSupplier<T8023549.Foo<java.lang.Integer>>), T8023549 165.7 +T8023549.java:25:12: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.mref.infer.and.explicit.params) 165.8 +4 errors
166.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 166.2 +++ b/test/tools/javac/lambda/8023558/T8023558a.java Tue Sep 17 08:21:11 2013 -0700 166.3 @@ -0,0 +1,38 @@ 166.4 +/* 166.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 166.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 166.7 + * 166.8 + * This code is free software; you can redistribute it and/or modify it 166.9 + * under the terms of the GNU General Public License version 2 only, as 166.10 + * published by the Free Software Foundation. 166.11 + * 166.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 166.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 166.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 166.15 + * version 2 for more details (a copy is included in the LICENSE file that 166.16 + * accompanied this code). 166.17 + * 166.18 + * You should have received a copy of the GNU General Public License version 166.19 + * 2 along with this work; if not, write to the Free Software Foundation, 166.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 166.21 + * 166.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 166.23 + * or visit www.oracle.com if you need additional information or have any 166.24 + * questions. 166.25 + */ 166.26 + 166.27 +/* 166.28 + * @test 166.29 + * @bug 8023558 166.30 + * @summary Javac creates invalid bootstrap methods for complex lambda/methodref case 166.31 + */ 166.32 +public class T8023558a { 166.33 + interface SAM<T> { 166.34 + T get(); 166.35 + } 166.36 + 166.37 + public static void main(String[] args) { 166.38 + SAM<SAM> sam = new SAM<SAM>() { public SAM get() { return null; } }; 166.39 + SAM temp = sam.get()::get; 166.40 + } 166.41 +}
167.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 167.2 +++ b/test/tools/javac/lambda/8023558/T8023558b.java Tue Sep 17 08:21:11 2013 -0700 167.3 @@ -0,0 +1,58 @@ 167.4 +/* 167.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 167.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 167.7 + * 167.8 + * This code is free software; you can redistribute it and/or modify it 167.9 + * under the terms of the GNU General Public License version 2 only, as 167.10 + * published by the Free Software Foundation. 167.11 + * 167.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 167.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 167.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 167.15 + * version 2 for more details (a copy is included in the LICENSE file that 167.16 + * accompanied this code). 167.17 + * 167.18 + * You should have received a copy of the GNU General Public License version 167.19 + * 2 along with this work; if not, write to the Free Software Foundation, 167.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 167.21 + * 167.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 167.23 + * or visit www.oracle.com if you need additional information or have any 167.24 + * questions. 167.25 + */ 167.26 + 167.27 +/* 167.28 + * @test 167.29 + * @bug 8023558 167.30 + * @summary Javac creates invalid bootstrap methods for complex lambda/methodref case 167.31 + */ 167.32 +public class T8023558b { 167.33 + 167.34 + interface Supplier<X> { 167.35 + X get(); 167.36 + } 167.37 + 167.38 + static class A { 167.39 + public A(Supplier<B> supplier) { } 167.40 + } 167.41 + 167.42 + static class B { } 167.43 + 167.44 + static class C { 167.45 + public B getB() { 167.46 + return new B(); 167.47 + } 167.48 + } 167.49 + 167.50 + public static void main(String[] args) { 167.51 + new T8023558b().test(T8023558b::getC); 167.52 + } 167.53 + 167.54 + private static C getC() { 167.55 + return new C(); 167.56 + } 167.57 + 167.58 + public void test(Supplier<C> supplier) { 167.59 + new A(supplier.get()::getB); 167.60 + } 167.61 +}
168.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 168.2 +++ b/test/tools/javac/lambda/8023558/T8023558c.java Tue Sep 17 08:21:11 2013 -0700 168.3 @@ -0,0 +1,39 @@ 168.4 +/* 168.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 168.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 168.7 + * 168.8 + * This code is free software; you can redistribute it and/or modify it 168.9 + * under the terms of the GNU General Public License version 2 only, as 168.10 + * published by the Free Software Foundation. 168.11 + * 168.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 168.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 168.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 168.15 + * version 2 for more details (a copy is included in the LICENSE file that 168.16 + * accompanied this code). 168.17 + * 168.18 + * You should have received a copy of the GNU General Public License version 168.19 + * 2 along with this work; if not, write to the Free Software Foundation, 168.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 168.21 + * 168.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 168.23 + * or visit www.oracle.com if you need additional information or have any 168.24 + * questions. 168.25 + */ 168.26 + 168.27 +/* 168.28 + * @test 168.29 + * @bug 8023558 168.30 + * @summary Javac creates invalid bootstrap methods for complex lambda/methodref case 168.31 + */ 168.32 + 168.33 +interface SAM<T> { 168.34 + T get(); 168.35 +} 168.36 + 168.37 +public class T8023558c { 168.38 + public static void main(String[] args) { 168.39 + SAM<SAM> sam = () -> Object::new; 168.40 + SAM temp = sam.get()::get; 168.41 + } 168.42 +}
169.1 --- a/test/tools/javac/lambda/BadRecovery.out Thu Sep 12 11:09:20 2013 -0700 169.2 +++ b/test/tools/javac/lambda/BadRecovery.out Tue Sep 17 08:21:11 2013 -0700 169.3 @@ -1,2 +1,3 @@ 169.4 +BadRecovery.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, BadRecovery.SAM1, @369, kindname.class, BadRecovery, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)) 169.5 BadRecovery.java:17:77: compiler.err.cant.resolve.location: kindname.variable, f, , , (compiler.misc.location: kindname.class, BadRecovery, null) 169.6 -1 error 169.7 +2 errors
170.1 --- a/test/tools/javac/lambda/EffectivelyFinalTest.java Thu Sep 12 11:09:20 2013 -0700 170.2 +++ b/test/tools/javac/lambda/EffectivelyFinalTest.java Tue Sep 17 08:21:11 2013 -0700 170.3 @@ -1,6 +1,6 @@ 170.4 /* 170.5 * @test /nodynamiccopyright/ 170.6 - * @bug 8003280 170.7 + * @bug 7175538 8003280 170.8 * @summary Add lambda tests 170.9 * Integrate effectively final check with DA/DU analysis 170.10 * @compile/fail/ref=EffectivelyFinalTest01.out -XDrawDiagnostics EffectivelyFinalTest.java
171.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 171.2 +++ b/test/tools/javac/lambda/EffectivelyFinalThrows.java Tue Sep 17 08:21:11 2013 -0700 171.3 @@ -0,0 +1,25 @@ 171.4 +/* 171.5 + * @test /nodynamiccopyright/ 171.6 + * @bug 8019521 171.7 + * @summary Check that enhanced rethrow/effectivelly final works correctly inside lambdas 171.8 + * @compile EffectivelyFinalThrows.java 171.9 + */ 171.10 + 171.11 +class EffectivelyFinalThrows { 171.12 + interface SAM<E extends Throwable> { 171.13 + public void t() throws E; 171.14 + } 171.15 + <E extends Throwable> void test(SAM<E> s) throws E { 171.16 + s.t(); 171.17 + } 171.18 + void test2(SAM<Checked> s) throws Checked { 171.19 + test(() -> { 171.20 + try { 171.21 + s.t(); 171.22 + } catch (Throwable t) { 171.23 + throw t; 171.24 + } 171.25 + }); 171.26 + } 171.27 + static class Checked extends Exception {} 171.28 +}
172.1 --- a/test/tools/javac/lambda/ErroneousLambdaExpr.java Thu Sep 12 11:09:20 2013 -0700 172.2 +++ b/test/tools/javac/lambda/ErroneousLambdaExpr.java Tue Sep 17 08:21:11 2013 -0700 172.3 @@ -1,5 +1,5 @@ 172.4 /* 172.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 172.6 + * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved. 172.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 172.8 * 172.9 * This code is free software; you can redistribute it and/or modify it 172.10 @@ -26,6 +26,7 @@ 172.11 * @bug 8003280 172.12 * @summary Add lambda tests 172.13 * stale state after speculative attribution round leads to missing classfiles 172.14 + * @compile/fail/ref=ErroneousLambdaExpr.out -XDrawDiagnostics ErroneousLambdaExpr.java 172.15 */ 172.16 public class ErroneousLambdaExpr<T> { 172.17
173.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 173.2 +++ b/test/tools/javac/lambda/ErroneousLambdaExpr.out Tue Sep 17 08:21:11 2013 -0700 173.3 @@ -0,0 +1,2 @@ 173.4 +ErroneousLambdaExpr.java:63:13: compiler.err.ref.ambiguous: call, kindname.method, call(ErroneousLambdaExpr.SAM1<T>), ErroneousLambdaExpr, kindname.method, call(ErroneousLambdaExpr.SAM2), ErroneousLambdaExpr 173.5 +1 error
174.1 --- a/test/tools/javac/lambda/MethodReference22.out Thu Sep 12 11:09:20 2013 -0700 174.2 +++ b/test/tools/javac/lambda/MethodReference22.out Tue Sep 17 08:21:11 2013 -0700 174.3 @@ -3,13 +3,17 @@ 174.4 MethodReference22.java:46:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)) 174.5 MethodReference22.java:47:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)) 174.6 MethodReference22.java:51:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m1, kindname.method, m1(MethodReference22,java.lang.String), MethodReference22, kindname.method, m1(java.lang.String), MethodReference22)) 174.7 -MethodReference22.java:52:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1401, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m1, kindname.method, m1(MethodReference22,java.lang.String), MethodReference22, kindname.method, m1(java.lang.String), MethodReference22))) 174.8 +MethodReference22.java:52:14: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1401, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m1, kindname.method, m1(MethodReference22,java.lang.String), MethodReference22, kindname.method, m1(java.lang.String), MethodReference22))) 174.9 MethodReference22.java:53:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m2, kindname.method, m2(MethodReference22,java.lang.String), MethodReference22, kindname.method, m2(java.lang.String), MethodReference22)) 174.10 -MethodReference22.java:54:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1504, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m2, kindname.method, m2(MethodReference22,java.lang.String), MethodReference22, kindname.method, m2(java.lang.String), MethodReference22))) 174.11 +MethodReference22.java:54:14: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1504, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m2, kindname.method, m2(MethodReference22,java.lang.String), MethodReference22, kindname.method, m2(java.lang.String), MethodReference22))) 174.12 MethodReference22.java:55:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m3, kindname.method, m3(MethodReference22,java.lang.String), MethodReference22, kindname.method, m3(java.lang.String), MethodReference22)) 174.13 -MethodReference22.java:56:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1607, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m3, kindname.method, m3(MethodReference22,java.lang.String), MethodReference22, kindname.method, m3(java.lang.String), MethodReference22))) 174.14 +MethodReference22.java:56:14: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1607, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m3, kindname.method, m3(MethodReference22,java.lang.String), MethodReference22, kindname.method, m3(java.lang.String), MethodReference22))) 174.15 MethodReference22.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22)) 174.16 -MethodReference22.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1710, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))) 174.17 +MethodReference22.java:58:14: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1710, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))) 174.18 +MethodReference22.java:62:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22 174.19 MethodReference22.java:62:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String)) 174.20 +MethodReference22.java:63:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22 174.21 +MethodReference22.java:64:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22 174.22 +MethodReference22.java:65:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22 174.23 MethodReference22.java:65:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)) 174.24 -14 errors 174.25 +18 errors
175.1 --- a/test/tools/javac/lambda/MethodReference23.out Thu Sep 12 11:09:20 2013 -0700 175.2 +++ b/test/tools/javac/lambda/MethodReference23.out Tue Sep 17 08:21:11 2013 -0700 175.3 @@ -1,6 +1,6 @@ 175.4 MethodReference23.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23)) 175.5 -MethodReference23.java:53:9: compiler.err.cant.apply.symbol: kindname.method, call11, MethodReference23.SAM11, @1140, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23))) 175.6 +MethodReference23.java:53:15: compiler.err.cant.apply.symbol: kindname.method, call11, MethodReference23.SAM11, @1140, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23))) 175.7 MethodReference23.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)) 175.8 -MethodReference23.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call12, MethodReference23.SAM12, @1282, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23))) 175.9 +MethodReference23.java:58:15: compiler.err.cant.apply.symbol: kindname.method, call12, MethodReference23.SAM12, @1282, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23))) 175.10 MethodReference23.java:72:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference23.SAM21), MethodReference23, kindname.method, call3(MethodReference23.SAM22), MethodReference23 175.11 5 errors
176.1 --- a/test/tools/javac/lambda/MethodReference41.java Thu Sep 12 11:09:20 2013 -0700 176.2 +++ b/test/tools/javac/lambda/MethodReference41.java Tue Sep 17 08:21:11 2013 -0700 176.3 @@ -1,43 +1,13 @@ 176.4 /* 176.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 176.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 176.7 - * 176.8 - * This code is free software; you can redistribute it and/or modify it 176.9 - * under the terms of the GNU General Public License version 2 only, as 176.10 - * published by the Free Software Foundation. 176.11 - * 176.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 176.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 176.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 176.15 - * version 2 for more details (a copy is included in the LICENSE file that 176.16 - * accompanied this code). 176.17 - * 176.18 - * You should have received a copy of the GNU General Public License version 176.19 - * 2 along with this work; if not, write to the Free Software Foundation, 176.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 176.21 - * 176.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 176.23 - * or visit www.oracle.com if you need additional information or have any 176.24 - * questions. 176.25 - */ 176.26 - 176.27 -/* 176.28 - * @test 176.29 + * @test /nodynamiccopyright/ 176.30 * @bug 8003280 176.31 * @summary Add lambda tests 176.32 * check that diamond inference is applied when using raw constructor reference qualifier 176.33 - * @run main MethodReference41 176.34 + * @compile/fail/ref=MethodReference41.out -XDrawDiagnostics MethodReference41.java 176.35 */ 176.36 + 176.37 public class MethodReference41 { 176.38 176.39 - static int assertionCount = 0; 176.40 - 176.41 - static void assertTrue(boolean cond) { 176.42 - assertionCount++; 176.43 - if (!cond) 176.44 - throw new AssertionError(); 176.45 - } 176.46 - 176.47 interface SAM1 { 176.48 void m(String s); 176.49 } 176.50 @@ -54,13 +24,20 @@ 176.51 Foo(X x) { } 176.52 } 176.53 176.54 + static void m1(SAM1 s) { } 176.55 176.56 - static void m(SAM1 s) { assertTrue(false); } 176.57 - static void m(SAM2 s) { assertTrue(true); } 176.58 - static void m(SAM3 s) { assertTrue(false); } 176.59 + static void m2(SAM2 s) { } 176.60 + 176.61 + static void m3(SAM3 s) { } 176.62 + 176.63 + static void m4(SAM1 s) { } 176.64 + static void m4(SAM2 s) { } 176.65 + static void m4(SAM3 s) { } 176.66 176.67 public static void main(String[] args) { 176.68 - m(Foo::new); 176.69 - assertTrue(assertionCount == 1); 176.70 + m1(Foo::new); 176.71 + m2(Foo::new); 176.72 + m3(Foo::new); 176.73 + m4(Foo::new); 176.74 } 176.75 }
177.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 177.2 +++ b/test/tools/javac/lambda/MethodReference41.out Tue Sep 17 08:21:11 2013 -0700 177.3 @@ -0,0 +1,4 @@ 177.4 +MethodReference41.java:38:11: compiler.err.cant.apply.symbol: kindname.method, m1, MethodReference41.SAM1, @767, kindname.class, MethodReference41, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Foo, java.lang.Number, java.lang.String, kindname.class, MethodReference41.Foo<X>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)))) 177.5 +MethodReference41.java:40:11: compiler.err.cant.apply.symbol: kindname.method, m3, MethodReference41.SAM3, @811, kindname.class, MethodReference41, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Foo, java.lang.Number, java.lang.Object, kindname.class, MethodReference41.Foo<X>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Object, java.lang.Number)))) 177.6 +MethodReference41.java:41:9: compiler.err.ref.ambiguous: m4, kindname.method, m4(MethodReference41.SAM2), MethodReference41, kindname.method, m4(MethodReference41.SAM3), MethodReference41 177.7 +3 errors
178.1 --- a/test/tools/javac/lambda/MethodReference42.java Thu Sep 12 11:09:20 2013 -0700 178.2 +++ b/test/tools/javac/lambda/MethodReference42.java Tue Sep 17 08:21:11 2013 -0700 178.3 @@ -1,43 +1,13 @@ 178.4 /* 178.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 178.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 178.7 - * 178.8 - * This code is free software; you can redistribute it and/or modify it 178.9 - * under the terms of the GNU General Public License version 2 only, as 178.10 - * published by the Free Software Foundation. 178.11 - * 178.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 178.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 178.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 178.15 - * version 2 for more details (a copy is included in the LICENSE file that 178.16 - * accompanied this code). 178.17 - * 178.18 - * You should have received a copy of the GNU General Public License version 178.19 - * 2 along with this work; if not, write to the Free Software Foundation, 178.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 178.21 - * 178.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 178.23 - * or visit www.oracle.com if you need additional information or have any 178.24 - * questions. 178.25 - */ 178.26 - 178.27 -/* 178.28 - * @test 178.29 + * @test /nodynamiccopyright/ 178.30 * @bug 8003280 178.31 * @summary Add lambda tests 178.32 * check that diamond inference is applied when using raw constructor reference qualifier 178.33 - * @run main MethodReference42 178.34 + * @compile/fail/ref=MethodReference42.out -XDrawDiagnostics MethodReference42.java 178.35 */ 178.36 + 178.37 public class MethodReference42 { 178.38 178.39 - static int assertionCount = 0; 178.40 - 178.41 - static void assertTrue(boolean cond) { 178.42 - assertionCount++; 178.43 - if (!cond) 178.44 - throw new AssertionError(); 178.45 - } 178.46 - 178.47 static class SuperFoo<X> { } 178.48 178.49 static class Foo<X extends Number> extends SuperFoo<X> { } 178.50 @@ -54,12 +24,20 @@ 178.51 SuperFoo<Object> m(); 178.52 } 178.53 178.54 - static void m(SAM1 s) { assertTrue(false); } 178.55 - static void m(SAM2 s) { assertTrue(true); } 178.56 - static void m(SAM3 s) { assertTrue(false); } 178.57 + static void m1(SAM1 s) { } 178.58 + 178.59 + static void m2(SAM2 s) { } 178.60 + 178.61 + static void m3(SAM3 s) { } 178.62 + 178.63 + static void m4(SAM1 s) { } 178.64 + static void m4(SAM2 s) { } 178.65 + static void m4(SAM3 s) { } 178.66 178.67 public static void main(String[] args) { 178.68 - m(Foo::new); 178.69 - assertTrue(assertionCount == 1); 178.70 + m1(Foo::new); 178.71 + m2(Foo::new); 178.72 + m3(Foo::new); 178.73 + m4(Foo::new); 178.74 } 178.75 }
179.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 179.2 +++ b/test/tools/javac/lambda/MethodReference42.out Tue Sep 17 08:21:11 2013 -0700 179.3 @@ -0,0 +1,4 @@ 179.4 +MethodReference42.java:38:11: compiler.err.cant.apply.symbol: kindname.method, m1, MethodReference42.SAM1, @811, kindname.class, MethodReference42, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number)) 179.5 +MethodReference42.java:40:11: compiler.err.cant.apply.symbol: kindname.method, m3, MethodReference42.SAM3, @855, kindname.class, MethodReference42, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.Object, java.lang.Number)) 179.6 +MethodReference42.java:41:9: compiler.err.ref.ambiguous: m4, kindname.method, m4(MethodReference42.SAM2), MethodReference42, kindname.method, m4(MethodReference42.SAM3), MethodReference42 179.7 +3 errors
180.1 --- a/test/tools/javac/lambda/MethodReference43.java Thu Sep 12 11:09:20 2013 -0700 180.2 +++ b/test/tools/javac/lambda/MethodReference43.java Tue Sep 17 08:21:11 2013 -0700 180.3 @@ -1,43 +1,13 @@ 180.4 /* 180.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 180.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 180.7 - * 180.8 - * This code is free software; you can redistribute it and/or modify it 180.9 - * under the terms of the GNU General Public License version 2 only, as 180.10 - * published by the Free Software Foundation. 180.11 - * 180.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 180.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 180.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 180.15 - * version 2 for more details (a copy is included in the LICENSE file that 180.16 - * accompanied this code). 180.17 - * 180.18 - * You should have received a copy of the GNU General Public License version 180.19 - * 2 along with this work; if not, write to the Free Software Foundation, 180.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 180.21 - * 180.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 180.23 - * or visit www.oracle.com if you need additional information or have any 180.24 - * questions. 180.25 - */ 180.26 - 180.27 -/* 180.28 - * @test 180.29 + * @test /nodynamiccopyright/ 180.30 * @bug 8003280 180.31 * @summary Add lambda tests 180.32 * check that diamond inference is applied when using raw constructor reference qualifier 180.33 - * @run main MethodReference43 180.34 + * @compile/fail/ref=MethodReference43.out -XDrawDiagnostics MethodReference43.java 180.35 */ 180.36 + 180.37 public class MethodReference43 { 180.38 180.39 - static int assertionCount = 0; 180.40 - 180.41 - static void assertTrue(boolean cond) { 180.42 - assertionCount++; 180.43 - if (!cond) 180.44 - throw new AssertionError(); 180.45 - } 180.46 - 180.47 interface SAM1 { 180.48 Foo<?> m(String s); 180.49 } 180.50 @@ -58,14 +28,24 @@ 180.51 Foo(X x) { } 180.52 } 180.53 180.54 + static void m1(SAM1 s) { } 180.55 180.56 - static void m(SAM1 s) { assertTrue(false); } 180.57 - static void m(SAM2 s) { assertTrue(false); } 180.58 - static void m(SAM3 s) { assertTrue(false); } 180.59 - static void m(SAM4 s) { assertTrue(true); } 180.60 + static void m2(SAM2 s) { } 180.61 + 180.62 + static void m3(SAM3 s) { } 180.63 + 180.64 + static void m4(SAM4 s) { } 180.65 + 180.66 + static void m5(SAM1 s) { } 180.67 + static void m5(SAM2 s) { } 180.68 + static void m5(SAM3 s) { } 180.69 + static void m5(SAM4 s) { } 180.70 180.71 public static void main(String[] args) { 180.72 - m(Foo::new); 180.73 - assertTrue(assertionCount == 1); 180.74 + m1(Foo::new); 180.75 + m2(Foo::new); 180.76 + m3(Foo::new); 180.77 + m4(Foo::new); 180.78 + m5(Foo::new); 180.79 } 180.80 }
181.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 181.2 +++ b/test/tools/javac/lambda/MethodReference43.out Tue Sep 17 08:21:11 2013 -0700 181.3 @@ -0,0 +1,5 @@ 181.4 +MethodReference43.java:45:11: compiler.err.cant.apply.symbol: kindname.method, m1, MethodReference43.SAM1, @897, kindname.class, MethodReference43, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Foo, java.lang.Number, java.lang.String, kindname.class, MethodReference43.Foo<X>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)))) 181.5 +MethodReference43.java:47:11: compiler.err.cant.apply.symbol: kindname.method, m3, MethodReference43.SAM3, @941, kindname.class, MethodReference43, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Foo, java.lang.Number, java.lang.Object, kindname.class, MethodReference43.Foo<X>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Object, java.lang.Number)))) 181.6 +MethodReference43.java:49:9: compiler.err.ref.ambiguous: m5, kindname.method, m5(MethodReference43.SAM3), MethodReference43, kindname.method, m5(MethodReference43.SAM4), MethodReference43 181.7 +MethodReference43.java:49:11: compiler.err.cant.apply.symbol: kindname.method, m5, MethodReference43.SAM3, @985, kindname.class, MethodReference43, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Foo, java.lang.Number, java.lang.Object, kindname.class, MethodReference43.Foo<X>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Object, java.lang.Number)))) 181.8 +4 errors
182.1 --- a/test/tools/javac/lambda/MethodReference44.java Thu Sep 12 11:09:20 2013 -0700 182.2 +++ b/test/tools/javac/lambda/MethodReference44.java Tue Sep 17 08:21:11 2013 -0700 182.3 @@ -1,43 +1,13 @@ 182.4 /* 182.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 182.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 182.7 - * 182.8 - * This code is free software; you can redistribute it and/or modify it 182.9 - * under the terms of the GNU General Public License version 2 only, as 182.10 - * published by the Free Software Foundation. 182.11 - * 182.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 182.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 182.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 182.15 - * version 2 for more details (a copy is included in the LICENSE file that 182.16 - * accompanied this code). 182.17 - * 182.18 - * You should have received a copy of the GNU General Public License version 182.19 - * 2 along with this work; if not, write to the Free Software Foundation, 182.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 182.21 - * 182.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 182.23 - * or visit www.oracle.com if you need additional information or have any 182.24 - * questions. 182.25 - */ 182.26 - 182.27 -/* 182.28 - * @test 182.29 + * @test /nodynamiccopyright/ 182.30 * @bug 8003280 182.31 * @summary Add lambda tests 182.32 * check that generic method reference is inferred when type parameters are omitted 182.33 - * @run main MethodReference44 182.34 + * @compile/fail/ref=MethodReference44.out -XDrawDiagnostics MethodReference44.java 182.35 */ 182.36 + 182.37 public class MethodReference44 { 182.38 182.39 - static int assertionCount = 0; 182.40 - 182.41 - static void assertTrue(boolean cond) { 182.42 - assertionCount++; 182.43 - if (!cond) 182.44 - throw new AssertionError(); 182.45 - } 182.46 - 182.47 static class SuperFoo<X> { } 182.48 182.49 static class Foo<X extends Number> extends SuperFoo<X> { } 182.50 @@ -56,12 +26,20 @@ 182.51 182.52 static <X extends Number> Foo<X> m() { return null; } 182.53 182.54 - static void g(SAM1 s) { assertTrue(false); } 182.55 - static void g(SAM2 s) { assertTrue(true); } 182.56 - static void g(SAM3 s) { assertTrue(false); } 182.57 + static void g1(SAM1 s) { } 182.58 + 182.59 + static void g2(SAM2 s) { } 182.60 + 182.61 + static void g3(SAM3 s) { } 182.62 + 182.63 + static void g4(SAM1 s) { } 182.64 + static void g4(SAM2 s) { } 182.65 + static void g4(SAM3 s) { } 182.66 182.67 public static void main(String[] args) { 182.68 - g(MethodReference44::m); 182.69 - assertTrue(assertionCount == 1); 182.70 + g1(MethodReference44::m); 182.71 + g2(MethodReference44::m); 182.72 + g3(MethodReference44::m); 182.73 + g4(MethodReference44::m); 182.74 } 182.75 }
183.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 183.2 +++ b/test/tools/javac/lambda/MethodReference44.out Tue Sep 17 08:21:11 2013 -0700 183.3 @@ -0,0 +1,4 @@ 183.4 +MethodReference44.java:40:11: compiler.err.cant.apply.symbol: kindname.method, g1, MethodReference44.SAM1, @864, kindname.class, MethodReference44, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number)) 183.5 +MethodReference44.java:42:11: compiler.err.cant.apply.symbol: kindname.method, g3, MethodReference44.SAM3, @932, kindname.class, MethodReference44, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.Object, java.lang.Number)) 183.6 +MethodReference44.java:43:9: compiler.err.ref.ambiguous: g4, kindname.method, g4(MethodReference44.SAM2), MethodReference44, kindname.method, g4(MethodReference44.SAM3), MethodReference44 183.7 +3 errors
184.1 --- a/test/tools/javac/lambda/MethodReference46.java Thu Sep 12 11:09:20 2013 -0700 184.2 +++ b/test/tools/javac/lambda/MethodReference46.java Tue Sep 17 08:21:11 2013 -0700 184.3 @@ -1,43 +1,13 @@ 184.4 /* 184.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 184.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 184.7 - * 184.8 - * This code is free software; you can redistribute it and/or modify it 184.9 - * under the terms of the GNU General Public License version 2 only, as 184.10 - * published by the Free Software Foundation. 184.11 - * 184.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 184.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 184.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 184.15 - * version 2 for more details (a copy is included in the LICENSE file that 184.16 - * accompanied this code). 184.17 - * 184.18 - * You should have received a copy of the GNU General Public License version 184.19 - * 2 along with this work; if not, write to the Free Software Foundation, 184.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 184.21 - * 184.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 184.23 - * or visit www.oracle.com if you need additional information or have any 184.24 - * questions. 184.25 - */ 184.26 - 184.27 -/* 184.28 - * @test 184.29 + * @test /nodynamiccopyright/ 184.30 * @bug 8003280 184.31 * @summary Add lambda tests 184.32 * check that generic method reference is inferred when type parameters are omitted 184.33 - * @run main MethodReference46 184.34 + * @compile/fail/ref=MethodReference46.out -XDrawDiagnostics MethodReference46.java 184.35 */ 184.36 + 184.37 public class MethodReference46 { 184.38 184.39 - static int assertionCount = 0; 184.40 - 184.41 - static void assertTrue(boolean cond) { 184.42 - assertionCount++; 184.43 - if (!cond) 184.44 - throw new AssertionError(); 184.45 - } 184.46 - 184.47 interface SAM1 { 184.48 void m(String s); 184.49 } 184.50 @@ -56,12 +26,20 @@ 184.51 184.52 static <X extends Number> void m(X fx) { } 184.53 184.54 - static void g(SAM1 s) { assertTrue(false); } 184.55 - static void g(SAM2 s) { assertTrue(true); } 184.56 - static void g(SAM3 s) { assertTrue(false); } 184.57 + static void g1(SAM1 s) { } 184.58 + 184.59 + static void g2(SAM2 s) { } 184.60 + 184.61 + static void g3(SAM3 s) { } 184.62 + 184.63 + static void g4(SAM1 s) { } 184.64 + static void g4(SAM2 s) { } 184.65 + static void g4(SAM3 s) { } 184.66 184.67 public static void main(String[] args) { 184.68 - g(MethodReference46::m); 184.69 - assertTrue(assertionCount == 1); 184.70 + g1(MethodReference46::m); 184.71 + g2(MethodReference46::m); 184.72 + g3(MethodReference46::m); 184.73 + g4(MethodReference46::m); 184.74 } 184.75 }
185.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 185.2 +++ b/test/tools/javac/lambda/MethodReference46.out Tue Sep 17 08:21:11 2013 -0700 185.3 @@ -0,0 +1,4 @@ 185.4 +MethodReference46.java:40:11: compiler.err.cant.apply.symbol: kindname.method, g1, MethodReference46.SAM1, @809, kindname.class, MethodReference46, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m, X, java.lang.String, kindname.class, MethodReference46, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)))) 185.5 +MethodReference46.java:42:11: compiler.err.cant.apply.symbol: kindname.method, g3, MethodReference46.SAM3, @877, kindname.class, MethodReference46, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m, X, java.lang.Object, kindname.class, MethodReference46, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Object, java.lang.Number)))) 185.6 +MethodReference46.java:43:9: compiler.err.ref.ambiguous: g4, kindname.method, g4(MethodReference46.SAM2), MethodReference46, kindname.method, g4(MethodReference46.SAM3), MethodReference46 185.7 +3 errors
186.1 --- a/test/tools/javac/lambda/MethodReference47.java Thu Sep 12 11:09:20 2013 -0700 186.2 +++ b/test/tools/javac/lambda/MethodReference47.java Tue Sep 17 08:21:11 2013 -0700 186.3 @@ -7,14 +7,6 @@ 186.4 */ 186.5 public class MethodReference47 { 186.6 186.7 - static int assertionCount = 0; 186.8 - 186.9 - static void assertTrue(boolean cond) { 186.10 - assertionCount++; 186.11 - if (!cond) 186.12 - throw new AssertionError(); 186.13 - } 186.14 - 186.15 interface SAM1 { 186.16 void m(Integer s); 186.17 } 186.18 @@ -34,7 +26,7 @@ 186.19 static void g2(SAM2 s) { } 186.20 186.21 public static void main(String[] args) { 186.22 - g1(MethodReference46::m); 186.23 - g2(MethodReference46::m); 186.24 + g1(MethodReference47::m); 186.25 + g2(MethodReference47::m); 186.26 } 186.27 }
187.1 --- a/test/tools/javac/lambda/MethodReference47.out Thu Sep 12 11:09:20 2013 -0700 187.2 +++ b/test/tools/javac/lambda/MethodReference47.out Tue Sep 17 08:21:11 2013 -0700 187.3 @@ -1,2 +1,2 @@ 187.4 -MethodReference47.java:38:9: compiler.err.ref.ambiguous: g2, kindname.method, g2(MethodReference47.SAM1), MethodReference47, kindname.method, g2(MethodReference47.SAM2), MethodReference47 187.5 +MethodReference47.java:30:9: compiler.err.ref.ambiguous: g2, kindname.method, g2(MethodReference47.SAM1), MethodReference47, kindname.method, g2(MethodReference47.SAM2), MethodReference47 187.6 1 error
188.1 --- a/test/tools/javac/lambda/MethodReference48.java Thu Sep 12 11:09:20 2013 -0700 188.2 +++ b/test/tools/javac/lambda/MethodReference48.java Tue Sep 17 08:21:11 2013 -0700 188.3 @@ -1,43 +1,13 @@ 188.4 /* 188.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 188.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 188.7 - * 188.8 - * This code is free software; you can redistribute it and/or modify it 188.9 - * under the terms of the GNU General Public License version 2 only, as 188.10 - * published by the Free Software Foundation. 188.11 - * 188.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 188.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 188.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 188.15 - * version 2 for more details (a copy is included in the LICENSE file that 188.16 - * accompanied this code). 188.17 - * 188.18 - * You should have received a copy of the GNU General Public License version 188.19 - * 2 along with this work; if not, write to the Free Software Foundation, 188.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 188.21 - * 188.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 188.23 - * or visit www.oracle.com if you need additional information or have any 188.24 - * questions. 188.25 - */ 188.26 - 188.27 -/* 188.28 - * @test 188.29 + * @test /nodynamiccopyright/ 188.30 * @bug 8003280 188.31 * @summary Add lambda tests 188.32 * check that raw qualifier in unbound method reference is inferred from descriptor 188.33 - * @run main MethodReference48 188.34 + * @compile/fail/ref=MethodReference48.out -XDrawDiagnostics MethodReference48.java 188.35 */ 188.36 + 188.37 public class MethodReference48 { 188.38 188.39 - static int assertionCount = 0; 188.40 - 188.41 - static void assertTrue(boolean cond) { 188.42 - assertionCount++; 188.43 - if (!cond) 188.44 - throw new AssertionError(); 188.45 - } 188.46 - 188.47 static class Foo<X> { 188.48 X m() { return null; }; 188.49 } 188.50 @@ -54,12 +24,20 @@ 188.51 Object m(Foo<Integer> fi); 188.52 } 188.53 188.54 - static void g(SAM1 s) { assertTrue(false); } //return type not compatible 188.55 - static void g(SAM2 s) { assertTrue(true); } //ok 188.56 - static void g(SAM3 s) { assertTrue(false); } //ok but less specific 188.57 + static void g1(SAM1 s) { } //return type not compatible 188.58 + 188.59 + static void g2(SAM2 s) { } //ok 188.60 + 188.61 + static void g3(SAM3 s) { } //ok 188.62 + 188.63 + static void g4(SAM1 s) { } //return type not compatible 188.64 + static void g4(SAM2 s) { } //ok 188.65 + static void g4(SAM3 s) { } //ok 188.66 188.67 public static void main(String[] args) { 188.68 - g(Foo::m); 188.69 - assertTrue(assertionCount == 1); 188.70 + g1(Foo::m); 188.71 + g2(Foo::m); 188.72 + g3(Foo::m); 188.73 + g4(Foo::m); 188.74 } 188.75 }
189.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 189.2 +++ b/test/tools/javac/lambda/MethodReference48.out Tue Sep 17 08:21:11 2013 -0700 189.3 @@ -0,0 +1,3 @@ 189.4 +MethodReference48.java:38:11: compiler.err.cant.apply.symbol: kindname.method, g1, MethodReference48.SAM1, @869, kindname.class, MethodReference48, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.String, MethodReference48.Foo<java.lang.Object>))) 189.5 +MethodReference48.java:41:9: compiler.err.ref.ambiguous: g4, kindname.method, g4(MethodReference48.SAM2), MethodReference48, kindname.method, g4(MethodReference48.SAM3), MethodReference48 189.6 +2 errors
190.1 --- a/test/tools/javac/lambda/MethodReference70.out Thu Sep 12 11:09:20 2013 -0700 190.2 +++ b/test/tools/javac/lambda/MethodReference70.out Tue Sep 17 08:21:11 2013 -0700 190.3 @@ -1,3 +1,3 @@ 190.4 MethodReference70.java:26:10: compiler.err.ref.ambiguous: g, kindname.method, <Z>g(MethodReference70.F<Z>), MethodReference70, kindname.method, <Z>g(MethodReference70.G<Z>), MethodReference70 190.5 -MethodReference70.java:26:11: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: Z) 190.6 +MethodReference70.java:26:11: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbols: kindname.method, m2, java.lang.Object,{(compiler.misc.inapplicable.method: kindname.method, MethodReference70, m2(java.lang.Integer), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.Integer))),(compiler.misc.inapplicable.method: kindname.method, MethodReference70, m2(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String)))}))) 190.7 2 errors
191.1 --- a/test/tools/javac/lambda/MethodReference71.out Thu Sep 12 11:09:20 2013 -0700 191.2 +++ b/test/tools/javac/lambda/MethodReference71.out Tue Sep 17 08:21:11 2013 -0700 191.3 @@ -1,3 +1,3 @@ 191.4 MethodReference71.java:24:10: compiler.err.ref.ambiguous: g, kindname.method, <Z>g(MethodReference71.F<Z>), MethodReference71, kindname.method, <Z>g(MethodReference71.G<Z>), MethodReference71 191.5 -MethodReference71.java:24:11: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: Z) 191.6 +MethodReference71.java:24:11: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer[], java.lang.Object, kindname.class, MethodReference71, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.Integer))))) 191.7 2 errors
192.1 --- a/test/tools/javac/lambda/MostSpecific04.java Thu Sep 12 11:09:20 2013 -0700 192.2 +++ b/test/tools/javac/lambda/MostSpecific04.java Tue Sep 17 08:21:11 2013 -0700 192.3 @@ -1,5 +1,5 @@ 192.4 /* 192.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 192.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 192.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 192.8 * 192.9 * This code is free software; you can redistribute it and/or modify it 192.10 @@ -26,17 +26,10 @@ 192.11 * @bug 8003280 192.12 * @summary Add lambda tests 192.13 * Structural most specific doesn't handle cases with wildcards in functional interfaces 192.14 + * @compile/fail/ref=MostSpecific04.out -XDrawDiagnostics MostSpecific04.java 192.15 */ 192.16 public class MostSpecific04 { 192.17 192.18 - static int assertionCount = 0; 192.19 - 192.20 - static void assertTrue(boolean cond) { 192.21 - assertionCount++; 192.22 - if (!cond) 192.23 - throw new AssertionError(); 192.24 - } 192.25 - 192.26 interface DoubleMapper<T> { 192.27 double map(T t); 192.28 } 192.29 @@ -46,13 +39,13 @@ 192.30 } 192.31 192.32 static class MyList<E> { 192.33 - void map(DoubleMapper<? super E> m) { assertTrue(false); } 192.34 - void map(LongMapper<? super E> m) { assertTrue(true); } 192.35 + void map(DoubleMapper<? super E> m) { } 192.36 + void map(LongMapper<? super E> m) { } 192.37 } 192.38 192.39 public static void main(String[] args) { 192.40 MyList<String> ls = new MyList<String>(); 192.41 - ls.map(e->e.length()); 192.42 - assertTrue(assertionCount == 1); 192.43 + ls.map(e->e.length()); //ambiguous - implicit 192.44 + ls.map((String e)->e.length()); //ok 192.45 } 192.46 }
193.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 193.2 +++ b/test/tools/javac/lambda/MostSpecific04.out Tue Sep 17 08:21:11 2013 -0700 193.3 @@ -0,0 +1,2 @@ 193.4 +MostSpecific04.java:48:11: compiler.err.ref.ambiguous: map, kindname.method, map(MostSpecific04.DoubleMapper<? super E>), MostSpecific04.MyList, kindname.method, map(MostSpecific04.LongMapper<? super E>), MostSpecific04.MyList 193.5 +1 error
194.1 --- a/test/tools/javac/lambda/MostSpecific05.java Thu Sep 12 11:09:20 2013 -0700 194.2 +++ b/test/tools/javac/lambda/MostSpecific05.java Tue Sep 17 08:21:11 2013 -0700 194.3 @@ -1,5 +1,5 @@ 194.4 /* 194.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 194.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 194.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 194.8 * 194.9 * This code is free software; you can redistribute it and/or modify it 194.10 @@ -26,17 +26,10 @@ 194.11 * @bug 8003280 194.12 * @summary Add lambda tests 194.13 * Structural most specific doesn't handle cases with wildcards in functional interfaces 194.14 + * @compile/fail/ref=MostSpecific05.out -XDrawDiagnostics MostSpecific05.java 194.15 */ 194.16 public class MostSpecific05 { 194.17 194.18 - static int assertionCount = 0; 194.19 - 194.20 - static void assertTrue(boolean cond) { 194.21 - assertionCount++; 194.22 - if (!cond) 194.23 - throw new AssertionError(); 194.24 - } 194.25 - 194.26 interface ObjectConverter<T extends Object> { 194.27 T map(Object o); 194.28 } 194.29 @@ -46,13 +39,13 @@ 194.30 } 194.31 194.32 static class MyMapper<A extends Object, B extends Number> { 194.33 - void map(ObjectConverter<? extends A> m) { assertTrue(false); } 194.34 - void map(NumberConverter<? extends B> m) { assertTrue(true); } 194.35 + void map(ObjectConverter<? extends A> m) { } 194.36 + void map(NumberConverter<? extends B> m) { } 194.37 } 194.38 194.39 public static void main(String[] args) { 194.40 MyMapper<Number, Double> mm = new MyMapper<Number, Double>(); 194.41 - mm.map(e->1.0); 194.42 - assertTrue(assertionCount == 1); 194.43 + mm.map(e->1.0); //ambiguous - implicit 194.44 + mm.map((Object e)->1.0); //ok 194.45 } 194.46 }
195.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 195.2 +++ b/test/tools/javac/lambda/MostSpecific05.out Tue Sep 17 08:21:11 2013 -0700 195.3 @@ -0,0 +1,2 @@ 195.4 +MostSpecific05.java:48:11: compiler.err.ref.ambiguous: map, kindname.method, map(MostSpecific05.ObjectConverter<? extends A>), MostSpecific05.MyMapper, kindname.method, map(MostSpecific05.NumberConverter<? extends B>), MostSpecific05.MyMapper 195.5 +1 error
196.1 --- a/test/tools/javac/lambda/MostSpecific08.java Thu Sep 12 11:09:20 2013 -0700 196.2 +++ b/test/tools/javac/lambda/MostSpecific08.java Tue Sep 17 08:21:11 2013 -0700 196.3 @@ -25,7 +25,7 @@ 196.4 * @test 196.5 * @bug 8008813 196.6 * @summary Structural most specific fails when method reference is passed to overloaded method 196.7 - * @compile MostSpecific08.java 196.8 + * @compile/fail/ref=MostSpecific08.out -XDrawDiagnostics MostSpecific08.java 196.9 */ 196.10 class MostSpecific08 { 196.11 196.12 @@ -51,12 +51,14 @@ 196.13 } 196.14 196.15 void testMref(Tester t) { 196.16 - IntResult pr = t.apply(C::getInt); 196.17 - ReferenceResult<Integer> rr = t.apply(C::getInteger); 196.18 + IntResult pr = t.apply(C::getInt); //ok - unoverloaded mref 196.19 + ReferenceResult<Integer> rr = t.apply(C::getInteger); //ok - unoverloaded mref 196.20 } 196.21 196.22 void testLambda(Tester t) { 196.23 - IntResult pr = t.apply(c->c.getInt()); 196.24 - ReferenceResult<Integer> rr = t.apply(c->c.getInteger()); 196.25 + IntResult pr1 = t.apply(c->c.getInt()); //ambiguous - implicit 196.26 + IntResult pr2 = t.apply((C c)->c.getInt()); //ok 196.27 + ReferenceResult<Integer> rr1 = t.apply(c->c.getInteger()); //ambiguous - implicit 196.28 + ReferenceResult<Integer> rr2 = t.apply((C c)->c.getInteger()); //ok 196.29 } 196.30 }
197.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 197.2 +++ b/test/tools/javac/lambda/MostSpecific08.out Tue Sep 17 08:21:11 2013 -0700 197.3 @@ -0,0 +1,4 @@ 197.4 +MostSpecific08.java:59:26: compiler.err.ref.ambiguous: apply, kindname.method, apply(MostSpecific08.PrimitiveFunction), MostSpecific08.Tester, kindname.method, <Z>apply(MostSpecific08.ReferenceFunction<Z>), MostSpecific08.Tester 197.5 +MostSpecific08.java:61:41: compiler.err.ref.ambiguous: apply, kindname.method, apply(MostSpecific08.PrimitiveFunction), MostSpecific08.Tester, kindname.method, <Z>apply(MostSpecific08.ReferenceFunction<Z>), MostSpecific08.Tester 197.6 +MostSpecific08.java:61:47: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: MostSpecific08.IntResult, MostSpecific08.ReferenceResult<java.lang.Integer>) 197.7 +3 errors
198.1 --- a/test/tools/javac/lambda/TargetType01.java Thu Sep 12 11:09:20 2013 -0700 198.2 +++ b/test/tools/javac/lambda/TargetType01.java Tue Sep 17 08:21:11 2013 -0700 198.3 @@ -26,7 +26,7 @@ 198.4 * @bug 8003280 8009131 198.5 * @summary Add lambda tests 198.6 * check nested case of overload resolution and lambda parameter inference 198.7 - * @compile TargetType01.java 198.8 + * @compile/fail/ref=TargetType01.out -XDrawDiagnostics TargetType01.java 198.9 */ 198.10 198.11 class TargetType01 {
199.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 199.2 +++ b/test/tools/javac/lambda/TargetType01.out Tue Sep 17 08:21:11 2013 -0700 199.3 @@ -0,0 +1,3 @@ 199.4 +TargetType01.java:45:9: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01 199.5 +TargetType01.java:45:26: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01 199.6 +2 errors
200.1 --- a/test/tools/javac/lambda/TargetType02.java Thu Sep 12 11:09:20 2013 -0700 200.2 +++ b/test/tools/javac/lambda/TargetType02.java Tue Sep 17 08:21:11 2013 -0700 200.3 @@ -1,5 +1,5 @@ 200.4 /* 200.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 200.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 200.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 200.8 * 200.9 * This code is free software; you can redistribute it and/or modify it 200.10 @@ -27,19 +27,11 @@ 200.11 * @summary Add lambda tests 200.12 * check overload resolution and target type inference w.r.t. generic methods 200.13 * @author Maurizio Cimadamore 200.14 - * @run main TargetType02 200.15 + * @compile/fail/ref=TargetType02.out -XDrawDiagnostics TargetType02.java 200.16 */ 200.17 200.18 public class TargetType02 { 200.19 200.20 - static int assertionCount = 0; 200.21 - 200.22 - static void assertTrue(boolean cond) { 200.23 - assertionCount++; 200.24 - if (!cond) 200.25 - throw new AssertionError(); 200.26 - } 200.27 - 200.28 interface S1<X extends Number> { 200.29 X m(Integer x); 200.30 } 200.31 @@ -48,15 +40,16 @@ 200.32 abstract X m(Integer x); 200.33 } 200.34 200.35 - static <Z extends Number> void call(S1<Z> s) { s.m(1); assertTrue(true); } 200.36 - static <Z extends String> void call(S2<Z> s) { s.m(2); assertTrue(false); } 200.37 + static <Z extends Number> void call1(S1<Z> s) { } 200.38 + 200.39 + static <Z extends String> void call2(S2<Z> s) { } 200.40 + 200.41 + static <Z extends Number> void call3(S1<Z> s) { } 200.42 + static <Z extends String> void call3(S2<Z> s) { } 200.43 200.44 void test() { 200.45 - call(i -> { toString(); return i; }); 200.46 - } 200.47 - 200.48 - public static void main(String[] args) { 200.49 - new TargetType02().test(); 200.50 - assertTrue(assertionCount == 1); 200.51 + call1(i -> { toString(); return i; }); 200.52 + call2(i -> { toString(); return i; }); 200.53 + call3(i -> { toString(); return i; }); 200.54 } 200.55 }
201.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 201.2 +++ b/test/tools/javac/lambda/TargetType02.out Tue Sep 17 08:21:11 2013 -0700 201.3 @@ -0,0 +1,3 @@ 201.4 +TargetType02.java:52:14: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String) 201.5 +TargetType02.java:53:9: compiler.err.ref.ambiguous: call3, kindname.method, <Z>call3(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call3(TargetType02.S2<Z>), TargetType02 201.6 +2 errors
202.1 --- a/test/tools/javac/lambda/TargetType10.java Thu Sep 12 11:09:20 2013 -0700 202.2 +++ b/test/tools/javac/lambda/TargetType10.java Tue Sep 17 08:21:11 2013 -0700 202.3 @@ -1,10 +1,10 @@ 202.4 /* 202.5 * @test /nodynamiccopyright/ 202.6 - * @bug 8003280 202.7 + * @bug 8003280 8016177 202.8 * @summary Add lambda tests 202.9 * check that wildcards in the target method of a lambda conversion is handled correctly 202.10 * @author Maurizio Cimadamore 202.11 - * @compile/fail/ref=TargetType10.out -XDrawDiagnostics TargetType10.java 202.12 + * @compile TargetType10.java 202.13 */ 202.14 202.15 class TargetType10 {
203.1 --- a/test/tools/javac/lambda/TargetType10.out Thu Sep 12 11:09:20 2013 -0700 203.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 203.3 @@ -1,2 +0,0 @@ 203.4 -TargetType10.java:17:18: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: B,A) 203.5 -1 error
204.1 --- a/test/tools/javac/lambda/TargetType21.java Thu Sep 12 11:09:20 2013 -0700 204.2 +++ b/test/tools/javac/lambda/TargetType21.java Tue Sep 17 08:21:11 2013 -0700 204.3 @@ -26,8 +26,10 @@ 204.4 204.5 void test() { 204.6 call(x -> { throw new Exception(); }); //ambiguous 204.7 + call((Integer x) -> { System.out.println(""); }); //ok (only one is void) 204.8 + call((Integer x) -> { return (Object) null; }); //ok (only one returns Object) 204.9 call(x -> { System.out.println(""); }); //ambiguous 204.10 - call(x -> { return (Object) null; }); //cyclic inference 204.11 + call(x -> { return (Object) null; }); //ambiguous 204.12 call(x -> { return null; }); //ambiguous 204.13 } 204.14 }
205.1 --- a/test/tools/javac/lambda/TargetType21.out Thu Sep 12 11:09:20 2013 -0700 205.2 +++ b/test/tools/javac/lambda/TargetType21.out Tue Sep 17 08:21:11 2013 -0700 205.3 @@ -1,5 +1,7 @@ 205.4 TargetType21.java:28:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 205.5 -TargetType21.java:29:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 205.6 -TargetType21.java:30:13: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: A) 205.7 -TargetType21.java:31:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 205.8 -4 errors 205.9 +TargetType21.java:31:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 205.10 +TargetType21.java:32:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 205.11 +TargetType21.java:32:13: compiler.err.cant.apply.symbol: kindname.method, call, TargetType21.SAM2, @888, kindname.class, TargetType21, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))) 205.12 +TargetType21.java:33:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 205.13 +TargetType21.java:33:13: compiler.err.cant.apply.symbol: kindname.method, call, TargetType21.SAM2, @946, kindname.class, TargetType21, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))) 205.14 +6 errors
206.1 --- a/test/tools/javac/lambda/TargetType24.java Thu Sep 12 11:09:20 2013 -0700 206.2 +++ b/test/tools/javac/lambda/TargetType24.java Tue Sep 17 08:21:11 2013 -0700 206.3 @@ -29,11 +29,14 @@ 206.4 } 206.5 206.6 void test(Array<String> as, final Array<Character> ac) { 206.7 - final boolean b1 = as.forAll(s -> ac.forAll(c -> false)); //ok 206.8 + final boolean b1 = as.forAll((String s) -> ac.forAll((Character c) -> false)); //ok 206.9 + final boolean b2 = as.forAll(s -> ac.forAll(c -> false)); //ambiguous 206.10 + final boolean b3 = as.forAll((String s) -> ac.forAll(c -> false)); //ambiguous 206.11 + final boolean b4 = as.forAll(s -> ac.forAll((Character c) -> false)); //ambiguous 206.12 final String s1 = as.forAll2(s -> ac.forAll2(c -> "")); //ok 206.13 - final boolean b2 = as.forAll(s -> ac.forAll(c -> "" )); //fail 206.14 + final boolean b5 = as.forAll(s -> ac.forAll(c -> "" )); //fail 206.15 final String s2 = as.forAll2(s -> ac.forAll2(c -> false)); //fail 206.16 - final boolean b3 = as.forAll((F<String, Boolean>)s -> ac.forAll((F<Character, Boolean>)c -> "")); //fail 206.17 + final boolean b6 = as.forAll((F<String, Boolean>)s -> ac.forAll((F<Character, Boolean>)c -> "")); //fail 206.18 final String s3 = as.forAll((FSub<String, String>)s -> ac.forAll((FSub<Character, String>)c -> false)); //fail 206.19 } 206.20 }
207.1 --- a/test/tools/javac/lambda/TargetType24.out Thu Sep 12 11:09:20 2013 -0700 207.2 +++ b/test/tools/javac/lambda/TargetType24.out Tue Sep 17 08:21:11 2013 -0700 207.3 @@ -1,5 +1,11 @@ 207.4 -TargetType24.java:34:37: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, boolean) 207.5 -TargetType24.java:35:45: compiler.err.cant.apply.symbol: kindname.method, forAll2, TargetType24.FSub<java.lang.Character,java.lang.String>, @945, kindname.class, TargetType24.Array<A>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String))) 207.6 -TargetType24.java:36:101: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Boolean)) 207.7 -TargetType24.java:37:104: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String)) 207.8 -4 errors 207.9 +TargetType24.java:33:30: compiler.err.ref.ambiguous: forAll, kindname.method, forAll(TargetType24.F<A,java.lang.Boolean>), TargetType24.Array, kindname.method, forAll(TargetType24.FSub<A,java.lang.String>), TargetType24.Array 207.10 +TargetType24.java:33:45: compiler.err.ref.ambiguous: forAll, kindname.method, forAll(TargetType24.F<A,java.lang.Boolean>), TargetType24.Array, kindname.method, forAll(TargetType24.FSub<A,java.lang.String>), TargetType24.Array 207.11 +TargetType24.java:34:54: compiler.err.ref.ambiguous: forAll, kindname.method, forAll(TargetType24.F<A,java.lang.Boolean>), TargetType24.Array, kindname.method, forAll(TargetType24.FSub<A,java.lang.String>), TargetType24.Array 207.12 +TargetType24.java:35:30: compiler.err.ref.ambiguous: forAll, kindname.method, forAll(TargetType24.F<A,java.lang.Boolean>), TargetType24.Array, kindname.method, forAll(TargetType24.FSub<A,java.lang.String>), TargetType24.Array 207.13 +TargetType24.java:37:30: compiler.err.ref.ambiguous: forAll, kindname.method, forAll(TargetType24.F<A,java.lang.Boolean>), TargetType24.Array, kindname.method, forAll(TargetType24.FSub<A,java.lang.String>), TargetType24.Array 207.14 +TargetType24.java:37:45: compiler.err.ref.ambiguous: forAll, kindname.method, forAll(TargetType24.F<A,java.lang.Boolean>), TargetType24.Array, kindname.method, forAll(TargetType24.FSub<A,java.lang.String>), TargetType24.Array 207.15 +TargetType24.java:37:52: compiler.err.cant.apply.symbol: kindname.method, forAll, TargetType24.F<java.lang.Character,java.lang.Boolean>, @1149, kindname.class, TargetType24.Array<A>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Boolean))) 207.16 +TargetType24.java:38:53: compiler.err.cant.apply.symbol: kindname.method, forAll2, TargetType24.FSub<java.lang.Character,java.lang.String>, @1221, kindname.class, TargetType24.Array<A>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String))) 207.17 +TargetType24.java:39:101: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Boolean)) 207.18 +TargetType24.java:40:104: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String)) 207.19 +10 errors
208.1 --- a/test/tools/javac/lambda/TargetType26.out Thu Sep 12 11:09:20 2013 -0700 208.2 +++ b/test/tools/javac/lambda/TargetType26.out Tue Sep 17 08:21:11 2013 -0700 208.3 @@ -1,2 +1,2 @@ 208.4 -TargetType26.java:16:11: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: Z) 208.5 +TargetType26.java:16:11: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.not.a.functional.intf: java.lang.Object)) 208.6 1 error
209.1 --- a/test/tools/javac/lambda/TargetType27.out Thu Sep 12 11:09:20 2013 -0700 209.2 +++ b/test/tools/javac/lambda/TargetType27.out Tue Sep 17 08:21:11 2013 -0700 209.3 @@ -1,2 +1,2 @@ 209.4 -TargetType27.java:18:10: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: R) 209.5 +TargetType27.java:18:10: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: A,R, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.not.a.functional.intf: java.lang.Object))) 209.6 1 error
210.1 --- a/test/tools/javac/lambda/TargetType39.out Thu Sep 12 11:09:20 2013 -0700 210.2 +++ b/test/tools/javac/lambda/TargetType39.out Tue Sep 17 08:21:11 2013 -0700 210.3 @@ -1,3 +1,3 @@ 210.4 -TargetType39.java:19:13: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: U) 210.5 -TargetType39.java:20:13: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: V) 210.6 +TargetType39.java:19:13: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U,V, (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: TargetType39.SAM<java.lang.String,java.lang.Void>, TargetType39.SAM<java.lang.Object,V>))) 210.7 +TargetType39.java:20:13: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U,V, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.not.a.functional.intf: java.lang.Object)))) 210.8 2 errors
211.1 --- a/test/tools/javac/lambda/TargetType43.out Thu Sep 12 11:09:20 2013 -0700 211.2 +++ b/test/tools/javac/lambda/TargetType43.out Tue Sep 17 08:21:11 2013 -0700 211.3 @@ -1,4 +1,5 @@ 211.4 TargetType43.java:13:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object) 211.5 TargetType43.java:13:30: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null) 211.6 +TargetType43.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Object, @359, kindname.class, TargetType43, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: java.lang.Object)) 211.7 TargetType43.java:14:21: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null) 211.8 -3 errors 211.9 +4 errors
212.1 --- a/test/tools/javac/lambda/TargetType66.java Thu Sep 12 11:09:20 2013 -0700 212.2 +++ b/test/tools/javac/lambda/TargetType66.java Tue Sep 17 08:21:11 2013 -0700 212.3 @@ -17,8 +17,8 @@ 212.4 void g(SAM2 s2) { } 212.5 212.6 void test() { 212.7 - g(x->{ String s = x; }); //g(SAM1) 212.8 - g(x->{ Integer i = x; }); //g(SAM2) 212.9 + g(x->{ String s = x; }); //ambiguous 212.10 + g(x->{ Integer i = x; }); //ambiguous 212.11 g(x->{ Object o = x; }); //ambiguous 212.12 g(x->{ Character c = x; }); //error: inapplicable methods 212.13 g(x->{ Character c = ""; }); //error: incompatible types
213.1 --- a/test/tools/javac/lambda/TargetType66.out Thu Sep 12 11:09:20 2013 -0700 213.2 +++ b/test/tools/javac/lambda/TargetType66.out Tue Sep 17 08:21:11 2013 -0700 213.3 @@ -1,4 +1,9 @@ 213.4 +TargetType66.java:20:9: compiler.err.ref.ambiguous: g, kindname.method, g(TargetType66.SAM1), TargetType66, kindname.method, g(TargetType66.SAM2), TargetType66 213.5 +TargetType66.java:21:9: compiler.err.ref.ambiguous: g, kindname.method, g(TargetType66.SAM1), TargetType66, kindname.method, g(TargetType66.SAM2), TargetType66 213.6 +TargetType66.java:21:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer) 213.7 TargetType66.java:22:9: compiler.err.ref.ambiguous: g, kindname.method, g(TargetType66.SAM1), TargetType66, kindname.method, g(TargetType66.SAM2), TargetType66 213.8 -TargetType66.java:23:9: compiler.err.cant.apply.symbols: kindname.method, g, @578,{(compiler.misc.inapplicable.method: kindname.method, TargetType66, g(TargetType66.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.bad.arg.types.in.lambda: java.lang.String, (compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Character))))),(compiler.misc.inapplicable.method: kindname.method, TargetType66, g(TargetType66.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.bad.arg.types.in.lambda: java.lang.Integer, (compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.Character)))))} 213.9 +TargetType66.java:23:9: compiler.err.ref.ambiguous: g, kindname.method, g(TargetType66.SAM1), TargetType66, kindname.method, g(TargetType66.SAM2), TargetType66 213.10 +TargetType66.java:23:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Character) 213.11 +TargetType66.java:24:9: compiler.err.ref.ambiguous: g, kindname.method, g(TargetType66.SAM1), TargetType66, kindname.method, g(TargetType66.SAM2), TargetType66 213.12 TargetType66.java:24:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Character) 213.13 -3 errors 213.14 +8 errors
214.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 214.2 +++ b/test/tools/javac/lambda/bridge/template_tests/BridgeMethodTestCase.java Tue Sep 17 08:21:11 2013 -0700 214.3 @@ -0,0 +1,421 @@ 214.4 +/* 214.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 214.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 214.7 + * 214.8 + * This code is free software; you can redistribute it and/or modify it 214.9 + * under the terms of the GNU General Public License version 2 only, as 214.10 + * published by the Free Software Foundation. 214.11 + * 214.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 214.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 214.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 214.15 + * version 2 for more details (a copy is included in the LICENSE file that 214.16 + * accompanied this code). 214.17 + * 214.18 + * You should have received a copy of the GNU General Public License version 214.19 + * 2 along with this work; if not, write to the Free Software Foundation, 214.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 214.21 + * 214.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 214.23 + * or visit www.oracle.com if you need additional information or have any 214.24 + * questions. 214.25 + * 214.26 + */ 214.27 +import java.io.File; 214.28 +import java.io.IOException; 214.29 +import java.lang.reflect.Method; 214.30 +import java.util.ArrayList; 214.31 +import java.util.Arrays; 214.32 +import java.util.HashMap; 214.33 +import java.util.List; 214.34 +import java.util.Map; 214.35 +import java.util.StringJoiner; 214.36 + 214.37 +import org.testng.annotations.BeforeMethod; 214.38 +import org.testng.annotations.Test; 214.39 + 214.40 +import tools.javac.combo.*; 214.41 + 214.42 +import static org.testng.Assert.fail; 214.43 + 214.44 +/** 214.45 + * BridgeMethodTestCase -- used for asserting linkage to bridges under separate compilation. 214.46 + * 214.47 + * Example test case: 214.48 + * public void test1() throws IOException, ReflectiveOperationException { 214.49 + * compileSpec("C(Bc1(A))"); 214.50 + * assertLinkage("C", LINKAGE_ERROR, "B1"); 214.51 + * recompileSpec("C(Bc1(Ac0))", "A"); 214.52 + * assertLinkage("C", "A0", "B1"); 214.53 + * } 214.54 + * 214.55 + * This compiles A, B, and C, asserts that C.m()Object does not exist, asserts 214.56 + * that C.m()Number eventually invokes B.m()Number, recompiles B, and then asserts 214.57 + * that the result of calling C.m()Object now arrives at A. 214.58 + * 214.59 + * @author Brian Goetz 214.60 + */ 214.61 + 214.62 +@Test 214.63 +public abstract class BridgeMethodTestCase extends JavacTemplateTestBase { 214.64 + 214.65 + private static final String TYPE_LETTERS = "ABCDIJK"; 214.66 + 214.67 + private static final String BASE_INDEX_CLASS = "class C0 {\n" + 214.68 + " int val;\n" + 214.69 + " C0(int val) { this.val = val; }\n" + 214.70 + " public int getVal() { return val; }\n" + 214.71 + "}\n"; 214.72 + private static final String INDEX_CLASS_TEMPLATE = "class C#ID extends C#PREV {\n" + 214.73 + " C#ID(int val) { super(val); }\n" + 214.74 + "}\n"; 214.75 + 214.76 + 214.77 + 214.78 + protected static String LINKAGE_ERROR = "-1"; 214.79 + 214.80 + private List<File> compileDirs = new ArrayList<>(); 214.81 + 214.82 + /** 214.83 + * Compile all the classes in a class spec, and put them on the classpath. 214.84 + * 214.85 + * The spec is the specification for a nest of classes, using the following notation 214.86 + * A, B represent abstract classes 214.87 + * C represents a concrete class 214.88 + * I, J, K represent interfaces 214.89 + * Lowercase 'c' following a class means that the method m() is concrete 214.90 + * Lowercase 'a' following a class or interface means that the method m() is abstract 214.91 + * Lowercase 'd' following an interface means that the method m() is default 214.92 + * A number 0, 1, or 2 following the lowercase letter indicates the return type of that method 214.93 + * 0 = Object, 1 = Number, 2 = Integer (these form an inheritance chain so bridges are generated) 214.94 + * A classes supertypes follow its method spec, in parentheses 214.95 + * Examples: 214.96 + * C(Ia0, Jd0) -- C extends I and J, I has abstract m()Object, J has default m()Object 214.97 + * Cc1(Ia0) -- C has concrete m()Number, extends I with abstract m()Object 214.98 + * If a type must appear multiple times, its full spec must be in the first occurrence 214.99 + * Example: 214.100 + * C(I(Kd0), J(K)) 214.101 + */ 214.102 + protected void compileSpec(String spec) throws IOException { 214.103 + compileSpec(spec, false); 214.104 + } 214.105 + 214.106 + /** 214.107 + * Compile all the classes in a class spec, and assert that there were compilation errors. 214.108 + */ 214.109 + protected void compileSpec(String spec, String... errorKeys) throws IOException { 214.110 + compileSpec(spec, false, errorKeys); 214.111 + } 214.112 + 214.113 + protected void compileSpec(String spec, boolean debug, String... errorKeys) throws IOException { 214.114 + ClassModel cm = new Parser(spec).parseClassModel(); 214.115 + for (int i = 0; i <= cm.maxIndex() ; i++) { 214.116 + if (debug) System.out.println(indexClass(i)); 214.117 + addSourceFile(String.format("C%d.java", i), new StringTemplate(indexClass(i))); 214.118 + } 214.119 + for (Map.Entry<String, ClassModel> e : classes(cm).entrySet()) { 214.120 + if (debug) System.out.println(e.getValue().toSource()); 214.121 + addSourceFile(e.getKey() + ".java", new StringTemplate(e.getValue().toSource())); 214.122 + } 214.123 + compileDirs.add(compile(true)); 214.124 + resetSourceFiles(); 214.125 + if (errorKeys.length == 0) 214.126 + assertCompileSucceeded(); 214.127 + else 214.128 + assertCompileErrors(errorKeys); 214.129 + } 214.130 + 214.131 + /** 214.132 + * Recompile only a subset of classes in the class spec, as named by names, 214.133 + * and put them on the classpath such that they shadow earlier versions of that class. 214.134 + */ 214.135 + protected void recompileSpec(String spec, String... names) throws IOException { 214.136 + List<String> nameList = Arrays.asList(names); 214.137 + ClassModel cm = new Parser(spec).parseClassModel(); 214.138 + for (int i = 0; i <= cm.maxIndex() ; i++) { 214.139 + addSourceFile(String.format("C%d.java", i), new StringTemplate(indexClass(i))); 214.140 + } 214.141 + for (Map.Entry<String, ClassModel> e : classes(cm).entrySet()) 214.142 + if (nameList.contains(e.getKey())) 214.143 + addSourceFile(e.getKey() + ".java", new StringTemplate(e.getValue().toSource())); 214.144 + compileDirs.add(compile(Arrays.asList(classPaths()), true)); 214.145 + resetSourceFiles(); 214.146 + assertCompileSucceeded(); 214.147 + } 214.148 + 214.149 + protected void assertLinkage(String name, String... expected) throws ReflectiveOperationException { 214.150 + for (int i=0; i<expected.length; i++) { 214.151 + String e = expected[i]; 214.152 + if (e.equals(LINKAGE_ERROR)) { 214.153 + try { 214.154 + int actual = invoke(name, i); 214.155 + fail("Expected linkage error, got" + fromNum(actual)); 214.156 + } 214.157 + catch (LinkageError x) { 214.158 + // success 214.159 + } 214.160 + } 214.161 + else { 214.162 + if (e.length() == 1) 214.163 + e += "0"; 214.164 + int expectedInt = toNum(e); 214.165 + int actual = invoke(name, i); 214.166 + if (expectedInt != actual) 214.167 + fail(String.format("Expected %s but found %s for %s.m()%d", fromNum(expectedInt), fromNum(actual), name, i)); 214.168 + } 214.169 + } 214.170 + } 214.171 + 214.172 + private Map<String, ClassModel> classes(ClassModel cm) { 214.173 + HashMap<String, ClassModel> m = new HashMap<>(); 214.174 + classesHelper(cm, m); 214.175 + return m; 214.176 + } 214.177 + 214.178 + private String indexClass(int index) { 214.179 + if (index == 0) { 214.180 + return BASE_INDEX_CLASS; 214.181 + } else { 214.182 + return INDEX_CLASS_TEMPLATE 214.183 + .replace("#ID", String.valueOf(index)) 214.184 + .replace("#PREV", String.valueOf(index - 1)); 214.185 + } 214.186 + } 214.187 + 214.188 + private static String overrideName(int index) { 214.189 + return "C" + index; 214.190 + } 214.191 + 214.192 + private void classesHelper(ClassModel cm, Map<String, ClassModel> m) { 214.193 + if (!m.containsKey(cm.name)) 214.194 + m.put(cm.name, cm); 214.195 + for (ClassModel s : cm.supertypes) 214.196 + classesHelper(s, m); 214.197 + } 214.198 + 214.199 + private static String fromNum(int num) { 214.200 + return String.format("%c%d", TYPE_LETTERS.charAt(num / 10), num % 10); 214.201 + } 214.202 + 214.203 + private static int toNum(String name, int index) { 214.204 + return 10*(TYPE_LETTERS.indexOf(name.charAt(0))) + index; 214.205 + } 214.206 + 214.207 + private static int toNum(String string) { 214.208 + return 10*(TYPE_LETTERS.indexOf(string.charAt(0))) + Integer.parseInt(string.substring(1, 2)); 214.209 + } 214.210 + 214.211 + private int invoke(String name, int index) throws ReflectiveOperationException { 214.212 + File[] files = classPaths(); 214.213 + Class clazz = loadClass(name, files); 214.214 + Method[] ms = clazz.getMethods(); 214.215 + for (Method m : ms) { 214.216 + if (m.getName().equals("m") && m.getReturnType().getName().equals(overrideName(index))) { 214.217 + m.setAccessible(true); 214.218 + Object instance = clazz.newInstance(); 214.219 + Object c0 = m.invoke(instance); 214.220 + Method getVal = c0.getClass().getMethod("getVal"); 214.221 + getVal.setAccessible(true); 214.222 + return (int)getVal.invoke(c0); 214.223 + } 214.224 + } 214.225 + throw new NoSuchMethodError("cannot find method m()" + index + " in class " + name); 214.226 + } 214.227 + 214.228 + private File[] classPaths() { 214.229 + File[] files = new File[compileDirs.size()]; 214.230 + for (int i=0; i<files.length; i++) 214.231 + files[files.length - i - 1] = compileDirs.get(i); 214.232 + return files; 214.233 + } 214.234 + 214.235 + @BeforeMethod 214.236 + @Override 214.237 + public void reset() { 214.238 + compileDirs.clear(); 214.239 + super.reset(); 214.240 + } 214.241 + 214.242 + private static class ClassModel { 214.243 + 214.244 + enum MethodType { 214.245 + ABSTRACT('a'), CONCRETE('c'), DEFAULT('d'); 214.246 + 214.247 + public final char designator; 214.248 + 214.249 + MethodType(char designator) { 214.250 + this.designator = designator; 214.251 + } 214.252 + 214.253 + public static MethodType find(char c) { 214.254 + for (MethodType m : values()) 214.255 + if (m.designator == c) 214.256 + return m; 214.257 + throw new IllegalArgumentException(); 214.258 + } 214.259 + } 214.260 + 214.261 + private final String name; 214.262 + private final boolean isInterface; 214.263 + private final List<ClassModel> supertypes; 214.264 + private final MethodType methodType; 214.265 + private final int methodIndex; 214.266 + 214.267 + private ClassModel(String name, 214.268 + boolean anInterface, 214.269 + List<ClassModel> supertypes, 214.270 + MethodType methodType, 214.271 + int methodIndex) { 214.272 + this.name = name; 214.273 + isInterface = anInterface; 214.274 + this.supertypes = supertypes; 214.275 + this.methodType = methodType; 214.276 + this.methodIndex = methodIndex; 214.277 + } 214.278 + 214.279 + @Override 214.280 + public String toString() { 214.281 + StringBuilder sb = new StringBuilder(); 214.282 + sb.append(name); 214.283 + if (methodType != null) { 214.284 + sb.append(methodType.designator); 214.285 + sb.append(methodIndex); 214.286 + } 214.287 + if (!supertypes.isEmpty()) { 214.288 + sb.append("("); 214.289 + for (int i=0; i<supertypes.size(); i++) { 214.290 + if (i > 0) 214.291 + sb.append(","); 214.292 + sb.append(supertypes.get(i).toString()); 214.293 + } 214.294 + sb.append(")"); 214.295 + } 214.296 + return sb.toString(); 214.297 + } 214.298 + 214.299 + int maxIndex() { 214.300 + int maxSoFar = methodIndex; 214.301 + for (ClassModel cm : supertypes) { 214.302 + maxSoFar = Math.max(cm.maxIndex(), maxSoFar); 214.303 + } 214.304 + return maxSoFar; 214.305 + } 214.306 + 214.307 + public String toSource() { 214.308 + String extendsClause = ""; 214.309 + String implementsClause = ""; 214.310 + String methodBody = ""; 214.311 + boolean isAbstract = "AB".contains(name); 214.312 + 214.313 + for (ClassModel s : supertypes) { 214.314 + if (!s.isInterface) { 214.315 + extendsClause = String.format("extends %s", s.name); 214.316 + break; 214.317 + } 214.318 + } 214.319 + 214.320 + StringJoiner sj = new StringJoiner(", "); 214.321 + for (ClassModel s : supertypes) 214.322 + if (s.isInterface) 214.323 + sj.add(s.name); 214.324 + if (sj.length() > 0) { 214.325 + if (isInterface) 214.326 + implementsClause = "extends " + sj.toString(); 214.327 + else 214.328 + implementsClause = "implements " + sj.toString(); 214.329 + } 214.330 + if (methodType != null) { 214.331 + switch (methodType) { 214.332 + case ABSTRACT: 214.333 + methodBody = String.format("public abstract %s m();", overrideName(methodIndex)); 214.334 + break; 214.335 + case CONCRETE: 214.336 + methodBody = String.format("public %s m() { return new %s(%d); };", 214.337 + overrideName(methodIndex), overrideName(methodIndex), toNum(name, methodIndex)); 214.338 + break; 214.339 + case DEFAULT: 214.340 + methodBody = String.format("public default %s m() { return new %s(%d); };", 214.341 + overrideName(methodIndex), overrideName(methodIndex), toNum(name, methodIndex)); 214.342 + break; 214.343 + 214.344 + } 214.345 + } 214.346 + 214.347 + return String.format("public %s %s %s %s %s { %s }", isAbstract ? "abstract" : "", 214.348 + isInterface ? "interface" : "class", 214.349 + name, extendsClause, implementsClause, methodBody); 214.350 + } 214.351 + } 214.352 + 214.353 + private static class Parser { 214.354 + private final String input; 214.355 + private final char[] chars; 214.356 + private int index; 214.357 + 214.358 + private Parser(String s) { 214.359 + input = s; 214.360 + chars = s.toCharArray(); 214.361 + } 214.362 + 214.363 + private char peek() { 214.364 + return index < chars.length ? chars[index] : 0; 214.365 + } 214.366 + 214.367 + private boolean peek(String validChars) { 214.368 + return validChars.indexOf(peek()) >= 0; 214.369 + } 214.370 + 214.371 + private char advanceIf(String validChars) { 214.372 + if (peek(validChars)) 214.373 + return chars[index++]; 214.374 + else 214.375 + return 0; 214.376 + } 214.377 + 214.378 + private char advanceIfDigit() { 214.379 + return advanceIf("0123456789"); 214.380 + } 214.381 + 214.382 + private int index() { 214.383 + StringBuilder buf = new StringBuilder(); 214.384 + char c = advanceIfDigit(); 214.385 + while (c != 0) { 214.386 + buf.append(c); 214.387 + c = advanceIfDigit(); 214.388 + } 214.389 + return Integer.valueOf(buf.toString()); 214.390 + } 214.391 + 214.392 + private char advance() { 214.393 + return chars[index++]; 214.394 + } 214.395 + 214.396 + private char expect(String validChars) { 214.397 + char c = advanceIf(validChars); 214.398 + if (c == 0) 214.399 + throw new IllegalArgumentException(String.format("Expecting %s at position %d of %s", validChars, index, input)); 214.400 + return c; 214.401 + } 214.402 + 214.403 + public ClassModel parseClassModel() { 214.404 + List<ClassModel> supers = new ArrayList<>(); 214.405 + char name = expect(TYPE_LETTERS); 214.406 + boolean isInterface = "IJK".indexOf(name) >= 0; 214.407 + ClassModel.MethodType methodType = peek(isInterface ? "ad" : "ac") ? ClassModel.MethodType.find(advance()) : null; 214.408 + int methodIndex = 0; 214.409 + if (methodType != null) { 214.410 + methodIndex = index(); 214.411 + } 214.412 + if (peek() == '(') { 214.413 + advance(); 214.414 + supers.add(parseClassModel()); 214.415 + while (peek() == ',') { 214.416 + advance(); 214.417 + supers.add(parseClassModel()); 214.418 + } 214.419 + expect(")"); 214.420 + } 214.421 + return new ClassModel(new String(new char[]{ name }), isInterface, supers, methodType, methodIndex); 214.422 + } 214.423 + } 214.424 +}
215.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 215.2 +++ b/test/tools/javac/lambda/bridge/template_tests/BridgeMethodsTemplateTest.java Tue Sep 17 08:21:11 2013 -0700 215.3 @@ -0,0 +1,1082 @@ 215.4 +/* 215.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 215.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 215.7 + * 215.8 + * This code is free software; you can redistribute it and/or modify it 215.9 + * under the terms of the GNU General Public License version 2 only, as 215.10 + * published by the Free Software Foundation. 215.11 + * 215.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 215.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 215.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 215.15 + * version 2 for more details (a copy is included in the LICENSE file that 215.16 + * accompanied this code). 215.17 + * 215.18 + * You should have received a copy of the GNU General Public License version 215.19 + * 2 along with this work; if not, write to the Free Software Foundation, 215.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 215.21 + * 215.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 215.23 + * or visit www.oracle.com if you need additional information or have any 215.24 + * questions. 215.25 + * 215.26 + */ 215.27 +import java.io.IOException; 215.28 + 215.29 +import org.testng.annotations.Test; 215.30 + 215.31 +/** 215.32 + * BridgeMethodsTemplateTest 215.33 + * 215.34 + * @author Brian Goetz 215.35 + */ 215.36 +@Test 215.37 +public class BridgeMethodsTemplateTest extends BridgeMethodTestCase { 215.38 + 215.39 + /* 215.40 + * Cc1(A) -> Cc1(Ac0) 215.41 + * 215.42 + * 0*: Inherited from A 215.43 + * 1: Declared in C 215.44 + */ 215.45 + public void test1() throws IOException, ReflectiveOperationException { 215.46 + compileSpec("Cc1(A)"); 215.47 + assertLinkage("C", LINKAGE_ERROR, "C1"); 215.48 + recompileSpec("Cc1(Ac0)", "A"); 215.49 + assertLinkage("C", "A0", "C1"); 215.50 + } 215.51 + 215.52 + /* 215.53 + * Cc1(I) -> Cc1(Id0) 215.54 + * 215.55 + * 0*: Inherited default from I 215.56 + * 1: Declared in C 215.57 + */ 215.58 + public void test2() throws IOException, ReflectiveOperationException { 215.59 + compileSpec("Cc1(I)"); 215.60 + assertLinkage("C", LINKAGE_ERROR, "C1"); 215.61 + recompileSpec("Cc1(Id0)", "I"); 215.62 + assertLinkage("C", "I0", "C1"); 215.63 + } 215.64 + 215.65 + /* 215.66 + * C(Bc1(A)) -> C(Bc1(Ac0)) 215.67 + * 215.68 + * 0*: Inherited from A 215.69 + * 1: Inherited from B 215.70 + */ 215.71 + public void test3() throws IOException, ReflectiveOperationException { 215.72 + compileSpec("C(Bc1(A))"); 215.73 + assertLinkage("C", LINKAGE_ERROR, "B1"); 215.74 + recompileSpec("C(Bc1(Ac0))", "A"); 215.75 + assertLinkage("C", "A0", "B1"); 215.76 + } 215.77 + 215.78 + /* 215.79 + * C(B(Ac0)) -> C(Bc1(Ac0)) 215.80 + * 215.81 + * 0: Inherited from B (through bridge) 215.82 + * 1: Inherited from B 215.83 + */ 215.84 + public void test4() throws IOException, ReflectiveOperationException { 215.85 + compileSpec("C(B(Ac0))"); 215.86 + assertLinkage("C", "A0", LINKAGE_ERROR); 215.87 + recompileSpec("C(Bc1(Ac0))", "B"); 215.88 + assertLinkage("C", "B1", "B1"); 215.89 + } 215.90 + 215.91 + /* 215.92 + * C(B(A)) -> C(Bc1(Ac0)) 215.93 + * 215.94 + * 0: Inherited from B (through bridge) 215.95 + * 1: Inherited from B 215.96 + */ 215.97 + public void test5() throws IOException, ReflectiveOperationException { 215.98 + compileSpec("C(B(A))"); 215.99 + assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR); 215.100 + recompileSpec("C(Bc1(Ac0))", "A", "B"); 215.101 + assertLinkage("C", "B1", "B1"); 215.102 + } 215.103 + 215.104 + /* 215.105 + * C(Ac1(I)) -> C(Ac1(Id0)) 215.106 + * 215.107 + * 0*: Inherited default from I 215.108 + * 1: Inherited from A 215.109 + */ 215.110 + public void test6() throws IOException, ReflectiveOperationException { 215.111 + compileSpec("C(Ac1(I))"); 215.112 + assertLinkage("C", LINKAGE_ERROR, "A1"); 215.113 + recompileSpec("C(Ac1(Id0))", "I"); 215.114 + assertLinkage("C", "I0", "A1"); 215.115 + } 215.116 + 215.117 + /* 215.118 + * C(A(Id0)) -> C(Ac1(Id0)) 215.119 + * 215.120 + * 0: Inherited from A (through bridge) 215.121 + * 1: Inherited from A 215.122 + */ 215.123 + public void test7() throws IOException, ReflectiveOperationException { 215.124 + compileSpec("C(A(Id0))"); 215.125 + assertLinkage("C", "I0", LINKAGE_ERROR); 215.126 + recompileSpec("C(Ac1(Id0))", "A"); 215.127 + assertLinkage("C", "A1", "A1"); 215.128 + } 215.129 + 215.130 + /* 215.131 + * C(A(I)) -> C(Ac1(Id0)) 215.132 + * 215.133 + * 0*: Inherited from A (through bridge) 215.134 + * 1*: Inherited from A 215.135 + */ 215.136 + public void test8() throws IOException, ReflectiveOperationException { 215.137 + compileSpec("C(A(I))"); 215.138 + assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR); 215.139 + recompileSpec("C(Ac1(Id0))", "A", "I"); 215.140 + assertLinkage("C", "A1", "A1"); 215.141 + } 215.142 + 215.143 + /* 215.144 + * C(Id1(J)) -> C(Id1(Jd0)) 215.145 + * 215.146 + * 0*: Inherited default from J 215.147 + * 1: Inherited default from I 215.148 + */ 215.149 + public void test9() throws IOException, ReflectiveOperationException { 215.150 + compileSpec("C(Id1(J))"); 215.151 + assertLinkage("C", LINKAGE_ERROR, "I1"); 215.152 + recompileSpec("C(Id1(Jd0))", "J"); 215.153 + assertLinkage("C", "J0", "I1"); 215.154 + } 215.155 + 215.156 + /* 215.157 + * C(I(Jd0)) -> C(Id1(Jd0)) 215.158 + * 215.159 + * 0: Inherited default from I (through bridge) 215.160 + * 1: Inherited default from I 215.161 + */ 215.162 + public void test10() throws IOException, ReflectiveOperationException { 215.163 + compileSpec("C(I(Jd0))"); 215.164 + assertLinkage("C", "J0", LINKAGE_ERROR); 215.165 + recompileSpec("C(Id1(Jd0))", "I"); 215.166 + assertLinkage("C", "I1", "I1"); 215.167 + } 215.168 + 215.169 + /* 215.170 + * C(I(J)) -> C(Id1(Jd0)) 215.171 + * 215.172 + * 0: Inherited default from I (through bridge) 215.173 + * 1: Inherited default from I 215.174 + */ 215.175 + public void test11() throws IOException, ReflectiveOperationException { 215.176 + compileSpec("C(I(J))"); 215.177 + assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR); 215.178 + recompileSpec("C(Id1(Jd0))", "I", "J"); 215.179 + assertLinkage("C", "I1", "I1"); 215.180 + } 215.181 + 215.182 + /* 215.183 + * Cc2(B(Ac0)) -> Cc2(Bc1(Ac0)) 215.184 + * 215.185 + * 0: Declared in C (through bridge) 215.186 + * 1*: Inherited from B 215.187 + * 2: Declared in C 215.188 + */ 215.189 + public void test12() throws IOException, ReflectiveOperationException { 215.190 + compileSpec("Cc2(B(Ac0))"); 215.191 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.192 + recompileSpec("Cc2(Bc1(Ac0))", "B"); 215.193 + assertLinkage("C", "C2", "B1", "C2"); 215.194 + } 215.195 + 215.196 + /* 215.197 + * Cc2(B(Aa0)) -> Cc2(Bc1(Aa0)) 215.198 + * 215.199 + * 0: Bridge in C (through bridge) 215.200 + * 1*: Inherited from B 215.201 + * 2: Declared in C 215.202 + */ 215.203 + public void test13() throws IOException, ReflectiveOperationException { 215.204 + compileSpec("Cc2(B(Aa0))"); 215.205 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.206 + recompileSpec("Cc2(Bc1(Aa0))", "B"); 215.207 + assertLinkage("C", "C2", "B1", "C2"); 215.208 + } 215.209 + 215.210 + /* 215.211 + * Cc2(Bc1(A)) -> Cc2(Bc1(Ac0)) 215.212 + * 215.213 + * 0*: Inherited from A 215.214 + * 1: Declared in C (through bridge) 215.215 + * 2: Declared in C 215.216 + */ 215.217 + public void test14() throws IOException, ReflectiveOperationException { 215.218 + compileSpec("Cc2(Bc1(A))"); 215.219 + assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); 215.220 + recompileSpec("Cc2(Bc1(Ac0))", "A"); 215.221 + assertLinkage("C", "A0", "C2", "C2"); 215.222 + } 215.223 + 215.224 + /* 215.225 + * Cc2(Ba1(A)) -> Cc2(Ba1(Ac0)) 215.226 + * 215.227 + * 0*: Inherited from A 215.228 + * 1: Declared in C (through bridge) 215.229 + * 2: Declared in C 215.230 + */ 215.231 + public void test15() throws IOException, ReflectiveOperationException { 215.232 + compileSpec("Cc2(Ba1(A))"); 215.233 + assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); 215.234 + recompileSpec("Cc2(Ba1(Ac0))", "A"); 215.235 + assertLinkage("C", "A0", "C2", "C2"); 215.236 + } 215.237 + 215.238 + /* 215.239 + * Cc2(B(A)) -> Cc2(Bc1(Ac0)) 215.240 + * 215.241 + * 0*: Inherited from B (through bridge) 215.242 + * 1*: Inherited from B 215.243 + * 2: Declared in C 215.244 + */ 215.245 + public void test16() throws IOException, ReflectiveOperationException { 215.246 + compileSpec("Cc2(B(A))"); 215.247 + assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2"); 215.248 + recompileSpec("Cc2(Bc1(Ac0))", "B", "A"); 215.249 + assertLinkage("C", "B1", "B1", "C2"); 215.250 + } 215.251 + 215.252 + /* 215.253 + * Cc2(A(Id0)) -> Cc2(Ac1(Id0)) 215.254 + * 215.255 + * 0: Declared in C (through bridge) 215.256 + * 1*: Inherited from A 215.257 + * 2: Declared in C 215.258 + */ 215.259 + public void test17() throws IOException, ReflectiveOperationException { 215.260 + compileSpec("Cc2(A(Id0))"); 215.261 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.262 + recompileSpec("Cc2(Ac1(Id0))", "A"); 215.263 + assertLinkage("C", "C2", "A1", "C2"); 215.264 + } 215.265 + 215.266 + /* 215.267 + * Cc2(A(Ia0)) -> Cc2(Ac1(Ia0)) 215.268 + * 215.269 + * 0: Declared in C (through bridge) 215.270 + * 1*: Inherited from A 215.271 + * 2: Declared in C 215.272 + */ 215.273 + public void test18() throws IOException, ReflectiveOperationException { 215.274 + compileSpec("Cc2(A(Ia0))"); 215.275 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.276 + recompileSpec("Cc2(Ac1(Ia0))", "A"); 215.277 + assertLinkage("C", "C2", "A1", "C2"); 215.278 + } 215.279 + 215.280 + /* 215.281 + * Cc2(Ac1(I)) -> Cc2(Ac1(Id0)) 215.282 + * 215.283 + * 0*: Inherited from I 215.284 + * 1: Declared in C (through bridge) 215.285 + * 2: Declared in C 215.286 + */ 215.287 + public void test19() throws IOException, ReflectiveOperationException { 215.288 + compileSpec("Cc2(Ac1(I))"); 215.289 + assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); 215.290 + recompileSpec("Cc2(Ac1(Id0))", "I"); 215.291 + assertLinkage("C", "I0", "C2", "C2"); 215.292 + } 215.293 + 215.294 + /* 215.295 + * Cc2(Aa1(I)) -> Cc2(Aa1(Id0)) 215.296 + * 215.297 + * 0*: Inherited from I 215.298 + * 1: Declared in C (through bridge) 215.299 + * 2: Declared in C 215.300 + */ 215.301 + public void test20() throws IOException, ReflectiveOperationException { 215.302 + compileSpec("Cc2(Aa1(I))"); 215.303 + assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); 215.304 + recompileSpec("Cc2(Aa1(Id0))", "I"); 215.305 + assertLinkage("C", "I0", "C2", "C2"); 215.306 + } 215.307 + 215.308 + /* 215.309 + * Cc2(A(I)) -> Cc2(Ac1(Id0)) 215.310 + * 215.311 + * 0*: Inherited from A (through bridge) 215.312 + * 1*: Inherited from A 215.313 + * 2: Declared in C 215.314 + */ 215.315 + public void test21() throws IOException, ReflectiveOperationException { 215.316 + compileSpec("Cc2(A(I))"); 215.317 + assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2"); 215.318 + recompileSpec("Cc2(Ac1(Id0))", "A", "I"); 215.319 + assertLinkage("C", "A1", "A1", "C2"); 215.320 + } 215.321 + 215.322 + /* 215.323 + * Cc2(J(Id0)) -> Cc2(Jd1(Id0)) 215.324 + * 215.325 + * 0: Declared in C (through bridge) 215.326 + * 1*: Inherited default from J 215.327 + * 2: Declared in C 215.328 + */ 215.329 + public void test22() throws IOException, ReflectiveOperationException { 215.330 + compileSpec("Cc2(J(Id0))"); 215.331 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.332 + recompileSpec("Cc2(Jd1(Id0))", "J"); 215.333 + assertLinkage("C", "C2", "J1", "C2"); 215.334 + } 215.335 + 215.336 + /* 215.337 + * Cc2(J(Ia0)) -> Cc2(Jd1(Ia0)) 215.338 + * 215.339 + * 0: Declared in C (through bridge) 215.340 + * 1*: Inherited default from J 215.341 + * 2: Declared in C 215.342 + */ 215.343 + public void test23() throws IOException, ReflectiveOperationException { 215.344 + compileSpec("Cc2(J(Ia0))"); 215.345 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.346 + recompileSpec("Cc2(Jd1(Ia0))", "J"); 215.347 + assertLinkage("C", "C2", "J1", "C2"); 215.348 + } 215.349 + 215.350 + /* 215.351 + * Cc2(Jd1(I)) -> Cc2(Jd1(Id0)) 215.352 + * 215.353 + * 0*: Inherited default from I 215.354 + * 1: Declared in C (through bridge) 215.355 + * 2: Declared in C 215.356 + */ 215.357 + public void test24() throws IOException, ReflectiveOperationException { 215.358 + compileSpec("Cc2(Jd1(I))"); 215.359 + assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); 215.360 + recompileSpec("Cc2(Jd1(Id0))", "I"); 215.361 + assertLinkage("C", "I0", "C2", "C2"); 215.362 + } 215.363 + 215.364 + /* 215.365 + * Cc2(Ja1(I)) -> Cc2(Ja1(Id0)) 215.366 + * 215.367 + * 0*: Inherited default from I 215.368 + * 1: Declared in C (through bridge) 215.369 + * 2: Declared in C 215.370 + */ 215.371 + public void test25() throws IOException, ReflectiveOperationException { 215.372 + compileSpec("Cc2(Ja1(I))"); 215.373 + assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); 215.374 + recompileSpec("Cc2(Ja1(Id0))", "I"); 215.375 + assertLinkage("C", "I0", "C2", "C2"); 215.376 + } 215.377 + 215.378 + /* 215.379 + * Cc2(J(I)) -> Cc2(Jd1(Id0)) 215.380 + * 215.381 + * 0*: Inherited default from J (through bridge) 215.382 + * 1*: Inherited default from J 215.383 + * 2: Declared in C 215.384 + */ 215.385 + public void test26() throws IOException, ReflectiveOperationException { 215.386 + compileSpec("Cc2(J(I))"); 215.387 + assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2"); 215.388 + recompileSpec("Cc2(Jd1(Id0))", "J", "I"); 215.389 + assertLinkage("C", "J1", "J1", "C2"); 215.390 + } 215.391 + 215.392 + /* 215.393 + * C(Ac1, I) -> C(Ac1, Id0) 215.394 + * 215.395 + * 0*: Inherited default from I 215.396 + * 1: Inherited from A 215.397 + */ 215.398 + public void test27() throws IOException, ReflectiveOperationException { 215.399 + compileSpec("C(Ac1,I)"); 215.400 + assertLinkage("C", LINKAGE_ERROR, "A1"); 215.401 + recompileSpec("C(Ac1,Id0)", "I"); 215.402 + assertLinkage("C", "I0", "A1"); 215.403 + } 215.404 + 215.405 + /* 215.406 + * C(A, Id0) -> C(Ac1, Id0) 215.407 + * 215.408 + * 0*: Inherited default from I 215.409 + * 1: Inherited from A 215.410 + */ 215.411 + public void test28() throws IOException, ReflectiveOperationException { 215.412 + compileSpec("C(A,Id0)"); 215.413 + assertLinkage("C", "I0", LINKAGE_ERROR); 215.414 + recompileSpec("C(Ac1,Id0)", "A"); 215.415 + assertLinkage("C", "I0", "A1"); 215.416 + } 215.417 + 215.418 + /* 215.419 + * C(A, I) -> C(Ac1, Id0) 215.420 + * 215.421 + * 0*: Inherited default from I 215.422 + * 1: Inherited from A 215.423 + */ 215.424 + public void test29() throws IOException, ReflectiveOperationException { 215.425 + compileSpec("C(A,I)"); 215.426 + assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR); 215.427 + recompileSpec("C(Ac1,Id0)", "A", "I"); 215.428 + assertLinkage("C", "I0", "A1"); 215.429 + } 215.430 + 215.431 + /* 215.432 + * Cc2(Ac1, I) -> Cc2(Ac1, Id0) 215.433 + * 215.434 + * 0*: Inherited default from I 215.435 + * 1: Declared in C (through bridge) 215.436 + * 2: Declared in C 215.437 + */ 215.438 + public void test30() throws IOException, ReflectiveOperationException { 215.439 + compileSpec("Cc2(Ac1,I)"); 215.440 + assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); 215.441 + recompileSpec("Cc2(Ac1,Id0)", "I"); 215.442 + assertLinkage("C", "I0", "C2", "C2"); 215.443 + } 215.444 + 215.445 + /* 215.446 + * Cc2(Aa1, I) -> Cc2(Aa1, Id0) 215.447 + * 215.448 + * 0*: Inherited default from I 215.449 + * 1: Declared in C (through bridge) 215.450 + * 2: Declared in C 215.451 + */ 215.452 + public void test31() throws IOException, ReflectiveOperationException { 215.453 + compileSpec("Cc2(Aa1,I)"); 215.454 + assertLinkage("C", LINKAGE_ERROR, "C2", "C2"); 215.455 + recompileSpec("Cc2(Aa1,Id0)", "I"); 215.456 + assertLinkage("C", "I0", "C2", "C2"); 215.457 + } 215.458 + 215.459 + /* 215.460 + * Cc2(A, Id0) -> Cc2(Ac1, Id0) 215.461 + * 215.462 + * 0: Declared in C (through bridge) 215.463 + * 1*: Inherited from A 215.464 + * 2: Declared in C 215.465 + */ 215.466 + public void test32() throws IOException, ReflectiveOperationException { 215.467 + compileSpec("Cc2(A,Id0)"); 215.468 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.469 + recompileSpec("Cc2(Ac1,Id0)", "A"); 215.470 + assertLinkage("C", "C2", "A1", "C2"); 215.471 + } 215.472 + 215.473 + /* 215.474 + * Cc2(A, Ia0) -> Cc2(Ac1, Ia0) 215.475 + * 215.476 + * 0: Declared in C (through bridge) 215.477 + * 1*: Inherited from A 215.478 + * 2: Declared in C 215.479 + */ 215.480 + public void test33() throws IOException, ReflectiveOperationException { 215.481 + compileSpec("Cc2(A,Ia0)"); 215.482 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.483 + recompileSpec("Cc2(Ac1,Ia0)", "A"); 215.484 + assertLinkage("C", "C2", "A1", "C2"); 215.485 + } 215.486 + 215.487 + /* 215.488 + * Cc2(A, I) -> Cc2(Ac1, Id0) 215.489 + * 215.490 + * 0*: Inherited from A 215.491 + * 1*: Inherited default from I 215.492 + * 2: Declared in C 215.493 + */ 215.494 + public void test34() throws IOException, ReflectiveOperationException { 215.495 + compileSpec("Cc2(A,I)"); 215.496 + assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2"); 215.497 + recompileSpec("Cc2(Ac1,Id0)", "A", "I"); 215.498 + assertLinkage("C", "I0", "A1", "C2"); 215.499 + } 215.500 + 215.501 + /* 215.502 + * Cc2(Id0, J) -> Cc2(Id0, Jd1) 215.503 + * 215.504 + * 0: Declared in C (through bridge) 215.505 + * 1*: Inherited default from J 215.506 + * 2: Declared in C 215.507 + */ 215.508 + public void test35() throws IOException, ReflectiveOperationException { 215.509 + compileSpec("Cc2(Id0,J)"); 215.510 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.511 + recompileSpec("Cc2(Id0,Jd1)", "J"); 215.512 + assertLinkage("C", "C2", "J1", "C2"); 215.513 + } 215.514 + 215.515 + /* 215.516 + * Cc2(Ia0, J) -> Cc2(Ia0, Jd1) 215.517 + * 215.518 + * 0: Declared in C (through bridge) 215.519 + * 1*: Inherited default from J 215.520 + * 2: Declared in C 215.521 + */ 215.522 + public void test36() throws IOException, ReflectiveOperationException { 215.523 + compileSpec("Cc2(Ia0,J)"); 215.524 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.525 + recompileSpec("Cc2(Ia0,Jd1)", "J"); 215.526 + assertLinkage("C", "C2", "J1", "C2"); 215.527 + } 215.528 + 215.529 + /* 215.530 + * Cc2(I, J) -> Cc2(Id0, Jd1) 215.531 + * 215.532 + * 0*: Inherited default from I 215.533 + * 1*: Inherited default from J 215.534 + * 2: Declared in C 215.535 + */ 215.536 + public void test37() throws IOException, ReflectiveOperationException { 215.537 + compileSpec("Cc2(I,J)"); 215.538 + assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2"); 215.539 + recompileSpec("Cc2(Id0,Jd1)", "I", "J"); 215.540 + assertLinkage("C", "I0", "J1", "C2"); 215.541 + } 215.542 + 215.543 + /* 215.544 + * C(A(Id0), J(Id0)) -> C(Ac1(Id0), J(Id0)) 215.545 + * 215.546 + * 0: Inherited default from I 215.547 + * 0*: Inherited from A (through bridge) 215.548 + * 1*: Inherited from A 215.549 + */ 215.550 + public void test38() throws IOException, ReflectiveOperationException { 215.551 + compileSpec("C(A(Id0),J(Id0))"); 215.552 + assertLinkage("C", "I0", LINKAGE_ERROR); 215.553 + recompileSpec("C(Ac1(Id0),J(Id0))", "A"); 215.554 + assertLinkage("C", "A1", "A1"); 215.555 + } 215.556 + 215.557 + /* 215.558 + * C(A(Id0), J(Id0)) -> C(A(Id0), Jd1(Id0)) 215.559 + * 215.560 + * 0: Inherited default from I 215.561 + * 0: Inherited default from J (through bridge) 215.562 + * 1*: Inherited default from J 215.563 + */ 215.564 + public void test39() throws IOException, ReflectiveOperationException { 215.565 + compileSpec("C(A(Id0),J(Id0))"); 215.566 + assertLinkage("C", "I0", LINKAGE_ERROR); 215.567 + recompileSpec("C(A(Id0),Jd1(Id0))", "J"); 215.568 + assertLinkage("C", "J1", "J1"); 215.569 + } 215.570 + 215.571 + /* 215.572 + * C(A(Id0), J(Id0)) -> C(Ac2(Id0), Jd1(Id0)) 215.573 + * 215.574 + * 0: Inherited default from I 215.575 + * 0*: Inherited from A (new bridge in A beats new bridge in J) 215.576 + * 1*: Inherited default from J 215.577 + * 2: Inherited from A 215.578 + */ 215.579 + public void test40() throws IOException, ReflectiveOperationException { 215.580 + compileSpec("C(A(Id0),J(Id0))"); 215.581 + assertLinkage("C", "I0", LINKAGE_ERROR); 215.582 + recompileSpec("C(Ac2(Id0),Jd1(Id0))", "A", "J"); 215.583 + assertLinkage("C", "A2", "J1", "A2"); 215.584 + } 215.585 + 215.586 + /* 215.587 + * C(J(Id0), K(Id0)) -> C(Jd1(Id0), K(Id0)) 215.588 + * 215.589 + * 0: Inherited from I 215.590 + * 0*: Inherited default from J (through bridge) 215.591 + * 1: Inherited default from J 215.592 + */ 215.593 + public void test41() throws IOException, ReflectiveOperationException { 215.594 + compileSpec("C(J(Id0),K(Id0))"); 215.595 + assertLinkage("C", "I0", LINKAGE_ERROR); 215.596 + recompileSpec("C(Jd1(Id0),K(Id0))", "J"); 215.597 + assertLinkage("C", "J1", "J1"); 215.598 + } 215.599 + 215.600 + /* 215.601 + * C(Ac2(Id0), J(Id0)) -> C(Ac2(Id0), Jd1(Id0)) 215.602 + * 215.603 + * 0: Inherited from A (bridge in A beats new bridge in J) 215.604 + * 1*: Inherited default from J 215.605 + * 2: Inherited from A 215.606 + */ 215.607 + public void test42() throws IOException, ReflectiveOperationException { 215.608 + compileSpec("C(Ac2(Id0),J(Id0))"); 215.609 + assertLinkage("C", "A2", LINKAGE_ERROR, "A2"); 215.610 + recompileSpec("C(Ac2(Id0),Jd1(Id0))", "J"); 215.611 + assertLinkage("C", "A2", "J1", "A2"); 215.612 + } 215.613 + 215.614 + /* 215.615 + * C(Ac2(Ia0), J(Ia0)) -> C(Ac2(Ia0), Jd1(Ia0)) 215.616 + * 215.617 + * 0: Inherited from A (bridge in A beats new bridge in J) 215.618 + * 1*: Inherited default from J 215.619 + * 2: Inherited from A 215.620 + */ 215.621 + public void test43() throws IOException, ReflectiveOperationException { 215.622 + compileSpec("C(Ac2(Ia0),J(Ia0))"); 215.623 + assertLinkage("C", "A2", LINKAGE_ERROR, "A2"); 215.624 + recompileSpec("C(Ac2(Ia0),Jd1(Ia0))", "J"); 215.625 + assertLinkage("C", "A2", "J1", "A2"); 215.626 + } 215.627 + 215.628 + /* 215.629 + * C(A(Id0), Jd1(Id0)) -> C(Ac2(Id0), Jd1(Id0)) 215.630 + * 215.631 + * 0: Inherited from J 215.632 + * 0*: Inherited from A (new bridge in A beats bridge in J) 215.633 + * 1: Inherited default from J 215.634 + * 2*: Inherited from A 215.635 + */ 215.636 + public void test44() throws IOException, ReflectiveOperationException { 215.637 + compileSpec("C(A(Id0),Jd1(Id0))"); 215.638 + assertLinkage("C", "J1", "J1", LINKAGE_ERROR); 215.639 + recompileSpec("C(Ac2(Id0),Jd1(Id0))", "A"); 215.640 + assertLinkage("C", "A2", "J1", "A2"); 215.641 + } 215.642 + 215.643 + /* 215.644 + * C(A(Ia0), Jd1(Ia0)) -> C(Ac2(Ia0), Jd1(Ia0)) 215.645 + * 215.646 + * 0: Inherited from J 215.647 + * 0*: Inherited from A (new bridge in A beats bridge in J) 215.648 + * 1: Inherited default from J 215.649 + * 2*: Inherited from A 215.650 + */ 215.651 + public void test45() throws IOException, ReflectiveOperationException { 215.652 + compileSpec("C(A(Ia0),Jd1(Ia0))"); 215.653 + assertLinkage("C", "J1", "J1", LINKAGE_ERROR); 215.654 + recompileSpec("C(Ac2(Ia0),Jd1(Ia0))", "A"); 215.655 + assertLinkage("C", "A2", "J1", "A2"); 215.656 + } 215.657 + 215.658 + /* 215.659 + * Cc2(A(Id0), J(Id0)) -> Cc2(Ac1(Id0), J(Id0)) 215.660 + * 215.661 + * 0: Declared in C (through bridge) 215.662 + * 1*: Inherited from A 215.663 + * 2: Declared in C 215.664 + */ 215.665 + public void test46() throws IOException, ReflectiveOperationException { 215.666 + compileSpec("Cc2(A(Id0),J(Id0))"); 215.667 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.668 + recompileSpec("Cc2(Ac1(Id0),J(Id0))", "A"); 215.669 + assertLinkage("C", "C2", "A1", "C2"); 215.670 + } 215.671 + 215.672 + /* 215.673 + * Cc2(A(Ia0), J(Ia0)) -> Cc2(Ac1(Ia0), J(Ia0)) 215.674 + * 215.675 + * 0: Declared in C (through bridge) 215.676 + * 1*: Inherited from A 215.677 + * 2: Declared in C 215.678 + */ 215.679 + public void test47() throws IOException, ReflectiveOperationException { 215.680 + compileSpec("Cc2(A(Ia0),J(Ia0))"); 215.681 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.682 + recompileSpec("Cc2(Ac1(Ia0),J(Ia0))", "A"); 215.683 + assertLinkage("C", "C2", "A1", "C2"); 215.684 + } 215.685 + 215.686 + /* 215.687 + * Cc2(A(Id0), J(Id0)) -> Cc2(A(Id0), Jd1(Id0)) 215.688 + * 215.689 + * 0: Declared in C (through bridge) 215.690 + * 1*: Inherited default from J 215.691 + * 2: Declared in C 215.692 + */ 215.693 + public void test48() throws IOException, ReflectiveOperationException { 215.694 + compileSpec("Cc2(A(Id0),J(Id0))"); 215.695 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.696 + recompileSpec("Cc2(A(Id0),Jd1(Id0))", "J"); 215.697 + assertLinkage("C", "C2", "J1", "C2"); 215.698 + } 215.699 + 215.700 + /* 215.701 + * Cc2(A(Ia0), J(Ia0)) -> Cc2(A(Ia0), Jd1(Ia0)) 215.702 + * 215.703 + * 0: Declared in C (through bridge) 215.704 + * 1*: Inherited default from J 215.705 + * 2: Declared in C 215.706 + */ 215.707 + public void test49() throws IOException, ReflectiveOperationException { 215.708 + compileSpec("Cc2(A(Ia0),J(Ia0))"); 215.709 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.710 + recompileSpec("Cc2(A(Ia0),Jd1(Ia0))", "J"); 215.711 + assertLinkage("C", "C2", "J1", "C2"); 215.712 + } 215.713 + 215.714 + 215.715 + /* 215.716 + * Cc3(A(Id0), J(Id0)) -> Cc3(Ac1(Id0), Jd2(Id0)) 215.717 + * 215.718 + * 0: Bridge in C 215.719 + * 1*: Inherited from A 215.720 + * 2*: Inherited default from J 215.721 + * 3: Declared in C 215.722 + */ 215.723 + public void test50() throws IOException, ReflectiveOperationException { 215.724 + compileSpec("Cc3(A(Id0),J(Id0))"); 215.725 + assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3"); 215.726 + recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "A", "J"); 215.727 + assertLinkage("C", "C3", "A1", "J2", "C3"); 215.728 + } 215.729 + 215.730 + /* 215.731 + * Cc3(A(Ia0), J(Ia0)) -> Cc3(Ac1(Ia0), Jd2(Ia0)) 215.732 + * 215.733 + * 0: Bridge in C 215.734 + * 1*: Inherited from A 215.735 + * 2*: Inherited default from J 215.736 + * 3: Declared in C 215.737 + */ 215.738 + public void test51() throws IOException, ReflectiveOperationException { 215.739 + compileSpec("Cc3(A(Ia0),J(Ia0))"); 215.740 + assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3"); 215.741 + recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "A", "J"); 215.742 + assertLinkage("C", "C3", "A1", "J2", "C3"); 215.743 + } 215.744 + 215.745 + /* 215.746 + * Cc2(J(Id0), K(Id0)) -> Cc2(Jd1(Id0), K(Id0)) 215.747 + * 215.748 + * 0: Declared in C (through bridge) 215.749 + * 1*: Inherited default from J 215.750 + * 2: Declared in C 215.751 + */ 215.752 + public void test52() throws IOException, ReflectiveOperationException { 215.753 + compileSpec("Cc2(J(Id0),K(Id0))"); 215.754 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.755 + recompileSpec("Cc2(Jd1(Id0),K(Id0))", "J"); 215.756 + assertLinkage("C", "C2", "J1", "C2"); 215.757 + } 215.758 + 215.759 + /* 215.760 + * Cc2(J(Ia0), K(Ia0)) -> Cc2(Jd1(Ia0), K(Ia0)) 215.761 + * 215.762 + * 0: Declared in C (through bridge) 215.763 + * 1*: Inherited default from J 215.764 + * 2: Declared in C 215.765 + */ 215.766 + public void test53() throws IOException, ReflectiveOperationException { 215.767 + compileSpec("Cc2(J(Ia0),K(Ia0))"); 215.768 + assertLinkage("C", "C2", LINKAGE_ERROR, "C2"); 215.769 + recompileSpec("Cc2(Jd1(Ia0),K(Ia0))", "J"); 215.770 + assertLinkage("C", "C2", "J1", "C2"); 215.771 + } 215.772 + 215.773 + /* 215.774 + * Cc3(J(Id0), K(Id0)) -> Cc3(Jd1(Id0), Kd2(Id0)) 215.775 + * 215.776 + * 0: Declared in C (through bridge) 215.777 + * 1*: Inherited default from J 215.778 + * 2*: Inherited default from K 215.779 + * 3: Declared in C 215.780 + */ 215.781 + public void test54() throws IOException, ReflectiveOperationException { 215.782 + compileSpec("Cc3(J(Id0),K(Id0))"); 215.783 + assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3"); 215.784 + recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "J", "K"); 215.785 + assertLinkage("C", "C3", "J1", "K2", "C3"); 215.786 + } 215.787 + 215.788 + /* 215.789 + * Cc3(J(Ia0), K(Ia0)) -> Cc3(Jd1(Ia0), Kd2(Ia0)) 215.790 + * 215.791 + * 0: Declared in C (through bridge) 215.792 + * 1*: Inherited default from J 215.793 + * 2*: Inherited default from K 215.794 + * 3: Declared in C 215.795 + */ 215.796 + public void test55() throws IOException, ReflectiveOperationException { 215.797 + compileSpec("Cc3(J(Ia0),K(Ia0))"); 215.798 + assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3"); 215.799 + recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "J", "K"); 215.800 + assertLinkage("C", "C3", "J1", "K2", "C3"); 215.801 + } 215.802 + 215.803 + /* 215.804 + * Cc3(Ac1(Id0), J(Id0)) -> Cc3(Ac1(Id0), Jd2(Id0)) 215.805 + * 215.806 + * 0: Declared in C (through bridge) 215.807 + * 1: Declared in C (through bridge) 215.808 + * 2*: Inherited default from J 215.809 + * 3: Declared in C 215.810 + */ 215.811 + public void test56() throws IOException, ReflectiveOperationException { 215.812 + compileSpec("Cc3(Ac1(Id0),J(Id0))"); 215.813 + assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); 215.814 + recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "J"); 215.815 + assertLinkage("C", "C3", "C3", "J2", "C3"); 215.816 + } 215.817 + 215.818 + /* 215.819 + * Cc3(Ac1(Ia0), J(Ia0)) -> Cc3(Ac1(Ia0), Jd2(Ia0)) 215.820 + * 215.821 + * 0: Declared in C (through bridge) 215.822 + * 1: Declared in C (through bridge) 215.823 + * 2*: Inherited default from J 215.824 + * 3: Declared in C 215.825 + */ 215.826 + public void test57() throws IOException, ReflectiveOperationException { 215.827 + compileSpec("Cc3(Ac1(Ia0),J(Ia0))"); 215.828 + assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); 215.829 + recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "J"); 215.830 + assertLinkage("C", "C3", "C3", "J2", "C3"); 215.831 + } 215.832 + 215.833 + /* 215.834 + * Cc3(Aa1(Id0), J(Id0)) -> Cc3(Aa1(Id0), Jd2(Id0)) 215.835 + * 215.836 + * 0: Declared in C (through bridge) 215.837 + * 1: Declared in C (through bridge) 215.838 + * 2*: Inherited default from J 215.839 + * 3: Declared in C 215.840 + */ 215.841 + public void test58() throws IOException, ReflectiveOperationException { 215.842 + compileSpec("Cc3(Aa1(Id0),J(Id0))"); 215.843 + assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); 215.844 + recompileSpec("Cc3(Aa1(Id0),Jd2(Id0))", "J"); 215.845 + assertLinkage("C", "C3", "C3", "J2", "C3"); 215.846 + } 215.847 + 215.848 + /* 215.849 + * Cc3(Aa1(Ia0), J(Ia0)) -> Cc3(Aa1(Ia0), Jd2(Ia0)) 215.850 + * 215.851 + * 0: Declared in C (through bridge) 215.852 + * 1: Declared in C (through bridge) 215.853 + * 2*: Inherited default from J 215.854 + * 3: Declared in C 215.855 + */ 215.856 + public void test59() throws IOException, ReflectiveOperationException { 215.857 + compileSpec("Cc3(Aa1(Ia0),J(Ia0))"); 215.858 + assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); 215.859 + recompileSpec("Cc3(Aa1(Ia0),Jd2(Ia0))", "J"); 215.860 + assertLinkage("C", "C3", "C3", "J2", "C3"); 215.861 + } 215.862 + 215.863 + /* 215.864 + * Cc3(A(Id0), Jd2(Id0)) -> Cc3(Ac1(Id0), Jd2(Id0)) 215.865 + * 215.866 + * 0: Declared in C (through bridge) 215.867 + * 1*: Inherited from A 215.868 + * 2: Declared in C (through bridge) 215.869 + * 3: Declared in C 215.870 + */ 215.871 + public void test60() throws IOException, ReflectiveOperationException { 215.872 + compileSpec("Cc3(A(Id0),Jd2(Id0))"); 215.873 + assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3"); 215.874 + recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "A"); 215.875 + assertLinkage("C", "C3", "A1", "C3", "C3"); 215.876 + } 215.877 + 215.878 + /* 215.879 + * Cc3(A(Im0), Jd2(Ia0)) -> Cc3(Ac1(Im0), Jd2(Ia0)) 215.880 + * 215.881 + * 0: Declared in C (through bridge) 215.882 + * 1*: Inherited from A 215.883 + * 2: Declared in C (through bridge) 215.884 + * 3: Declared in C 215.885 + */ 215.886 + public void test61() throws IOException, ReflectiveOperationException { 215.887 + compileSpec("Cc3(A(Ia0),Jd2(Ia0))"); 215.888 + assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3"); 215.889 + recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "A"); 215.890 + assertLinkage("C", "C3", "A1", "C3", "C3"); 215.891 + } 215.892 + 215.893 + /* 215.894 + * Cc3(A(Im0), Ja2(Id0)) -> Cc3(Ac1(Id0), Ja2(Id0)) 215.895 + * 215.896 + * 0: Declared in C (through bridge) 215.897 + * 1*: Inherited from A 215.898 + * 2: Declared in C (through bridge) 215.899 + * 3: Declared in C 215.900 + */ 215.901 + public void test62() throws IOException, ReflectiveOperationException { 215.902 + compileSpec("Cc3(A(Id0),Ja2(Id0))"); 215.903 + assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3"); 215.904 + recompileSpec("Cc3(Ac1(Id0),Ja2(Id0))", "A"); 215.905 + assertLinkage("C", "C3", "A1", "C3", "C3"); 215.906 + } 215.907 + 215.908 + /* 215.909 + * Cc3(A(Im0), Ja2(Ia0)) -> Cc3(Ac1(Ia0), Ja2(Ia0)) 215.910 + * 215.911 + * 0: Declared in C (through bridge) 215.912 + * 1*: Inherited from A 215.913 + * 2: Declared in C (through bridge) 215.914 + * 3: Declared in C 215.915 + */ 215.916 + public void test63() throws IOException, ReflectiveOperationException { 215.917 + compileSpec("Cc3(A(Ia0),Ja2(Ia0))"); 215.918 + assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3"); 215.919 + recompileSpec("Cc3(Ac1(Ia0),Ja2(Ia0))", "A"); 215.920 + assertLinkage("C", "C3", "A1", "C3", "C3"); 215.921 + } 215.922 + 215.923 + /* 215.924 + * Cc3(Jd1(Id0), K(Id0)) -> Cc3(Jd1(Id0), Kd2(Id0)) 215.925 + * 215.926 + * 0: Declared in C (through bridge) 215.927 + * 1: Declared in C (through bridge) 215.928 + * 2*: Inherited default from K 215.929 + * 3: Declared in C 215.930 + */ 215.931 + public void test64() throws IOException, ReflectiveOperationException { 215.932 + compileSpec("Cc3(Jd1(Id0),K(Id0))"); 215.933 + assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); 215.934 + recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "K"); 215.935 + assertLinkage("C", "C3", "C3", "K2", "C3"); 215.936 + } 215.937 + 215.938 + /* 215.939 + * Cc3(Jd1(Ia0), K(Ia0)) -> Cc3(Jd1(Ia0), Kd2(Ia0)) 215.940 + * 215.941 + * 0: Declared in C (through bridge) 215.942 + * 1: Declared in C (through bridge) 215.943 + * 2*: Inherited default from K 215.944 + * 3: Declared in C 215.945 + */ 215.946 + public void test65() throws IOException, ReflectiveOperationException { 215.947 + compileSpec("Cc3(Jd1(Ia0),K(Ia0))"); 215.948 + assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); 215.949 + recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "K"); 215.950 + assertLinkage("C", "C3", "C3", "K2", "C3"); 215.951 + } 215.952 + 215.953 + /* 215.954 + * Cc3(Ja1(Id0), K(Id0)) -> Cc3(Ja1(Id0), Kd2(Id0)) 215.955 + * 215.956 + * 0: Declared in C (through bridge) 215.957 + * 1: Declared in C (through bridge) 215.958 + * 2*: Inherited default from K 215.959 + * 3: Declared in C 215.960 + */ 215.961 + public void test66() throws IOException, ReflectiveOperationException { 215.962 + compileSpec("Cc3(Jd1(Id0),K(Id0))"); 215.963 + assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); 215.964 + recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "K"); 215.965 + assertLinkage("C", "C3", "C3", "K2", "C3"); 215.966 + } 215.967 + 215.968 + /* 215.969 + * Cc3(Ja1(Ia0), K(Ia0)) -> Cc3(Ja1(Ia0), Kd2(Ia0)) 215.970 + * 215.971 + * 0: Declared in C (through bridge) 215.972 + * 1: Declared in C (through bridge) 215.973 + * 2*: Inherited default from K 215.974 + * 3: Declared in C 215.975 + */ 215.976 + public void test67() throws IOException, ReflectiveOperationException { 215.977 + compileSpec("Cc3(Jd1(Ia0),K(Ia0))"); 215.978 + assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3"); 215.979 + recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "K"); 215.980 + assertLinkage("C", "C3", "C3", "K2", "C3"); 215.981 + } 215.982 + 215.983 + // Dan's set A 215.984 + public void testA1() throws IOException, ReflectiveOperationException { 215.985 + compileSpec("C(Id0)"); 215.986 + assertLinkage("C", "I0"); 215.987 + } 215.988 + 215.989 + public void testA2() throws IOException, ReflectiveOperationException { 215.990 + compileSpec("C(A(Id0))"); 215.991 + assertLinkage("C", "I0"); 215.992 + } 215.993 + 215.994 + public void testA3() throws IOException, ReflectiveOperationException { 215.995 + compileSpec("C(A(Id0),J)"); 215.996 + assertLinkage("C", "I0"); 215.997 + } 215.998 + 215.999 + public void testA4() throws IOException, ReflectiveOperationException { 215.1000 + compileSpec("D(C(Id0),Jd0(Id0))"); 215.1001 + assertLinkage("D", "J0"); 215.1002 + assertLinkage("C", "I0"); 215.1003 + } 215.1004 + 215.1005 + public void testA5() throws IOException, ReflectiveOperationException { 215.1006 + compileSpec("C(A(Id0),Jd0)", 215.1007 + "compiler.err.types.incompatible.unrelated.defaults"); 215.1008 + } 215.1009 + 215.1010 + public void testA6() throws IOException, ReflectiveOperationException { 215.1011 + compileSpec("C(A(Ia0,Jd0))", 215.1012 + "compiler.err.does.not.override.abstract", 215.1013 + "compiler.err.types.incompatible.abstract.default"); 215.1014 + } 215.1015 + 215.1016 + public void testA7() throws IOException, ReflectiveOperationException { 215.1017 + compileSpec("C(A(Id0,Jd0))", 215.1018 + "compiler.err.types.incompatible.unrelated.defaults"); 215.1019 + } 215.1020 + 215.1021 + public void testA8() throws IOException, ReflectiveOperationException { 215.1022 + compileSpec("C(A(Ia0),J)", "compiler.err.does.not.override.abstract"); 215.1023 + } 215.1024 + 215.1025 + public void testA9() throws IOException, ReflectiveOperationException { 215.1026 + compileSpec("C(Ac0(Id0))"); 215.1027 + assertLinkage("C", "A0"); 215.1028 + } 215.1029 + 215.1030 + public void testA10() throws IOException, ReflectiveOperationException { 215.1031 + compileSpec("C(Aa0,I)", "compiler.err.does.not.override.abstract"); 215.1032 + } 215.1033 + 215.1034 + public void testA11() throws IOException, ReflectiveOperationException { 215.1035 + compileSpec("C(Ac0,Id0)"); 215.1036 + assertLinkage("C", "A0"); 215.1037 + } 215.1038 + 215.1039 + // Dan's set B 215.1040 + 215.1041 + /* B1 can't be done, needs a second concrete class D 215.1042 + public void testB1() throws IOException, ReflectiveOperationException { 215.1043 + compileSpec("Cc1(Dc0)"); 215.1044 + assertLinkage("C", "C1", "C1"); 215.1045 + assertLinkage("D", "A0", LINKAGE_ERROR); 215.1046 + } 215.1047 + */ 215.1048 + 215.1049 + public void testB2() throws IOException, ReflectiveOperationException { 215.1050 + compileSpec("Cc1(Ac0)"); 215.1051 + assertLinkage("C", "C1", "C1"); 215.1052 + } 215.1053 + 215.1054 + //??? B3 seems to suggest that we should create an abstract class 215.1055 + //public void testB3() throws IOException, ReflectiveOperationException { 215.1056 + // compileSpec("Ba1(Cc0)"); 215.1057 + // assertLinkage("B", "C0", "A1"); 215.1058 + //} 215.1059 + 215.1060 + // B4 needs too many classes 215.1061 + 215.1062 + public void testB5() throws IOException, ReflectiveOperationException { 215.1063 + compileSpec("Cc1(Aa1(Id0))"); 215.1064 + assertLinkage("C", "C1", "C1"); 215.1065 + } 215.1066 + 215.1067 + public void testB6() throws IOException, ReflectiveOperationException { 215.1068 + compileSpec("C(Ac1(Id0))"); 215.1069 + assertLinkage("C", "A1", "A1"); 215.1070 + } 215.1071 + 215.1072 + public void testB7() throws IOException, ReflectiveOperationException { 215.1073 + compileSpec("Cc1(Id0)"); 215.1074 + assertLinkage("C", "C1", "C1"); 215.1075 + } 215.1076 + 215.1077 + public void testB8() throws IOException, ReflectiveOperationException { 215.1078 + compileSpec("C(Jd1(Id0))"); 215.1079 + assertLinkage("C", "J1", "J1"); 215.1080 + } 215.1081 + 215.1082 + // B9 needs too many classes 215.1083 + 215.1084 + // The rest of Dan's tests need generics 215.1085 +}
216.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 216.2 +++ b/test/tools/javac/lambda/bridge/template_tests/TEST.properties Tue Sep 17 08:21:11 2013 -0700 216.3 @@ -0,0 +1,7 @@ 216.4 +# This file identifies root(s) of the test-ng hierarchy. 216.5 + 216.6 + 216.7 + 216.8 +TestNG.dirs = . 216.9 + 216.10 +lib.dirs = /lib/combo
217.1 --- a/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java Thu Sep 12 11:09:20 2013 -0700 217.2 +++ b/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java Tue Sep 17 08:21:11 2013 -0700 217.3 @@ -197,7 +197,7 @@ 217.4 "class Test {\n" + 217.5 " void m(SAM1 s) { }\n" + 217.6 " void m(SAM2 s) { }\n" + 217.7 - " { m(x->{ #LR }); }\n" + 217.8 + " { m((#A1 x)->{ #LR }); }\n" + 217.9 "}\n"; 217.10 217.11 String source; 217.12 @@ -236,14 +236,17 @@ 217.13 void check() { 217.14 checkCount.incrementAndGet(); 217.15 217.16 + if (ak1 != ak2) 217.17 + return; 217.18 + 217.19 if (!lrk.compatibleWith(rt1) || !lrk.compatibleWith(rt2)) 217.20 return; 217.21 217.22 if (lrk.needsConversion(rt1) != lrk.needsConversion(rt2)) 217.23 return; 217.24 217.25 - boolean m1MoreSpecific = moreSpecific(rt1, rt2, ek1, ek2, ak1, ak2); 217.26 - boolean m2MoreSpecific = moreSpecific(rt2, rt1, ek2, ek1, ak2, ak1); 217.27 + boolean m1MoreSpecific = rt1.moreSpecificThan(rt2); 217.28 + boolean m2MoreSpecific = rt2.moreSpecificThan(rt1); 217.29 217.30 boolean ambiguous = (m1MoreSpecific == m2MoreSpecific); 217.31 217.32 @@ -268,17 +271,6 @@ 217.33 } 217.34 } 217.35 217.36 - boolean moreSpecific(RetTypeKind rk1, RetTypeKind rk2, ExceptionKind ek1, 217.37 - ExceptionKind ek2, ArgTypeKind ak1, ArgTypeKind ak2) { 217.38 - if (!rk1.moreSpecificThan(rk2)) 217.39 - return false; 217.40 - 217.41 - if (ak1 != ak2) 217.42 - return false; 217.43 - 217.44 - return true; 217.45 - } 217.46 - 217.47 static class DiagnosticChecker 217.48 implements javax.tools.DiagnosticListener<JavaFileObject> { 217.49
218.1 --- a/test/tools/javac/lambda/typeInference/InferenceTest5.java Thu Sep 12 11:09:20 2013 -0700 218.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 218.3 @@ -1,122 +0,0 @@ 218.4 -/* 218.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 218.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 218.7 - * 218.8 - * This code is free software; you can redistribute it and/or modify it 218.9 - * under the terms of the GNU General Public License version 2 only, as 218.10 - * published by the Free Software Foundation. 218.11 - * 218.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 218.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 218.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 218.15 - * version 2 for more details (a copy is included in the LICENSE file that 218.16 - * accompanied this code). 218.17 - * 218.18 - * You should have received a copy of the GNU General Public License version 218.19 - * 2 along with this work; if not, write to the Free Software Foundation, 218.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 218.21 - * 218.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 218.23 - * or visit www.oracle.com if you need additional information or have any 218.24 - * questions. 218.25 - */ 218.26 - 218.27 -/** 218.28 - * @test 218.29 - * @bug 8003280 218.30 - * @summary Add lambda tests 218.31 - * This test is for overloaded methods, verify that the specific method is 218.32 - selected when type inference occurs 218.33 - * @compile InferenceTest5.java 218.34 - * @run main InferenceTest5 218.35 - */ 218.36 - 218.37 -import java.util.List; 218.38 -import java.io.File; 218.39 - 218.40 -public class InferenceTest5 { 218.41 - 218.42 - private static void assertTrue(boolean b) { 218.43 - if(!b) 218.44 - throw new AssertionError(); 218.45 - } 218.46 - 218.47 - public static void main(String[] args) { 218.48 - InferenceTest5 test = new InferenceTest5(); 218.49 - int n = test.method1((a, b) -> {} ); 218.50 - assertTrue(n == 1); 218.51 - 218.52 - n = test.method1(() -> null); 218.53 - assertTrue(n == 2); 218.54 - 218.55 - n = test.method1(a -> null); 218.56 - assertTrue(n == 3); 218.57 - 218.58 - n = test.method1(a -> {}); 218.59 - assertTrue(n == 4); 218.60 - 218.61 - n = test.method1(() -> {}); 218.62 - assertTrue(n == 5); 218.63 - 218.64 - n = test.method1((a, b) -> 0); 218.65 - assertTrue(n == 6); 218.66 - 218.67 - n = test.method1((a, b) -> null); 218.68 - assertTrue(n == 6); 218.69 - 218.70 - n = test.method1((a, b) -> null, (a, b) -> null); 218.71 - assertTrue(n == 7); 218.72 - } 218.73 - 218.74 - int method1(SAM1<String> s) { 218.75 - return 1; 218.76 - } 218.77 - 218.78 - int method1(SAM2 s) { 218.79 - return 2; 218.80 - } 218.81 - 218.82 - int method1(SAM3 s) { 218.83 - return 3; 218.84 - } 218.85 - 218.86 - int method1(SAM4 s) { 218.87 - return 4; 218.88 - } 218.89 - 218.90 - int method1(SAM5 s) { 218.91 - return 5; 218.92 - } 218.93 - 218.94 - int method1(SAM6<?, ? super Integer> s) { 218.95 - return 6; 218.96 - } 218.97 - 218.98 - int method1(SAM6<?, ?>... s) { 218.99 - return 7; 218.100 - } 218.101 - 218.102 - static interface SAM1<T> { 218.103 - void foo(List<T> a, List<T> b); 218.104 - } 218.105 - 218.106 - static interface SAM2 { 218.107 - List<String> foo(); 218.108 - } 218.109 - 218.110 - static interface SAM3 { 218.111 - String foo(int a); 218.112 - } 218.113 - 218.114 - static interface SAM4 { 218.115 - void foo(List<File> a); 218.116 - } 218.117 - 218.118 - static interface SAM5 { 218.119 - void foo(); 218.120 - } 218.121 - 218.122 - static interface SAM6<T, V> { 218.123 - V get(T t, T t2); 218.124 - } 218.125 -}
219.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 219.2 +++ b/test/tools/javac/lambda/typeInference/InferenceTest6.java Tue Sep 17 08:21:11 2013 -0700 219.3 @@ -0,0 +1,26 @@ 219.4 +/* 219.5 + * @test /nodynamiccopyright/ 219.6 + * @bug 8003280 8016177 219.7 + * @summary Add lambda tests 219.8 + * Missing cast to SAM type that causes type inference to not work. 219.9 + * @compile -XDrawDiagnostics InferenceTest6.java 219.10 + */ 219.11 + 219.12 +import java.util.*; 219.13 + 219.14 +public class InferenceTest6 { 219.15 + public static void main(String[] args) { 219.16 + InferenceTest6 test = new InferenceTest6(); 219.17 + test.method1(n -> {}); 219.18 + test.method1((SAM1<String>)n -> {}); 219.19 + test.method1((SAM1<Integer>)n -> {n++;}); 219.20 + test.method1((SAM1<Comparator<String>>)n -> {List<String> list = Arrays.asList("string1", "string2"); Collections.sort(list,n);}); 219.21 + test.method1((SAM1<Thread>)n -> {n.start();}); 219.22 + } 219.23 + 219.24 + interface SAM1<X> { 219.25 + void m1(X arg); 219.26 + } 219.27 + 219.28 + <X> void method1(SAM1<X> s) {} 219.29 +}
220.1 --- a/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out Thu Sep 12 11:09:20 2013 -0700 220.2 +++ b/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out Tue Sep 17 08:21:11 2013 -0700 220.3 @@ -1,4 +1,5 @@ 220.4 InferenceTest_neg1_2.java:14:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM4<java.lang.Double,java.lang.String>), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5<java.lang.Integer>), InferenceTest_neg1_2 220.5 -InferenceTest_neg1_2.java:15:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM2), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM4<java.lang.Double,java.lang.String>), InferenceTest_neg1_2 220.6 -InferenceTest_neg1_2.java:16:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM3<java.lang.Integer>), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5<java.lang.Integer>), InferenceTest_neg1_2 220.7 -3 errors 220.8 +InferenceTest_neg1_2.java:15:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM4<java.lang.Double,java.lang.String>), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5<java.lang.Integer>), InferenceTest_neg1_2 220.9 +InferenceTest_neg1_2.java:16:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM4<java.lang.Double,java.lang.String>), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5<java.lang.Integer>), InferenceTest_neg1_2 220.10 +InferenceTest_neg1_2.java:16:20: compiler.err.cant.apply.symbol: kindname.method, method, InferenceTest_neg1_2.SAM4<java.lang.Double,java.lang.String>, @597, kindname.class, InferenceTest_neg1_2, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String))) 220.11 +4 errors
221.1 --- a/test/tools/javac/lambda/typeInference/InferenceTest_neg5.java Thu Sep 12 11:09:20 2013 -0700 221.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 221.3 @@ -1,26 +0,0 @@ 221.4 -/* 221.5 - * @test /nodynamiccopyright/ 221.6 - * @bug 8003280 221.7 - * @summary Add lambda tests 221.8 - * Missing cast to SAM type that causes type inference to not work. 221.9 - * @compile/fail/ref=InferenceTest_neg5.out -XDrawDiagnostics InferenceTest_neg5.java 221.10 - */ 221.11 - 221.12 -import java.util.*; 221.13 - 221.14 -public class InferenceTest_neg5 { 221.15 - public static void main(String[] args) { 221.16 - InferenceTest_neg5 test = new InferenceTest_neg5(); 221.17 - test.method1(n -> {}); 221.18 - test.method1((SAM1<String>)n -> {}); 221.19 - test.method1((SAM1<Integer>)n -> {n++;}); 221.20 - test.method1((SAM1<Comparator<String>>)n -> {List<String> list = Arrays.asList("string1", "string2"); Collections.sort(list,n);}); 221.21 - test.method1((SAM1<Thread>)n -> {n.start();}); 221.22 - } 221.23 - 221.24 - interface SAM1<X> { 221.25 - void m1(X arg); 221.26 - } 221.27 - 221.28 - <X> void method1(SAM1<X> s) {} 221.29 -}
222.1 --- a/test/tools/javac/lambda/typeInference/InferenceTest_neg5.out Thu Sep 12 11:09:20 2013 -0700 222.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 222.3 @@ -1,2 +0,0 @@ 222.4 -InferenceTest_neg5.java:14:21: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: X) 222.5 -1 error
223.1 --- a/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java Thu Sep 12 11:09:20 2013 -0700 223.2 +++ b/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java Tue Sep 17 08:21:11 2013 -0700 223.3 @@ -227,12 +227,7 @@ 223.4 } 223.5 else if (lambdaBodyType != LambdaBody.RETURN_ARG) 223.6 return false; 223.7 - if ( genericDeclKind == GenericDeclKind.GENERIC_NOBOUND || 223.8 - genericDeclKind == GenericDeclKind.GENERIC_BOUND ) { 223.9 - if ( parameterType == TypeKind.GENERIC && 223.10 - parameterKind == ParameterKind.IMPLICIT) //cyclic inference 223.11 - return false; 223.12 - } 223.13 + 223.14 return true; 223.15 } 223.16
224.1 --- a/test/tools/javac/lib/DPrinter.java Thu Sep 12 11:09:20 2013 -0700 224.2 +++ b/test/tools/javac/lib/DPrinter.java Tue Sep 17 08:21:11 2013 -0700 224.3 @@ -49,7 +49,7 @@ 224.4 import com.sun.source.util.TaskListener; 224.5 import com.sun.source.util.Trees; 224.6 import com.sun.tools.javac.api.JavacTrees; 224.7 -import com.sun.tools.javac.code.Annotations; 224.8 +import com.sun.tools.javac.code.SymbolMetadata; 224.9 import com.sun.tools.javac.code.Attribute; 224.10 import com.sun.tools.javac.code.Flags; 224.11 import com.sun.tools.javac.code.Kinds; 224.12 @@ -186,21 +186,21 @@ 224.13 FULL 224.14 }; 224.15 224.16 - public void printAnnotations(String label, Annotations annotations) { 224.17 + public void printAnnotations(String label, SymbolMetadata annotations) { 224.18 printAnnotations(label, annotations, Details.FULL); 224.19 } 224.20 224.21 - protected void printAnnotations(String label, Annotations annotations, Details details) { 224.22 + protected void printAnnotations(String label, SymbolMetadata annotations, Details details) { 224.23 if (annotations == null) { 224.24 printNull(label); 224.25 } else { 224.26 // no SUMMARY format currently available to use 224.27 224.28 // use reflection to get at private fields 224.29 - Object DECL_NOT_STARTED = getField(null, Annotations.class, "DECL_NOT_STARTED"); 224.30 - Object DECL_IN_PROGRESS = getField(null, Annotations.class, "DECL_IN_PROGRESS"); 224.31 - Object attributes = getField(annotations, Annotations.class, "attributes"); 224.32 - Object type_attributes = getField(annotations, Annotations.class, "type_attributes"); 224.33 + Object DECL_NOT_STARTED = getField(null, SymbolMetadata.class, "DECL_NOT_STARTED"); 224.34 + Object DECL_IN_PROGRESS = getField(null, SymbolMetadata.class, "DECL_IN_PROGRESS"); 224.35 + Object attributes = getField(annotations, SymbolMetadata.class, "attributes"); 224.36 + Object type_attributes = getField(annotations, SymbolMetadata.class, "type_attributes"); 224.37 224.38 if (!showEmptyItems) { 224.39 if (attributes instanceof List && ((List) attributes).isEmpty()
225.1 --- a/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java Thu Sep 12 11:09:20 2013 -0700 225.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java Tue Sep 17 08:21:11 2013 -0700 225.3 @@ -31,6 +31,7 @@ 225.4 * @compile/fail/ref=TestMissingElement.ref -proc:only -XprintRounds -XDrawDiagnostics -processor TestMissingElement InvalidSource.java 225.5 */ 225.6 225.7 +import java.io.PrintWriter; 225.8 import java.util.*; 225.9 import javax.annotation.processing.*; 225.10 import javax.lang.model.element.*; 225.11 @@ -38,7 +39,18 @@ 225.12 import javax.lang.model.util.*; 225.13 import static javax.tools.Diagnostic.Kind.*; 225.14 225.15 +import com.sun.tools.javac.processing.JavacProcessingEnvironment; 225.16 +import com.sun.tools.javac.util.Log; 225.17 + 225.18 public class TestMissingElement extends JavacTestingAbstractProcessor { 225.19 + private PrintWriter out; 225.20 + 225.21 + @Override 225.22 + public void init(ProcessingEnvironment env) { 225.23 + super.init(env); 225.24 + out = ((JavacProcessingEnvironment) env).getContext().get(Log.outKey); 225.25 + } 225.26 + 225.27 @Override 225.28 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 225.29 for (TypeElement te: ElementFilter.typesIn(roundEnv.getRootElements())) { 225.30 @@ -70,13 +82,13 @@ 225.31 } 225.32 225.33 private void checkInterfaces(TypeElement te, String expect) { 225.34 - System.err.println("check interfaces: " + te + " -- " + expect); 225.35 + out.println("check interfaces: " + te + " -- " + expect); 225.36 String found = asString(te.getInterfaces(), ", "); 225.37 checkEqual("interfaces", te, found, expect); 225.38 } 225.39 225.40 private void checkSupertype(TypeElement te, String expect) { 225.41 - System.err.println("check supertype: " + te + " -- " + expect); 225.42 + out.println("check supertype: " + te + " -- " + expect); 225.43 String found = asString(te.getSuperclass()); 225.44 checkEqual("supertype", te, found, expect); 225.45 } 225.46 @@ -85,7 +97,7 @@ 225.47 if (found.equals(expect)) { 225.48 // messager.printMessage(NOTE, "expected " + label + " found: " + expect, te); 225.49 } else { 225.50 - System.err.println("unexpected " + label + ": " + te + "\n" 225.51 + out.println("unexpected " + label + ": " + te + "\n" 225.52 + " found: " + found + "\n" 225.53 + "expect: " + expect); 225.54 messager.printMessage(ERROR, "unexpected " + label + " found: " + found + "; expected: " + expect, te);
226.1 --- a/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.ref Thu Sep 12 11:09:20 2013 -0700 226.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.ref Tue Sep 17 08:21:11 2013 -0700 226.3 @@ -2,6 +2,24 @@ 226.4 input files: {ExpectInterfaces, ExpectSupertype, OK, InvalidSource} 226.5 annotations: [ExpectSupertype, ExpectInterfaces] 226.6 last round: false 226.7 +check supertype: InvalidSource.TestClassMissingClassA -- !:empty clss A! 226.8 +check supertype: InvalidSource.TestClassMissingClassAB -- !:empty clss (pkg A).B! 226.9 +check supertype: InvalidSource.TestClassMissingClass_juA -- !:empty clss (pkg java.util).A! 226.10 +check supertype: InvalidSource.TestClassTMissingClassAT -- !:empty clss A!<tvar T> 226.11 +check interfaces: InvalidSource.TestClassMissingIntfA -- !:empty intf A! 226.12 +check interfaces: InvalidSource.TestClassMissingIntfAB -- !:empty intf (pkg A).B! 226.13 +check interfaces: InvalidSource.TestClassMissingIntfAOK -- !:empty intf A!, intf OK 226.14 +check interfaces: InvalidSource.TestClassOKMissingIntfA -- intf OK, !:empty intf A! 226.15 +check interfaces: InvalidSource.TestClassMissingIntfA_B -- !:empty intf A!, !:empty intf B! 226.16 +check interfaces: InvalidSource.TestIntfMissingIntfA -- !:empty intf A! 226.17 +check interfaces: InvalidSource.TestIntfMissingIntfAOK -- !:empty intf A!, intf OK 226.18 +check interfaces: InvalidSource.TestIntfOKMissingIntfA -- intf OK, !:empty intf A! 226.19 +check interfaces: InvalidSource.TestIntfMissingIntfAB -- !:empty intf A!, !:empty intf B! 226.20 +check interfaces: InvalidSource.TestClassTMissingIntfAT -- !:empty intf A!<tvar T> 226.21 +check interfaces: InvalidSource.TestClassTMissingIntfAT_B -- !:empty intf A!<tvar T>, !:empty intf B! 226.22 +check interfaces: InvalidSource.TestIntfTMissingIntfAT -- !:empty intf A!<tvar T> 226.23 +check interfaces: InvalidSource.TestIntfTMissingIntfAT_B -- !:empty intf A!<tvar T>, !:empty intf B! 226.24 +check interfaces: InvalidSource.TestClassListMissingX -- intf (pkg java.util).List<!:empty clss X!> 226.25 Round 2: 226.26 input files: {} 226.27 annotations: [] 226.28 @@ -28,22 +46,4 @@ 226.29 InvalidSource.java:103:51: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null) 226.30 InvalidSource.java:103:57: compiler.err.cant.resolve.location: kindname.class, B, , , (compiler.misc.location: kindname.class, InvalidSource, null) 226.31 InvalidSource.java:106:58: compiler.err.cant.resolve.location: kindname.class, X, , , (compiler.misc.location: kindname.class, InvalidSource, null) 226.32 -22 errors 226.33 -check supertype: InvalidSource.TestClassMissingClassA -- !:empty clss A! 226.34 -check supertype: InvalidSource.TestClassMissingClassAB -- !:empty clss (pkg A).B! 226.35 -check supertype: InvalidSource.TestClassMissingClass_juA -- !:empty clss (pkg java.util).A! 226.36 -check supertype: InvalidSource.TestClassTMissingClassAT -- !:empty clss A!<tvar T> 226.37 -check interfaces: InvalidSource.TestClassMissingIntfA -- !:empty intf A! 226.38 -check interfaces: InvalidSource.TestClassMissingIntfAB -- !:empty intf (pkg A).B! 226.39 -check interfaces: InvalidSource.TestClassMissingIntfAOK -- !:empty intf A!, intf OK 226.40 -check interfaces: InvalidSource.TestClassOKMissingIntfA -- intf OK, !:empty intf A! 226.41 -check interfaces: InvalidSource.TestClassMissingIntfA_B -- !:empty intf A!, !:empty intf B! 226.42 -check interfaces: InvalidSource.TestIntfMissingIntfA -- !:empty intf A! 226.43 -check interfaces: InvalidSource.TestIntfMissingIntfAOK -- !:empty intf A!, intf OK 226.44 -check interfaces: InvalidSource.TestIntfOKMissingIntfA -- intf OK, !:empty intf A! 226.45 -check interfaces: InvalidSource.TestIntfMissingIntfAB -- !:empty intf A!, !:empty intf B! 226.46 -check interfaces: InvalidSource.TestClassTMissingIntfAT -- !:empty intf A!<tvar T> 226.47 -check interfaces: InvalidSource.TestClassTMissingIntfAT_B -- !:empty intf A!<tvar T>, !:empty intf B! 226.48 -check interfaces: InvalidSource.TestIntfTMissingIntfAT -- !:empty intf A!<tvar T> 226.49 -check interfaces: InvalidSource.TestIntfTMissingIntfAT_B -- !:empty intf A!<tvar T>, !:empty intf B! 226.50 -check interfaces: InvalidSource.TestClassListMissingX -- intf (pkg java.util).List<!:empty clss X!> 226.51 \ No newline at end of file 226.52 +22 errors 226.53 \ No newline at end of file
227.1 --- a/test/tools/javac/warnings/6594914/T6594914a.out Thu Sep 12 11:09:20 2013 -0700 227.2 +++ b/test/tools/javac/warnings/6594914/T6594914a.out Tue Sep 17 08:21:11 2013 -0700 227.3 @@ -1,7 +1,7 @@ 227.4 T6594914a.java:11:5: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 227.5 T6594914a.java:16:16: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 227.6 -T6594914a.java:16:52: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 227.7 T6594914a.java:16:33: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 227.8 T6594914a.java:17:20: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 227.9 +T6594914a.java:16:52: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 227.10 T6594914a.java:24:9: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 227.11 6 warnings
228.1 --- a/test/tools/javac/warnings/6594914/T6594914b.out Thu Sep 12 11:09:20 2013 -0700 228.2 +++ b/test/tools/javac/warnings/6594914/T6594914b.out Tue Sep 17 08:21:11 2013 -0700 228.3 @@ -1,7 +1,7 @@ 228.4 T6594914b.java:11:13: compiler.warn.sun.proprietary: sun.misc.Lock 228.5 T6594914b.java:16:24: compiler.warn.sun.proprietary: sun.misc.Lock 228.6 -T6594914b.java:16:56: compiler.warn.sun.proprietary: sun.misc.Lock 228.7 T6594914b.java:16:39: compiler.warn.sun.proprietary: sun.misc.Lock 228.8 T6594914b.java:17:28: compiler.warn.sun.proprietary: sun.misc.CEFormatException 228.9 +T6594914b.java:16:56: compiler.warn.sun.proprietary: sun.misc.Lock 228.10 T6594914b.java:24:17: compiler.warn.sun.proprietary: sun.misc.Lock 228.11 6 warnings
229.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 229.2 +++ b/test/tools/javac/warnings/suppress/ImplicitTest.java Tue Sep 17 08:21:11 2013 -0700 229.3 @@ -0,0 +1,31 @@ 229.4 +/* 229.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 229.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 229.7 + * 229.8 + * This code is free software; you can redistribute it and/or modify it 229.9 + * under the terms of the GNU General Public License version 2 only, as 229.10 + * published by the Free Software Foundation. 229.11 + * 229.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 229.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 229.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 229.15 + * version 2 for more details (a copy is included in the LICENSE file that 229.16 + * accompanied this code). 229.17 + * 229.18 + * You should have received a copy of the GNU General Public License version 229.19 + * 2 along with this work; if not, write to the Free Software Foundation, 229.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 229.21 + * 229.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 229.23 + * or visit www.oracle.com if you need additional information or have any 229.24 + * questions. 229.25 + */ 229.26 + 229.27 +/** 229.28 + * @test 229.29 + * @bug 8021112 229.30 + * @summary Verify that deprecated warning is printed correctly for import 229.31 + * statement when processing a file on demand while attributing another file. 229.32 + * @clean pack.ImplicitUse pack.ImplicitMain pack.Dep 229.33 + * @compile/ref=ImplicitTest.out -XDrawDiagnostics -Xlint:deprecation pack/ImplicitMain.java 229.34 + */
230.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 230.2 +++ b/test/tools/javac/warnings/suppress/ImplicitTest.out Tue Sep 17 08:21:11 2013 -0700 230.3 @@ -0,0 +1,2 @@ 230.4 +ImplicitUse.java:4:12: compiler.warn.has.been.deprecated: pack.Dep, pack 230.5 +1 warning 230.6 \ No newline at end of file
231.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 231.2 +++ b/test/tools/javac/warnings/suppress/PackageInfo.java Tue Sep 17 08:21:11 2013 -0700 231.3 @@ -0,0 +1,30 @@ 231.4 +/* 231.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 231.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 231.7 + * 231.8 + * This code is free software; you can redistribute it and/or modify it 231.9 + * under the terms of the GNU General Public License version 2 only, as 231.10 + * published by the Free Software Foundation. 231.11 + * 231.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 231.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 231.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 231.15 + * version 2 for more details (a copy is included in the LICENSE file that 231.16 + * accompanied this code). 231.17 + * 231.18 + * You should have received a copy of the GNU General Public License version 231.19 + * 2 along with this work; if not, write to the Free Software Foundation, 231.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 231.21 + * 231.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 231.23 + * or visit www.oracle.com if you need additional information or have any 231.24 + * questions. 231.25 + */ 231.26 + 231.27 +/** 231.28 + * @test 231.29 + * @bug 8021112 231.30 + * @summary Verify that deprecated warnings are printed correctly for package-info.java 231.31 + * @clean pack.package-info pack.DeprecatedClass 231.32 + * @compile/ref=PackageInfo.out -XDrawDiagnostics -Xlint:deprecation pack/package-info.java pack/DeprecatedClass.java 231.33 + */
232.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 232.2 +++ b/test/tools/javac/warnings/suppress/PackageInfo.out Tue Sep 17 08:21:11 2013 -0700 232.3 @@ -0,0 +1,3 @@ 232.4 +package-info.java:5:12: compiler.warn.has.been.deprecated: pack.DeprecatedClass, pack 232.5 +package-info.java:2:2: compiler.warn.has.been.deprecated: pack.DeprecatedClass, pack 232.6 +2 warnings
233.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 233.2 +++ b/test/tools/javac/warnings/suppress/T6480588.java Tue Sep 17 08:21:11 2013 -0700 233.3 @@ -0,0 +1,36 @@ 233.4 +/** 233.5 + * @test /nodynamiccopyright/ 233.6 + * @bug 6470588 233.7 + * @summary Verify that \\@SuppressWarnings("deprecation") works OK for all parts 233.8 + * of class/method/field "header", including (declaration) annotations 233.9 + * @build VerifySuppressWarnings 233.10 + * @compile/ref=T6480588.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast T6480588.java 233.11 + * @run main VerifySuppressWarnings T6480588.java 233.12 + */ 233.13 + 233.14 +@DeprecatedAnnotation 233.15 +class T6480588 extends DeprecatedClass implements DeprecatedInterface { 233.16 + @DeprecatedAnnotation 233.17 + public DeprecatedClass method(DeprecatedClass param) throws DeprecatedClass { 233.18 + DeprecatedClass lv = new DeprecatedClass(); 233.19 + @Deprecated 233.20 + DeprecatedClass lvd = new DeprecatedClass(); 233.21 + return null; 233.22 + } 233.23 + 233.24 + @Deprecated 233.25 + public void methodD() { 233.26 + } 233.27 + 233.28 + @DeprecatedAnnotation 233.29 + DeprecatedClass field = new DeprecatedClass(); 233.30 + 233.31 + @DeprecatedAnnotation 233.32 + class Inner extends DeprecatedClass implements DeprecatedInterface { 233.33 + } 233.34 + 233.35 +} 233.36 + 233.37 +@Deprecated class DeprecatedClass extends Throwable { } 233.38 +@Deprecated interface DeprecatedInterface { } 233.39 +@Deprecated @interface DeprecatedAnnotation { }
234.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 234.2 +++ b/test/tools/javac/warnings/suppress/T6480588.out Tue Sep 17 08:21:11 2013 -0700 234.3 @@ -0,0 +1,18 @@ 234.4 +T6480588.java:12:24: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 234.5 +T6480588.java:12:51: compiler.warn.has.been.deprecated: DeprecatedInterface, compiler.misc.unnamed.package 234.6 +T6480588.java:11:2: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package 234.7 +T6480588.java:14:12: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 234.8 +T6480588.java:14:65: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 234.9 +T6480588.java:13:6: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package 234.10 +T6480588.java:14:35: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 234.11 +T6480588.java:15:9: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 234.12 +T6480588.java:15:34: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 234.13 +T6480588.java:17:9: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 234.14 +T6480588.java:17:35: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 234.15 +T6480588.java:26:5: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 234.16 +T6480588.java:25:6: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package 234.17 +T6480588.java:26:33: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 234.18 +T6480588.java:29:25: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package 234.19 +T6480588.java:29:52: compiler.warn.has.been.deprecated: DeprecatedInterface, compiler.misc.unnamed.package 234.20 +T6480588.java:28:6: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package 234.21 +17 warnings 234.22 \ No newline at end of file
235.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 235.2 +++ b/test/tools/javac/warnings/suppress/T8021112a.java Tue Sep 17 08:21:11 2013 -0700 235.3 @@ -0,0 +1,45 @@ 235.4 +/* 235.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 235.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 235.7 + * 235.8 + * This code is free software; you can redistribute it and/or modify it 235.9 + * under the terms of the GNU General Public License version 2 only, as 235.10 + * published by the Free Software Foundation. 235.11 + * 235.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 235.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 235.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 235.15 + * version 2 for more details (a copy is included in the LICENSE file that 235.16 + * accompanied this code). 235.17 + * 235.18 + * You should have received a copy of the GNU General Public License version 235.19 + * 2 along with this work; if not, write to the Free Software Foundation, 235.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 235.21 + * 235.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 235.23 + * or visit www.oracle.com if you need additional information or have any 235.24 + * questions. 235.25 + */ 235.26 +package test; 235.27 + 235.28 +/** 235.29 + * @test 235.30 + * @bug 8021112 235.31 + * @summary Verify that \\@SuppressWarnings work even if the value is defined 235.32 + * inside the suppressed class itself, and verify that "unnecessary cast" 235.33 + * lint can be properly suppressed. 235.34 + * @compile -Xlint:cast -Werror T8021112a.java 235.35 + */ 235.36 + 235.37 +import static test.T8021112a.D; 235.38 + 235.39 +@SuppressWarnings(D) 235.40 +public class T8021112a { 235.41 + public static final String D = (String) "cast"; 235.42 +} 235.43 + 235.44 +class Other { 235.45 + public static final String D = "cast"; 235.46 + @SuppressWarnings(D) 235.47 + public static final String D2 = (String) "cast"; 235.48 +}
236.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 236.2 +++ b/test/tools/javac/warnings/suppress/T8021112b.java Tue Sep 17 08:21:11 2013 -0700 236.3 @@ -0,0 +1,22 @@ 236.4 +/** 236.5 + * @test /nodynamiccopyright/ 236.6 + * @bug 8021112 236.7 + * @summary Verify that \\@SuppressWarnings("unchecked") works correctly for lazy attrib values 236.8 + * @build VerifySuppressWarnings 236.9 + * @compile/ref=T8021112b.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast T8021112b.java 236.10 + * @run main VerifySuppressWarnings T8021112b.java 236.11 + */ 236.12 + 236.13 +public class T8021112b { 236.14 + public static final String D1 = Dep.D; 236.15 + public static final String D2 = ""; 236.16 + public static final Object[] o = { 236.17 + new Object() { 236.18 + Dep d; 236.19 + } 236.20 + }; 236.21 +} 236.22 + 236.23 +@Deprecated class Dep { 236.24 + public static final String D = T8021112b.D2; 236.25 +}
237.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 237.2 +++ b/test/tools/javac/warnings/suppress/T8021112b.out Tue Sep 17 08:21:11 2013 -0700 237.3 @@ -0,0 +1,3 @@ 237.4 +T8021112b.java:11:37: compiler.warn.has.been.deprecated: Dep, compiler.misc.unnamed.package 237.5 +T8021112b.java:15:13: compiler.warn.has.been.deprecated: Dep, compiler.misc.unnamed.package 237.6 +2 warnings 237.7 \ No newline at end of file
238.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 238.2 +++ b/test/tools/javac/warnings/suppress/TypeAnnotations.java Tue Sep 17 08:21:11 2013 -0700 238.3 @@ -0,0 +1,51 @@ 238.4 +/** 238.5 + * @test /nodynamiccopyright/ 238.6 + * @bug 8021112 238.7 + * @summary Verify that \\@SuppressWarnings("unchecked") works for type annotations 238.8 + * @build VerifySuppressWarnings 238.9 + * @compile/ref=TypeAnnotations.out -XDrawDiagnostics -Xlint:unchecked,deprecation,cast TypeAnnotations.java 238.10 + * @run main VerifySuppressWarnings TypeAnnotations.java 238.11 + */ 238.12 + 238.13 +import java.lang.annotation.*; 238.14 + 238.15 +public class TypeAnnotations extends @TA Object implements @TA Runnable { 238.16 + 238.17 + public @TA String @TA [] m(@TA String @TA [] p) throws @TA Throwable { 238.18 + Runnable r = () -> { 238.19 + @TA Object tested = null; 238.20 + @TA boolean isAnnotated = tested instanceof @TA String; 238.21 + }; 238.22 + 238.23 + @TA Object tested = null; 238.24 + @TA boolean isAnnotated = tested instanceof @TA String; 238.25 + 238.26 + return (@TA String @TA []) null; 238.27 + } 238.28 + 238.29 + { 238.30 + Runnable r = () -> { 238.31 + @TA Object tested = null; 238.32 + @TA boolean isAnnotated = tested instanceof @TA String; 238.33 + }; 238.34 + 238.35 + @TA Object tested = null; 238.36 + @TA boolean isAnnotated = tested instanceof @TA String; 238.37 + 238.38 + @TA String @TA [] ret = (@TA String @TA []) null; 238.39 + } 238.40 + 238.41 + @TA String @TA [] f = new @TA String @TA[0]; 238.42 + 238.43 + @Override public void run() { } 238.44 + 238.45 + public static class Inner extends @TA Object implements @TA Runnable { 238.46 + @Override public void run() { } 238.47 + } 238.48 +} 238.49 + 238.50 +@Target({ElementType.TYPE_USE, ElementType.TYPE}) 238.51 +@Deprecated 238.52 +@interface TA { 238.53 + 238.54 +}
239.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 239.2 +++ b/test/tools/javac/warnings/suppress/TypeAnnotations.out Tue Sep 17 08:21:11 2013 -0700 239.3 @@ -0,0 +1,41 @@ 239.4 +TypeAnnotations.java:12:39: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.5 +TypeAnnotations.java:12:61: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.6 +TypeAnnotations.java:14:24: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.7 +TypeAnnotations.java:14:61: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.8 +TypeAnnotations.java:14:13: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.9 +TypeAnnotations.java:14:44: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.10 +TypeAnnotations.java:14:33: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.11 +TypeAnnotations.java:23:29: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.12 +TypeAnnotations.java:23:18: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.13 +TypeAnnotations.java:16:14: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.14 +TypeAnnotations.java:17:58: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.15 +TypeAnnotations.java:17:14: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.16 +TypeAnnotations.java:17:58: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.17 +TypeAnnotations.java:20:10: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.18 +TypeAnnotations.java:21:54: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.19 +TypeAnnotations.java:21:10: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.20 +TypeAnnotations.java:21:54: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.21 +TypeAnnotations.java:23:18: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.22 +TypeAnnotations.java:23:29: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.23 +TypeAnnotations.java:28:14: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.24 +TypeAnnotations.java:29:58: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.25 +TypeAnnotations.java:29:14: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.26 +TypeAnnotations.java:29:58: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.27 +TypeAnnotations.java:32:10: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.28 +TypeAnnotations.java:33:54: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.29 +TypeAnnotations.java:33:10: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.30 +TypeAnnotations.java:33:54: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.31 +TypeAnnotations.java:35:46: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.32 +TypeAnnotations.java:35:35: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.33 +TypeAnnotations.java:35:21: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.34 +TypeAnnotations.java:35:10: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.35 +TypeAnnotations.java:35:35: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.36 +TypeAnnotations.java:35:46: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.37 +TypeAnnotations.java:38:17: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.38 +TypeAnnotations.java:38:6: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.39 +TypeAnnotations.java:38:43: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.40 +TypeAnnotations.java:38:32: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.41 +TypeAnnotations.java:38:32: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.42 +TypeAnnotations.java:42:40: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.43 +TypeAnnotations.java:42:62: compiler.warn.has.been.deprecated: TA, compiler.misc.unnamed.package 239.44 +40 warnings 239.45 \ No newline at end of file
240.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 240.2 +++ b/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java Tue Sep 17 08:21:11 2013 -0700 240.3 @@ -0,0 +1,212 @@ 240.4 +/* 240.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 240.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 240.7 + * 240.8 + * This code is free software; you can redistribute it and/or modify it 240.9 + * under the terms of the GNU General Public License version 2 only, as 240.10 + * published by the Free Software Foundation. 240.11 + * 240.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 240.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 240.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 240.15 + * version 2 for more details (a copy is included in the LICENSE file that 240.16 + * accompanied this code). 240.17 + * 240.18 + * You should have received a copy of the GNU General Public License version 240.19 + * 2 along with this work; if not, write to the Free Software Foundation, 240.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 240.21 + * 240.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 240.23 + * or visit www.oracle.com if you need additional information or have any 240.24 + * questions. 240.25 + */ 240.26 + 240.27 +import com.sun.source.tree.ClassTree; 240.28 +import com.sun.source.tree.CompilationUnitTree; 240.29 +import com.sun.source.tree.MethodTree; 240.30 +import com.sun.source.tree.NewClassTree; 240.31 +import com.sun.source.tree.Tree; 240.32 +import com.sun.source.tree.VariableTree; 240.33 +import com.sun.source.util.JavacTask; 240.34 +import com.sun.source.util.TreeScanner; 240.35 +import com.sun.source.util.Trees; 240.36 +import com.sun.tools.javac.api.JavacTool; 240.37 +import com.sun.tools.javac.code.Flags; 240.38 +import com.sun.tools.javac.file.JavacFileManager; 240.39 +import com.sun.tools.javac.tree.JCTree.JCMethodDecl; 240.40 +import java.io.File; 240.41 +import java.io.IOException; 240.42 +import java.net.URI; 240.43 +import java.net.URISyntaxException; 240.44 +import java.util.ArrayList; 240.45 +import java.util.Arrays; 240.46 +import java.util.Iterator; 240.47 +import java.util.List; 240.48 +import javax.tools.Diagnostic; 240.49 +import javax.tools.DiagnosticListener; 240.50 +import javax.tools.FileObject; 240.51 +import javax.tools.ForwardingJavaFileManager; 240.52 +import javax.tools.JavaFileManager; 240.53 +import javax.tools.JavaFileObject; 240.54 +import javax.tools.SimpleJavaFileObject; 240.55 + 240.56 +/**Takes a source file, parses it once to get the warnings inside the file and 240.57 + * then for each and every declaration in the file, it tries to place 240.58 + * the @SuppressWarnings annotation on the declaration and verifies than no 240.59 + * warnings are produced inside the declaration, but all are produced outside it. 240.60 + * 240.61 + * Currently only works with <code>unchecked,deprecation,cast</code> warnings. 240.62 + */ 240.63 +public class VerifySuppressWarnings { 240.64 + 240.65 + private static final List<String> STANDARD_PARAMS = Arrays.asList("-Xlint:unchecked,deprecation,cast", "-Xjcov"); 240.66 + 240.67 + public static void main(String... args) throws IOException, URISyntaxException { 240.68 + if (args.length != 1) throw new IllegalStateException("Must provide class name!"); 240.69 + String testContent = null; 240.70 + List<File> sourcePath = new ArrayList<>(); 240.71 + for (String sourcePaths : System.getProperty("test.src.path").split(":")) { 240.72 + sourcePath.add(new File(sourcePaths)); 240.73 + } 240.74 + JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null); 240.75 + for (File sp : sourcePath) { 240.76 + File inp = new File(sp, args[0]); 240.77 + 240.78 + if (inp.canRead()) { 240.79 + testContent = fm.getRegularFile(inp).getCharContent(true).toString(); 240.80 + } 240.81 + } 240.82 + if (testContent == null) throw new IllegalStateException(); 240.83 + final List<Diagnostic<?>> diagnostics = new ArrayList<>(); 240.84 + DiagnosticListener<JavaFileObject> collectDiagnostics = new DiagnosticListener<JavaFileObject>() { 240.85 + @Override public void report(Diagnostic<? extends JavaFileObject> diagnostic) { 240.86 + diagnostics.add(diagnostic); 240.87 + } 240.88 + }; 240.89 + JavaFileObject testFile = new TestFO(new URI("mem://" + args[0]), testContent); 240.90 + JavacTask task = JavacTool.create().getTask(null, 240.91 + new TestFM(fm), 240.92 + collectDiagnostics, 240.93 + STANDARD_PARAMS, 240.94 + null, 240.95 + Arrays.asList(testFile)); 240.96 + final Trees trees = Trees.instance(task); 240.97 + final CompilationUnitTree cut = task.parse().iterator().next(); 240.98 + task.analyze(); 240.99 + 240.100 + final List<int[]> declarationSpans = new ArrayList<>(); 240.101 + 240.102 + new TreeScanner<Void, Void>() { 240.103 + @Override public Void visitClass(ClassTree node, Void p) { 240.104 + handleDeclaration(node); 240.105 + return super.visitClass(node, p); 240.106 + } 240.107 + @Override public Void visitMethod(MethodTree node, Void p) { 240.108 + handleDeclaration(node); 240.109 + return super.visitMethod(node, p); 240.110 + } 240.111 + @Override public Void visitVariable(VariableTree node, Void p) { 240.112 + handleDeclaration(node); 240.113 + return super.visitVariable(node, p); 240.114 + } 240.115 + 240.116 + @Override 240.117 + public Void visitNewClass(NewClassTree node, Void p) { 240.118 + if (node.getClassBody() != null) { 240.119 + scan(node.getClassBody().getMembers(), null); 240.120 + } 240.121 + return null; 240.122 + } 240.123 + 240.124 + private void handleDeclaration(Tree node) { 240.125 + int endPos = (int) trees.getSourcePositions().getEndPosition(cut, node); 240.126 + 240.127 + if (endPos == (-1)) { 240.128 + if (node.getKind() == Tree.Kind.METHOD && (((JCMethodDecl) node).getModifiers().flags & Flags.GENERATEDCONSTR) != 0) { 240.129 + return ; 240.130 + } 240.131 + throw new IllegalStateException(); 240.132 + } 240.133 + 240.134 + declarationSpans.add(new int[] {(int) trees.getSourcePositions().getStartPosition(cut, node), endPos}); 240.135 + } 240.136 + }.scan(cut, null); 240.137 + 240.138 + for (final int[] declarationSpan : declarationSpans) { 240.139 + final String suppressWarnings = "@SuppressWarnings({\"deprecation\", \"unchecked\", \"serial\"})"; 240.140 + final String updatedContent = testContent.substring(0, declarationSpan[0]) + suppressWarnings + testContent.substring(declarationSpan[0]); 240.141 + final List<Diagnostic<?>> foundErrors = new ArrayList<>(diagnostics); 240.142 + DiagnosticListener<JavaFileObject> verifyDiagnostics = new DiagnosticListener<JavaFileObject>() { 240.143 + @Override public void report(Diagnostic<? extends JavaFileObject> diagnostic) { 240.144 + long adjustedPos = diagnostic.getPosition(); 240.145 + 240.146 + if (adjustedPos >= declarationSpan[0]) adjustedPos -= suppressWarnings.length(); 240.147 + 240.148 + if (declarationSpan[0] <= adjustedPos && adjustedPos <= declarationSpan[1]) { 240.149 + throw new IllegalStateException("unsuppressed: " + diagnostic.getMessage(null)); 240.150 + } 240.151 + 240.152 + boolean found = false; 240.153 + 240.154 + for (Iterator<Diagnostic<?>> it = foundErrors.iterator(); it.hasNext();) { 240.155 + Diagnostic<?> d = it.next(); 240.156 + if (d.getPosition() == adjustedPos && d.getCode().equals(diagnostic.getCode())) { 240.157 + it.remove(); 240.158 + found = true; 240.159 + break; 240.160 + } 240.161 + } 240.162 + 240.163 + if (!found) { 240.164 + throw new IllegalStateException("diagnostic not originally reported: " + diagnostic.getMessage(null)); 240.165 + } 240.166 + } 240.167 + }; 240.168 + 240.169 + JavaFileObject updatedFile = new TestFO(new URI("mem://" + args[0]), updatedContent); 240.170 + JavacTask testTask = JavacTool.create().getTask(null, 240.171 + new TestFM(fm), 240.172 + verifyDiagnostics, 240.173 + STANDARD_PARAMS, 240.174 + null, 240.175 + Arrays.asList(updatedFile)); 240.176 + 240.177 + testTask.analyze(); 240.178 + 240.179 + for (Diagnostic<?> d : foundErrors) { 240.180 + if (d.getPosition() < declarationSpan[0] || declarationSpan[1] < d.getPosition()) { 240.181 + throw new IllegalStateException("missing: " + d.getMessage(null)); 240.182 + } 240.183 + } 240.184 + } 240.185 + } 240.186 + 240.187 + private static final class TestFO extends SimpleJavaFileObject { 240.188 + private final String content; 240.189 + public TestFO(URI uri, String content) { 240.190 + super(uri, Kind.SOURCE); 240.191 + this.content = content; 240.192 + } 240.193 + 240.194 + @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { 240.195 + return content; 240.196 + } 240.197 + 240.198 + @Override public boolean isNameCompatible(String simpleName, Kind kind) { 240.199 + return true; 240.200 + } 240.201 + } 240.202 + 240.203 + private static final class TestFM extends ForwardingJavaFileManager<JavaFileManager> { 240.204 + 240.205 + public TestFM(JavaFileManager fileManager) { 240.206 + super(fileManager); 240.207 + } 240.208 + 240.209 + @Override 240.210 + public boolean isSameFile(FileObject a, FileObject b) { 240.211 + return a.equals(b); 240.212 + } 240.213 + 240.214 + } 240.215 +}
241.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 241.2 +++ b/test/tools/javac/warnings/suppress/pack/DeprecatedClass.java Tue Sep 17 08:21:11 2013 -0700 241.3 @@ -0,0 +1,5 @@ 241.4 +/* /nodynamiccopyright/ */ 241.5 +package pack; 241.6 +@Deprecated 241.7 +@interface DeprecatedClass { 241.8 +}
242.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 242.2 +++ b/test/tools/javac/warnings/suppress/pack/ImplicitMain.java Tue Sep 17 08:21:11 2013 -0700 242.3 @@ -0,0 +1,14 @@ 242.4 +/* /nodynamiccopyright/ */ 242.5 +package pack; 242.6 + 242.7 +@SuppressWarnings("deprecation") 242.8 +public class ImplicitMain { 242.9 + private Object test() { 242.10 + return new ImplicitUse(); 242.11 + } 242.12 +} 242.13 + 242.14 +@Deprecated 242.15 +class Dep { 242.16 + 242.17 +}
243.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 243.2 +++ b/test/tools/javac/warnings/suppress/pack/ImplicitUse.java Tue Sep 17 08:21:11 2013 -0700 243.3 @@ -0,0 +1,7 @@ 243.4 +/* /nodynamiccopyright/ */ 243.5 +package pack; 243.6 + 243.7 +import pack.Dep; 243.8 + 243.9 +public class ImplicitUse { 243.10 +}
244.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 244.2 +++ b/test/tools/javac/warnings/suppress/pack/package-info.java Tue Sep 17 08:21:11 2013 -0700 244.3 @@ -0,0 +1,5 @@ 244.4 +/* /nodynamiccopyright/ */ 244.5 +@DeprecatedClass 244.6 +package pack; 244.7 + 244.8 +import pack.DeprecatedClass;
245.1 --- a/test/tools/javadoc/api/basic/APITest.java Thu Sep 12 11:09:20 2013 -0700 245.2 +++ b/test/tools/javadoc/api/basic/APITest.java Tue Sep 17 08:21:11 2013 -0700 245.3 @@ -1,5 +1,5 @@ 245.4 /* 245.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 245.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 245.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 245.8 * 245.9 * This code is free software; you can redistribute it and/or modify it 245.10 @@ -29,6 +29,7 @@ 245.11 import java.lang.reflect.InvocationTargetException; 245.12 import java.lang.reflect.Method; 245.13 import java.net.URI; 245.14 +import java.nio.file.DirectoryStream; 245.15 import java.nio.file.Files; 245.16 import java.nio.file.Path; 245.17 import java.util.Arrays; 245.18 @@ -164,11 +165,13 @@ 245.19 } 245.20 245.21 private void listFiles(Path dir, Set<Path> files) throws IOException { 245.22 - for (Path f: Files.newDirectoryStream(dir)) { 245.23 - if (Files.isDirectory(f)) 245.24 - listFiles(f, files); 245.25 - else if (Files.isRegularFile(f)) 245.26 - files.add(f); 245.27 + try (DirectoryStream<Path> ds = Files.newDirectoryStream(dir)) { 245.28 + for (Path f: ds) { 245.29 + if (Files.isDirectory(f)) 245.30 + listFiles(f, files); 245.31 + else if (Files.isRegularFile(f)) 245.32 + files.add(f); 245.33 + } 245.34 } 245.35 } 245.36
246.1 --- a/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java Thu Sep 12 11:09:20 2013 -0700 246.2 +++ b/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java Tue Sep 17 08:21:11 2013 -0700 246.3 @@ -1,5 +1,5 @@ 246.4 /* 246.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 246.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 246.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 246.8 * 246.9 * This code is free software; you can redistribute it and/or modify it 246.10 @@ -23,7 +23,7 @@ 246.11 246.12 /* 246.13 * @test 246.14 - * @bug 6493690 246.15 + * @bug 6493690 8024434 246.16 * @summary javadoc should have a javax.tools.Tool service provider 246.17 * @build APITest 246.18 * @run main GetTask_FileManagerTest