--- a/langtools/make/CompileInterim.gmk Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/make/CompileInterim.gmk Wed Apr 08 14:32:21 2015 -0700
@@ -43,7 +43,6 @@
$(LANGTOOLS_TOPDIR)/src/jdk.compiler/share/classes \
$(LANGTOOLS_TOPDIR)/src/jdk.dev/share/classes \
$(LANGTOOLS_TOPDIR)/src/jdk.javadoc/share/classes \
- $(LANGTOOLS_TOPDIR)/src/java.base/share/classes \
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.compiler \
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.dev \
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.javadoc, \
--- a/langtools/make/Makefile Wed Apr 08 13:12:52 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#
-# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation. Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# Locate this Makefile
-ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))), )
- makefile_path := $(CURDIR)/$(lastword $(MAKEFILE_LIST))
-else
- makefile_path := $(lastword $(MAKEFILE_LIST))
-endif
-repo_dir := $(patsubst %/make/Makefile, %, $(makefile_path))
-
-# What is the name of this subsystem (langtools, corba, etc)?
-subsystem_name := $(notdir $(repo_dir))
-
-# Try to locate top-level makefile
-top_level_makefile := $(repo_dir)/../Makefile
-ifneq ($(wildcard $(top_level_makefile)), )
- $(info Will run $(subsystem_name) target on top-level Makefile)
- $(info WARNING: This is a non-recommended way of building!)
- $(info ===================================================)
-else
- $(info Cannot locate top-level Makefile. Is this repo not checked out as part of a complete forest?)
- $(error Build from top-level Makefile instead)
-endif
-
-all:
- @$(MAKE) -f $(top_level_makefile) $(subsystem_name)
--- a/langtools/make/build.properties Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/make/build.properties Wed Apr 08 14:32:21 2015 -0700
@@ -47,12 +47,11 @@
boot.javac.target = 8
#configuration of submodules (share by both the bootstrap and normal compilation):
-langtools.modules=java.base:java.compiler:jdk.compiler:jdk.dev:jdk.javadoc
-java.base.dependencies=
-java.compiler.dependencies=java.base
-jdk.compiler.dependencies=java.base:java.compiler
-jdk.javadoc.dependencies=java.base:java.compiler:jdk.compiler
-jdk.dev.dependencies=java.base:java.compiler:jdk.compiler
+langtools.modules=java.compiler:jdk.compiler:jdk.dev:jdk.javadoc
+java.compiler.dependencies=
+jdk.compiler.dependencies=java.compiler
+jdk.javadoc.dependencies=java.compiler:jdk.compiler
+jdk.dev.dependencies=java.compiler:jdk.compiler
javac.resource.includes = \
com/sun/tools/javac/resources/compiler.properties
--- a/langtools/make/build.xml Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/make/build.xml Wed Apr 08 14:32:21 2015 -0700
@@ -254,7 +254,6 @@
warningsProperty="findbugs.all.warnings"
jvm="${target.java.home}/bin/java"
jvmargs="-Xmx512M">
- <class location="${build.dir}/java.base/classes"/>
<class location="${build.dir}/java.compiler/classes"/>
<class location="${build.dir}/jdk.compiler/classes"/>
<class location="${build.dir}/jdk.javadoc/classes"/>
@@ -461,7 +460,6 @@
<macrodef name="build-all-module-jars">
<attribute name="compilation.kind" default=""/>
<sequential>
- <build-module-jar module.name="java.base" compilation.kind="@{compilation.kind}" />
<build-module-jar module.name="java.compiler" compilation.kind="@{compilation.kind}" />
<build-module-jar module.name="jdk.compiler" compilation.kind="@{compilation.kind}" />
<build-module-jar module.name="jdk.javadoc" compilation.kind="@{compilation.kind}" />
@@ -522,8 +520,6 @@
<macrodef name="build-all-module-classes">
<attribute name="compilation.kind" default=""/>
<sequential>
- <build-module-classes module.name="java.base"
- compilation.kind="@{compilation.kind}" />
<build-module-classes module.name="java.compiler"
compilation.kind="@{compilation.kind}" />
<build-module-classes module.name="jdk.compiler"
--- a/langtools/make/intellij/langtools.iml Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/make/intellij/langtools.iml Wed Apr 08 14:32:21 2015 -0700
@@ -4,13 +4,11 @@
<output url="file://$MODULE_DIR$/build" />
<output-test url="file://$MODULE_DIR$/build" />
<content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/src/java.base/share/classes" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/java.compiler/share/classes" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/jdk.compiler/share/classes" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/jdk.dev/share/classes" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/jdk.javadoc/share/classes" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
- <sourceFolder url="file://$MODULE_DIR$/build/bootstrap/java.base/gensrc" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/bootstrap/java.compiler/gensrc" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/bootstrap/jdk.compiler/gensrc" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/bootstrap/jdk.dev/gensrc" isTestSource="false" />
--- a/langtools/make/intellij/workspace.xml Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/make/intellij/workspace.xml Wed Apr 08 14:32:21 2015 -0700
@@ -10,7 +10,7 @@
<!-- standard tools -->
<configuration default="false" name="javac" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.javac.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -29,7 +29,7 @@
</configuration>
<configuration default="false" name="javadoc" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.javadoc.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -48,7 +48,7 @@
</configuration>
<configuration default="false" name="javap" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.javap.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -67,7 +67,7 @@
</configuration>
<configuration default="false" name="javah" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.javah.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -86,7 +86,7 @@
</configuration>
<configuration default="false" name="sjavac" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.sjavac.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -106,7 +106,7 @@
<!-- bootstrap javac -->
<configuration default="false" name="javac (bootstrap)" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.javac.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@bootstrap@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@bootstrap@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
--- a/langtools/make/netbeans/langtools/nbproject/project.xml Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/make/netbeans/langtools/nbproject/project.xml Wed Apr 08 14:32:21 2015 -0700
@@ -57,11 +57,6 @@
<location>${root}/make</location>
</source-folder>
<source-folder>
- <label>Source files - java.base</label>
- <type>java</type>
- <location>${root}/src/java.base/share/classes</location>
- </source-folder>
- <source-folder>
<label>Source files - java.compiler</label>
<type>java</type>
<location>${root}/src/java.compiler/share/classes</location>
@@ -107,19 +102,6 @@
</action>
<action name="compile.single">
<target>compile-single</target>
- <property name="module.name">java.base</property>
- <context>
- <property>includes</property>
- <folder>${root}/src/java.base/share/classes</folder>
- <pattern>\.java$</pattern>
- <format>relative-path</format>
- <arity>
- <separated-files>,</separated-files>
- </arity>
- </context>
- </action>
- <action name="compile.single">
- <target>compile-single</target>
<property name="module.name">java.compiler</property>
<context>
<property>includes</property>
@@ -259,18 +241,6 @@
<target>debug-single</target>
<context>
<property>debug.classname</property>
- <folder>${root}/src/java.base/share/classes</folder>
- <pattern>\.java$</pattern>
- <format>java-name</format>
- <arity>
- <one-file-only/>
- </arity>
- </context>
- </action>
- <action name="debug.single">
- <target>debug-single</target>
- <context>
- <property>debug.classname</property>
<folder>${root}/src/java.compiler/share/classes</folder>
<pattern>\.java$</pattern>
<format>java-name</format>
@@ -333,19 +303,6 @@
</action>
<action name="debug.fix">
<target>debug-fix</target>
- <property name="module.name">java.base</property>
- <context>
- <property>class</property>
- <folder>${root}/src/java.base/share/classes</folder>
- <pattern>\.java$</pattern>
- <format>relative-path-noext</format>
- <arity>
- <one-file-only/>
- </arity>
- </context>
- </action>
- <action name="debug.fix">
- <target>debug-fix</target>
<property name="module.name">java.compiler</property>
<context>
<property>class</property>
@@ -417,10 +374,6 @@
<view>
<items>
<source-folder style="tree">
- <label>Source files - java.base</label>
- <location>${root}/src/java.base/share/classes</location>
- </source-folder>
- <source-folder style="tree">
<label>Source files - java.compiler</label>
<location>${root}/src/java.compiler/share/classes</location>
</source-folder>
@@ -477,36 +430,29 @@
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/4">
<compilation-unit>
- <package-root>${root}/src/java.base/share/classes</package-root>
- <package-root>${root}/build/bootstrap/java.base/gensrc</package-root>
- <built-to>${root}/build/java.base/classes</built-to>
- <source-level>1.8</source-level>
- </compilation-unit>
- <compilation-unit>
<package-root>${root}/src/java.compiler/share/classes</package-root>
<package-root>${root}/build/bootstrap/java.compiler/gensrc</package-root>
- <classpath mode="compile">${root}/build/java.base/classes</classpath>
<built-to>${root}/build/java.compiler/classes</built-to>
<source-level>1.8</source-level>
</compilation-unit>
<compilation-unit>
<package-root>${root}/src/jdk.compiler/share/classes</package-root>
<package-root>${root}/build/bootstrap/jdk.compiler/gensrc</package-root>
- <classpath mode="compile">${root}/build/java.base/classes:${root}/build/java.compiler/classes</classpath>
+ <classpath mode="compile">${root}/build/java.compiler/classes</classpath>
<built-to>${root}/build/jdk.compiler/classes</built-to>
<source-level>1.8</source-level>
</compilation-unit>
<compilation-unit>
<package-root>${root}/src/jdk.dev/share/classes</package-root>
<package-root>${root}/build/bootstrap/jdk.dev/gensrc</package-root>
- <classpath mode="compile">${root}/build/java.base/classes:${root}/build/java.compiler/classes:${root}/build/jdk.compiler/classes</classpath>
+ <classpath mode="compile">${root}/build/java.compiler/classes:${root}/build/jdk.compiler/classes</classpath>
<built-to>${root}/build/jdk.dev/classes</built-to>
<source-level>1.8</source-level>
</compilation-unit>
<compilation-unit>
<package-root>${root}/src/jdk.javadoc/share/classes</package-root>
<package-root>${root}/build/bootstrap/jdk.javadoc/gensrc</package-root>
- <classpath mode="compile">${root}/build/java.base/classes:${root}/build/java.compiler/classes:${root}/build/jdk.compiler/classes</classpath>
+ <classpath mode="compile">${root}/build/java.compiler/classes:${root}/build/jdk.compiler/classes</classpath>
<built-to>${root}/build/jdk.javadoc/classes</built-to>
<source-level>1.8</source-level>
</compilation-unit>
--- a/langtools/src/java.base/share/classes/jdk/Exported.java Wed Apr 08 13:12:52 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk;
-
-import java.lang.annotation.*;
-
-/**
- * Indicates whether or not a JDK specific type or package is an
- * exported part of the JDK suitable for use outside of the JDK
- * implementation itself.
- *
- * This annotation should only be applied to types and packages
- * <em>outside</em> of the Java SE namespaces of {@code java.*} and
- * {@code javax.*} packages. For example, certain portions of {@code
- * com.sun.*} are official parts of the JDK meant to be generally
- * usable while other portions of {@code com.sun.*} are not. This
- * annotation type allows those portions to be easily and
- * programmatically distinguished.
- *
- * <p>If in one release a type or package is
- * <code>@Exported(true)</code>, in a subsequent major release such a
- * type or package can transition to <code>@Exported(false)</code>.
- *
- * <p>If a type or package is <code>@Exported(false)</code> in a
- * release, it may be removed in a subsequent major release.
- *
- * <p>If a top-level type has an <code>@Exported</code> annotation,
- * any nested member types with the top-level type should have an
- * <code>@Exported</code> annotation with the same value.
- *
- * (In exceptional cases, if a nested type is going to be removed
- * before its enclosing type, the nested type's could be
- * <code>@Exported(false)</code> while its enclosing type was
- * <code>@Exported(true)</code>.)
- *
- * Likewise, if a package has an <code>@Exported</code> annotation,
- * top-level types within that package should also have an
- * <code>@Exported</code> annotation.
- *
- * Sometimes a top-level type may have a different
- * <code>@Exported</code> value than its package.
- *
- * @since 1.8
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.PACKAGE})
-@Exported
-public @interface Exported {
- /**
- * Whether or not the annotated type or package is an exported
- * part of the JDK.
- * @return whether or not the annotated type or package is an exported
- * part of the JDK
- */
- boolean value() default true;
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Wed Apr 08 14:32:21 2015 -0700
@@ -40,6 +40,7 @@
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.comp.*;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.main.*;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.parser.Parser;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java Wed Apr 08 14:32:21 2015 -0700
@@ -44,7 +44,7 @@
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.main.Arguments;
import com.sun.tools.javac.main.Option;
-import com.sun.tools.javac.util.BaseFileManager;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.util.ClientCodeException;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.DefinedBy;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Kinds.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Kinds.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -66,22 +66,22 @@
MTH(Category.BASIC, KindName.METHOD, KindSelector.MTH),
POLY(Category.BASIC, KindSelector.POLY),
ERR(Category.ERROR, KindSelector.ERR),
- AMBIGUOUS(Category.OVERLOAD),
- HIDDEN(Category.OVERLOAD),
- STATICERR(Category.OVERLOAD),
- MISSING_ENCL(Category.OVERLOAD),
- ABSENT_VAR(Category.OVERLOAD, KindName.VAR),
- WRONG_MTHS(Category.OVERLOAD, KindName.METHOD),
- WRONG_MTH(Category.OVERLOAD, KindName.METHOD),
- ABSENT_MTH(Category.OVERLOAD, KindName.METHOD),
- ABSENT_TYP(Category.OVERLOAD, KindName.CLASS);
+ AMBIGUOUS(Category.RESOLUTION_TARGET), // overloaded target
+ HIDDEN(Category.RESOLUTION_TARGET), // not overloaded non-target
+ STATICERR(Category.RESOLUTION_TARGET), // overloaded? target
+ MISSING_ENCL(Category.RESOLUTION), // not overloaded non-target
+ ABSENT_VAR(Category.RESOLUTION_TARGET, KindName.VAR), // not overloaded non-target
+ WRONG_MTHS(Category.RESOLUTION_TARGET, KindName.METHOD), // overloaded target
+ WRONG_MTH(Category.RESOLUTION_TARGET, KindName.METHOD), // not overloaded target
+ ABSENT_MTH(Category.RESOLUTION_TARGET, KindName.METHOD), // not overloaded non-target
+ ABSENT_TYP(Category.RESOLUTION_TARGET, KindName.CLASS); // not overloaded non-target
// There are essentially two "levels" to the Kind datatype.
// The first is a totally-ordered set of categories of
// solutions. Within each category, we have more
// possibilities.
private enum Category {
- BASIC, ERROR, OVERLOAD;
+ BASIC, ERROR, RESOLUTION, RESOLUTION_TARGET;
}
private final KindName kindName;
@@ -127,8 +127,12 @@
return selector.contains(kindSelectors);
}
- public boolean isOverloadError() {
- return category == Category.OVERLOAD;
+ public boolean isResolutionError() {
+ return category == Category.RESOLUTION || category == Category.RESOLUTION_TARGET;
+ }
+
+ public boolean isResolutionTargetError() {
+ return category == Category.RESOLUTION_TARGET;
}
public boolean isValid() {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java Wed Apr 08 14:32:21 2015 -0700
@@ -209,6 +209,9 @@
public boolean allowPrivateSafeVarargs() {
return compareTo(JDK1_9) >= 0;
}
+ public boolean allowDiamondWithAnonymousClassCreation() {
+ return compareTo(JDK1_9) >= 0;
+ }
public boolean allowUnderscoreIdentifier() {
return compareTo(JDK1_8) <= 0;
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -90,6 +90,7 @@
final DeferredAttr deferredAttr;
final TreeMaker make;
final Names names;
+ private final boolean allowDiamondWithAnonymousClassCreation;
final EnumSet<AnalyzerMode> analyzerModes;
@@ -112,6 +113,7 @@
String findOpt = options.get("find");
//parse modes
Source source = Source.instance(context);
+ allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation();
analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source);
}
@@ -210,7 +212,7 @@
boolean match(JCNewClass tree) {
return tree.clazz.hasTag(TYPEAPPLY) &&
!TreeInfo.isDiamond(tree) &&
- tree.def == null;
+ (tree.def == null || allowDiamondWithAnonymousClassCreation);
}
@Override
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Wed Apr 08 14:32:21 2015 -0700
@@ -46,6 +46,10 @@
import com.sun.tools.javac.comp.Infer.InferenceContext;
import com.sun.tools.javac.comp.Infer.FreeTypeListener;
import com.sun.tools.javac.jvm.*;
+import static com.sun.tools.javac.resources.CompilerProperties.Fragments.Diamond;
+import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArg;
+import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArgs;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
import com.sun.tools.javac.resources.CompilerProperties.Fragments;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.tree.JCTree.*;
@@ -54,6 +58,7 @@
import com.sun.tools.javac.util.DefinedBy.Api;
import com.sun.tools.javac.util.Dependencies.AttributionKind;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.JCDiagnostic.Fragment;
import com.sun.tools.javac.util.List;
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Flags.ANNOTATION;
@@ -219,6 +224,26 @@
final Type found,
final KindSelector ownkind,
final ResultInfo resultInfo) {
+ return check(tree, found, ownkind, resultInfo, true);
+ }
+ /** Check kind and type of given tree against protokind and prototype.
+ * If check succeeds, store type in tree and return it.
+ * If check fails, store errType in tree and return it.
+ * No checks are performed if the prototype is a method type.
+ * It is not necessary in this case since we know that kind and type
+ * are correct.
+ *
+ * @param tree The tree whose kind and type is checked
+ * @param found The computed type of the tree
+ * @param ownkind The computed kind of the tree
+ * @param resultInfo The expected result of the tree
+ * @param recheckPostInference If true and inference is underway, arrange to recheck the tree after inference finishes.
+ */
+ Type check(final JCTree tree,
+ final Type found,
+ final KindSelector ownkind,
+ final ResultInfo resultInfo,
+ boolean recheckPostInference) {
InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
Type owntype;
boolean shouldCheck = !found.hasTag(ERROR) &&
@@ -233,12 +258,14 @@
//delay the check if there are inference variables in the found type
//this means we are dealing with a partially inferred poly expression
owntype = shouldCheck ? resultInfo.pt : found;
- inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt),
- instantiatedContext -> {
- ResultInfo pendingResult =
- resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
- check(tree, inferenceContext.asInstType(found), ownkind, pendingResult);
- });
+ if (recheckPostInference) {
+ inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt),
+ instantiatedContext -> {
+ ResultInfo pendingResult =
+ resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
+ check(tree, inferenceContext.asInstType(found), ownkind, pendingResult, false);
+ });
+ }
} else {
owntype = shouldCheck ?
resultInfo.check(tree, found) :
@@ -862,7 +889,7 @@
} else {
chk.checkOverrideClashes(tree.pos(), env.enclClass.type, m);
}
- chk.checkOverride(tree, m);
+ chk.checkOverride(env, tree, m);
if (isDefaultMethod && types.overridesObjectMethod(m.enclClass(), m)) {
log.error(tree, "default.overrides.object.member", m.name, Kinds.kindName(m.location()), m.location());
@@ -1969,11 +1996,16 @@
(((JCVariableDecl) env.tree).mods.flags & Flags.ENUM) == 0 ||
((JCVariableDecl) env.tree).init != tree))
log.error(tree.pos(), "enum.cant.be.instantiated");
+
+ boolean isSpeculativeDiamondInferenceRound = TreeInfo.isDiamond(tree) &&
+ resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
+ boolean skipNonDiamondPath = false;
// Check that class is not abstract
- if (cdef == null &&
+ if (cdef == null && !isSpeculativeDiamondInferenceRound && // class body may be nulled out in speculative tree copy
(clazztype.tsym.flags() & (ABSTRACT | INTERFACE)) != 0) {
log.error(tree.pos(), "abstract.cant.be.instantiated",
clazztype.tsym);
+ skipNonDiamondPath = true;
} else if (cdef != null && clazztype.tsym.isInterface()) {
// Check that no constructor arguments are given to
// anonymous classes implementing an interface
@@ -1986,7 +2018,9 @@
// Error recovery: pretend no arguments were supplied.
argtypes = List.nil();
typeargtypes = List.nil();
- } else if (TreeInfo.isDiamond(tree)) {
+ skipNonDiamondPath = true;
+ }
+ if (TreeInfo.isDiamond(tree)) {
ClassType site = new ClassType(clazztype.getEnclosingType(),
clazztype.tsym.type.getTypeArguments(),
clazztype.tsym,
@@ -2022,7 +2056,7 @@
tree.clazz.type = types.createErrorType(clazztype);
if (!constructorType.isErroneous()) {
- tree.clazz.type = clazztype = constructorType.getReturnType();
+ tree.clazz.type = clazz.type = constructorType.getReturnType();
tree.constructorType = types.createMethodTypeWithReturn(constructorType, syms.voidType);
}
clazztype = chk.checkClassType(tree.clazz, tree.clazz.type, true);
@@ -2031,7 +2065,7 @@
// Resolve the called constructor under the assumption
// that we are referring to a superclass instance of the
// current instance (JLS ???).
- else {
+ else if (!skipNonDiamondPath) {
//the following code alters some of the fields in the current
//AttrContext - hence, the current context must be dup'ed in
//order to avoid downstream failures
@@ -2052,70 +2086,8 @@
}
if (cdef != null) {
- // We are seeing an anonymous class instance creation.
- // In this case, the class instance creation
- // expression
- //
- // E.new <typeargs1>C<typargs2>(args) { ... }
- //
- // is represented internally as
- //
- // E . new <typeargs1>C<typargs2>(args) ( class <empty-name> { ... } ) .
- //
- // This expression is then *transformed* as follows:
- //
- // (1) add an extends or implements clause
- // (2) add a constructor.
- //
- // For instance, if C is a class, and ET is the type of E,
- // the expression
- //
- // E.new <typeargs1>C<typargs2>(args) { ... }
- //
- // is translated to (where X is a fresh name and typarams is the
- // parameter list of the super constructor):
- //
- // new <typeargs1>X(<*nullchk*>E, args) where
- // X extends C<typargs2> {
- // <typarams> X(ET e, args) {
- // e.<typeargs1>super(args)
- // }
- // ...
- // }
-
- if (clazztype.tsym.isInterface()) {
- cdef.implementing = List.of(clazz);
- } else {
- cdef.extending = clazz;
- }
-
- if (resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK &&
- isSerializable(clazztype)) {
- localEnv.info.isSerializable = true;
- }
-
- attribStat(cdef, localEnv);
-
- // If an outer instance is given,
- // prefix it to the constructor arguments
- // and delete it from the new expression
- if (tree.encl != null && !clazztype.tsym.isInterface()) {
- tree.args = tree.args.prepend(makeNullCheck(tree.encl));
- argtypes = argtypes.prepend(tree.encl.type);
- tree.encl = null;
- }
-
- // Reassign clazztype and recompute constructor.
- clazztype = cdef.sym.type;
- Symbol sym = tree.constructor = rs.resolveConstructor(
- tree.pos(), localEnv, clazztype, argtypes, typeargtypes);
- Assert.check(!sym.kind.isOverloadError());
- tree.constructor = sym;
- tree.constructorType = checkId(noCheckTree,
- clazztype,
- tree.constructor,
- localEnv,
- new ResultInfo(pkind, newMethodTemplate(syms.voidType, argtypes, typeargtypes)));
+ visitAnonymousClassDefinition(tree, clazz, clazztype, cdef, localEnv, argtypes, typeargtypes, pkind);
+ return;
}
if (tree.constructor != null && tree.constructor.kind == MTH)
@@ -2133,6 +2105,125 @@
chk.validate(tree.typeargs, localEnv);
}
+ // where
+ private void visitAnonymousClassDefinition(JCNewClass tree, JCExpression clazz, Type clazztype,
+ JCClassDecl cdef, Env<AttrContext> localEnv,
+ List<Type> argtypes, List<Type> typeargtypes,
+ KindSelector pkind) {
+ // We are seeing an anonymous class instance creation.
+ // In this case, the class instance creation
+ // expression
+ //
+ // E.new <typeargs1>C<typargs2>(args) { ... }
+ //
+ // is represented internally as
+ //
+ // E . new <typeargs1>C<typargs2>(args) ( class <empty-name> { ... } ) .
+ //
+ // This expression is then *transformed* as follows:
+ //
+ // (1) add an extends or implements clause
+ // (2) add a constructor.
+ //
+ // For instance, if C is a class, and ET is the type of E,
+ // the expression
+ //
+ // E.new <typeargs1>C<typargs2>(args) { ... }
+ //
+ // is translated to (where X is a fresh name and typarams is the
+ // parameter list of the super constructor):
+ //
+ // new <typeargs1>X(<*nullchk*>E, args) where
+ // X extends C<typargs2> {
+ // <typarams> X(ET e, args) {
+ // e.<typeargs1>super(args)
+ // }
+ // ...
+ // }
+ InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
+ final boolean isDiamond = TreeInfo.isDiamond(tree);
+ if (isDiamond
+ && ((tree.constructorType != null && inferenceContext.free(tree.constructorType))
+ || (tree.clazz.type != null && inferenceContext.free(tree.clazz.type)))) {
+ inferenceContext.addFreeTypeListener(List.of(tree.constructorType, tree.clazz.type),
+ instantiatedContext -> {
+ tree.constructorType = instantiatedContext.asInstType(tree.constructorType);
+ clazz.type = instantiatedContext.asInstType(clazz.type);
+ visitAnonymousClassDefinition(tree, clazz, clazz.type, cdef, localEnv, argtypes, typeargtypes, pkind);
+ });
+ } else {
+ if (isDiamond && clazztype.hasTag(CLASS)) {
+ List<Type> invalidDiamondArgs = chk.checkDiamondDenotable((ClassType)clazztype);
+ if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) {
+ // One or more types inferred in the previous steps is non-denotable.
+ Fragment fragment = Diamond(clazztype.tsym);
+ log.error(tree.clazz.pos(),
+ Errors.CantApplyDiamond1(
+ fragment,
+ invalidDiamondArgs.size() > 1 ?
+ DiamondInvalidArgs(invalidDiamondArgs, fragment) :
+ DiamondInvalidArg(invalidDiamondArgs, fragment)));
+ }
+ // For <>(){}, inferred types must also be accessible.
+ for (Type t : clazztype.getTypeArguments()) {
+ rs.checkAccessibleType(env, t);
+ }
+ }
+
+ // If we already errored, be careful to avoid a further avalanche. ErrorType answers
+ // false for isInterface call even when the original type is an interface.
+ boolean implementing = clazztype.tsym.isInterface() ||
+ clazztype.isErroneous() && clazztype.getOriginalType().tsym.isInterface();
+
+ if (implementing) {
+ cdef.implementing = List.of(clazz);
+ } else {
+ cdef.extending = clazz;
+ }
+
+ if (resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK &&
+ isSerializable(clazztype)) {
+ localEnv.info.isSerializable = true;
+ }
+
+ attribStat(cdef, localEnv);
+
+ List<Type> finalargtypes;
+ // If an outer instance is given,
+ // prefix it to the constructor arguments
+ // and delete it from the new expression
+ if (tree.encl != null && !clazztype.tsym.isInterface()) {
+ tree.args = tree.args.prepend(makeNullCheck(tree.encl));
+ finalargtypes = argtypes.prepend(tree.encl.type);
+ tree.encl = null;
+ } else {
+ finalargtypes = argtypes;
+ }
+
+ // Reassign clazztype and recompute constructor. As this necessarily involves
+ // another attribution pass for deferred types in the case of <>, replicate
+ // them. Original arguments have right decorations already.
+ if (isDiamond && pkind.contains(KindSelector.POLY)) {
+ finalargtypes = finalargtypes.map(deferredAttr.deferredCopier);
+ }
+
+ clazztype = cdef.sym.type;
+ Symbol sym = tree.constructor = rs.resolveConstructor(
+ tree.pos(), localEnv, clazztype, finalargtypes, typeargtypes);
+ Assert.check(!sym.kind.isResolutionError());
+ tree.constructor = sym;
+ tree.constructorType = checkId(noCheckTree,
+ clazztype,
+ tree.constructor,
+ localEnv,
+ new ResultInfo(pkind, newMethodTemplate(syms.voidType, finalargtypes, typeargtypes)));
+ }
+ Type owntype = (tree.constructor != null && tree.constructor.kind == MTH) ?
+ clazztype : types.createErrorType(tree.type);
+ result = check(tree, owntype, KindSelector.VAL, resultInfo, false);
+ chk.validate(tree.typeargs, localEnv);
+ }
+
/** Make an attributed null check tree.
*/
public JCExpression makeNullCheck(JCExpression arg) {
@@ -2647,17 +2738,20 @@
Symbol refSym = refResult.fst;
Resolve.ReferenceLookupHelper lookupHelper = refResult.snd;
+ /** this switch will need to go away and be replaced by the new RESOLUTION_TARGET testing
+ * JDK-8075541
+ */
if (refSym.kind != MTH) {
boolean targetError;
switch (refSym.kind) {
case ABSENT_MTH:
+ case MISSING_ENCL:
targetError = false;
break;
case WRONG_MTH:
case WRONG_MTHS:
case AMBIGUOUS:
case HIDDEN:
- case MISSING_ENCL:
case STATICERR:
targetError = true;
break;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -63,6 +63,11 @@
*/
boolean isSpeculative = false;
+ /**
+ * Is this an attribution environment for an anonymous class instantiated using <> ?
+ */
+ boolean isAnonymousDiamond = false;
+
/** Are arguments to current function applications boxed into an array for varargs?
*/
Resolve.MethodResolutionPhase pendingResolutionPhase = null;
@@ -100,6 +105,7 @@
info.defaultSuperCallSite = defaultSuperCallSite;
info.isSerializable = isSerializable;
info.isSpeculative = isSpeculative;
+ info.isAnonymousDiamond = isAnonymousDiamond;
return info;
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Wed Apr 08 14:32:21 2015 -0700
@@ -32,6 +32,8 @@
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Attribute.Compound;
import com.sun.tools.javac.jvm.*;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
+import com.sun.tools.javac.resources.CompilerProperties.Fragments;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -84,6 +86,7 @@
private boolean suppressAbortOnBadClassFile;
private boolean enableSunApiLintControl;
private final JavaFileManager fileManager;
+ private final Source source;
private final Profile profile;
private final boolean warnOnAccessToSensitiveMembers;
@@ -122,11 +125,12 @@
lint = Lint.instance(context);
fileManager = context.get(JavaFileManager.class);
- Source source = Source.instance(context);
+ source = Source.instance(context);
allowSimplifiedVarargs = source.allowSimplifiedVarargs();
allowDefaultMethods = source.allowDefaultMethods();
allowStrictMethodClashCheck = source.allowStrictMethodClashCheck();
allowPrivateSafeVarargs = source.allowPrivateSafeVarargs();
+ allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation();
complexInference = options.isSet("complexinference");
warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
@@ -169,6 +173,10 @@
*/
boolean allowPrivateSafeVarargs;
+ /** Switch: can diamond inference be used in anonymous instance creation ?
+ */
+ boolean allowDiamondWithAnonymousClassCreation;
+
/** Switch: -complexinference option set?
*/
boolean complexInference;
@@ -773,10 +781,9 @@
if (!TreeInfo.isDiamond(tree) ||
t.isErroneous()) {
return checkClassType(tree.clazz.pos(), t, true);
- } else if (tree.def != null) {
+ } else if (tree.def != null && !allowDiamondWithAnonymousClassCreation) {
log.error(tree.clazz.pos(),
- "cant.apply.diamond.1",
- t, diags.fragment("diamond.and.anon.class", t));
+ Errors.CantApplyDiamond1(t, Fragments.DiamondAndAnonClassNotSupportedInSource(source.name)));
return types.createErrorType(t);
} else if (t.tsym.type.getTypeArguments().isEmpty()) {
log.error(tree.clazz.pos(),
@@ -794,6 +801,59 @@
}
}
+ /** Check that the type inferred using the diamond operator does not contain
+ * non-denotable types such as captured types or intersection types.
+ * @param t the type inferred using the diamond operator
+ * @return the (possibly empty) list of non-denotable types.
+ */
+ List<Type> checkDiamondDenotable(ClassType t) {
+ ListBuffer<Type> buf = new ListBuffer<>();
+ for (Type arg : t.getTypeArguments()) {
+ if (!diamondTypeChecker.visit(arg, null)) {
+ buf.append(arg);
+ }
+ }
+ return buf.toList();
+ }
+ // where
+
+ /** diamondTypeChecker: A type visitor that descends down the given type looking for non-denotable
+ * types. The visit methods return false as soon as a non-denotable type is encountered and true
+ * otherwise.
+ */
+ private static final Types.SimpleVisitor<Boolean, Void> diamondTypeChecker = new Types.SimpleVisitor<Boolean, Void>() {
+ @Override
+ public Boolean visitType(Type t, Void s) {
+ return true;
+ }
+ @Override
+ public Boolean visitClassType(ClassType t, Void s) {
+ if (t.isCompound()) {
+ return false;
+ }
+ for (Type targ : t.getTypeArguments()) {
+ if (!visit(targ, s)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ @Override
+ public Boolean visitCapturedType(CapturedType t, Void s) {
+ return false;
+ }
+
+ @Override
+ public Boolean visitArrayType(ArrayType t, Void s) {
+ return visit(t.elemtype, s);
+ }
+
+ @Override
+ public Boolean visitWildcardType(WildcardType t, Void s) {
+ return visit(t.type, s);
+ }
+ };
+
void checkVarargsMethodDecl(Env<AttrContext> env, JCMethodDecl tree) {
MethodSymbol m = tree.sym;
if (!allowSimplifiedVarargs) return;
@@ -1917,7 +1977,7 @@
* for errors.
* @param m The overriding method.
*/
- void checkOverride(JCMethodDecl tree, MethodSymbol m) {
+ void checkOverride(Env<AttrContext> env, JCMethodDecl tree, MethodSymbol m) {
ClassSymbol origin = (ClassSymbol)m.owner;
if ((origin.flags() & ENUM) != 0 && names.finalize.equals(m.name))
if (m.overrides(syms.enumFinalFinalize, origin, types, false)) {
@@ -1934,7 +1994,12 @@
}
}
- if (m.attribute(syms.overrideType.tsym) != null && !isOverrider(m)) {
+ // Check if this method must override a super method due to being annotated with @Override
+ // or by virtue of being a member of a diamond inferred anonymous class. Latter case is to
+ // be treated "as if as they were annotated" with @Override.
+ boolean mustOverride = m.attribute(syms.overrideType.tsym) != null ||
+ (env.info.isAnonymousDiamond && !m.isConstructor() && !m.isPrivate());
+ if (mustOverride && !isOverrider(m)) {
DiagnosticPosition pos = tree.pos();
for (JCAnnotation a : tree.getModifiers().annotations) {
if (a.annotationType.type.tsym == syms.overrideType.tsym) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Apr 08 14:32:21 2015 -0700
@@ -26,6 +26,7 @@
package com.sun.tools.javac.comp;
import com.sun.source.tree.LambdaExpressionTree.BodyKind;
+import com.sun.source.tree.NewClassTree;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Type.TypeMapping;
import com.sun.tools.javac.comp.Resolve.ResolveError;
@@ -81,6 +82,8 @@
final Log log;
final Symtab syms;
final TreeMaker make;
+ final TreeCopier<Void> treeCopier;
+ final TypeMapping<Void> deferredCopier;
final Types types;
final Flow flow;
final Names names;
@@ -125,6 +128,35 @@
return "Empty deferred context!";
}
};
+
+ // For speculative attribution, skip the class definition in <>.
+ treeCopier =
+ new TreeCopier<Void>(make) {
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public JCTree visitNewClass(NewClassTree node, Void p) {
+ JCNewClass t = (JCNewClass) node;
+ if (TreeInfo.isDiamond(t)) {
+ JCExpression encl = copy(t.encl, p);
+ List<JCExpression> typeargs = copy(t.typeargs, p);
+ JCExpression clazz = copy(t.clazz, p);
+ List<JCExpression> args = copy(t.args, p);
+ JCClassDecl def = null;
+ return make.at(t.pos).NewClass(encl, typeargs, clazz, args, def);
+ } else {
+ return super.visitNewClass(node, p);
+ }
+ }
+ };
+ deferredCopier = new TypeMapping<Void> () {
+ @Override
+ public Type visitType(Type t, Void v) {
+ if (t.hasTag(DEFERRED)) {
+ DeferredType dt = (DeferredType) t;
+ return new DeferredType(treeCopier.copy(dt.tree), dt.env);
+ }
+ return t;
+ }
+ };
}
/** shared tree for stuck expressions */
@@ -364,7 +396,7 @@
* disabled during speculative type-checking.
*/
JCTree attribSpeculative(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
- return attribSpeculative(tree, env, resultInfo, new TreeCopier<>(make),
+ return attribSpeculative(tree, env, resultInfo, treeCopier,
(newTree)->new DeferredAttrDiagHandler(log, newTree));
}
@@ -1209,8 +1241,8 @@
rs.getMemberReference(tree, localEnv, mref2,
exprTree.type, tree.name);
tree.sym = res;
- if (res.kind.isOverloadError() ||
- res.type.hasTag(FORALL) ||
+ if (res.kind.isResolutionTargetError() ||
+ res.type != null && res.type.hasTag(FORALL) ||
(res.flags() & Flags.VARARGS) != 0 ||
(TreeInfo.isStaticSelector(exprTree, tree.name.table.names) &&
exprTree.type.isRaw())) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -192,6 +192,7 @@
localEnv.info.isSelfCall = false;
localEnv.info.lint = null; // leave this to be filled in by Attr,
// when annotations have been processed
+ localEnv.info.isAnonymousDiamond = TreeInfo.isDiamond(env.tree);
return localEnv;
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Wed Apr 08 14:32:21 2015 -0700
@@ -1885,7 +1885,7 @@
* Translate a symbol of a given kind into something suitable for the
* synthetic lambda body
*/
- Symbol translate(Name name, final Symbol sym, LambdaSymbolKind skind) {
+ Symbol translate(final Symbol sym, LambdaSymbolKind skind) {
Symbol ret;
switch (skind) {
case CAPTURED_THIS:
@@ -1893,7 +1893,7 @@
break;
case TYPE_VAR:
// Just erase the type var
- ret = new VarSymbol(sym.flags(), name,
+ ret = new VarSymbol(sym.flags(), sym.name,
types.erasure(sym.type), sym.owner);
/* this information should also be kept for LVT generation at Gen
@@ -1902,7 +1902,7 @@
((VarSymbol)ret).pos = ((VarSymbol)sym).pos;
break;
case CAPTURED_VAR:
- ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) {
+ ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, sym.name, types.erasure(sym.type), translatedSym) {
@Override
public Symbol baseSymbol() {
//keep mapping with original captured symbol
@@ -1911,16 +1911,16 @@
};
break;
case LOCAL_VAR:
- ret = new VarSymbol(sym.flags() & FINAL, name, sym.type, translatedSym);
+ ret = new VarSymbol(sym.flags() & FINAL, sym.name, sym.type, translatedSym);
((VarSymbol) ret).pos = ((VarSymbol) sym).pos;
break;
case PARAM:
- ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, name, types.erasure(sym.type), translatedSym);
+ ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, sym.name, types.erasure(sym.type), translatedSym);
((VarSymbol) ret).pos = ((VarSymbol) sym).pos;
break;
default:
- ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym);
- ((VarSymbol) ret).pos = ((VarSymbol) sym).pos;
+ Assert.error(skind.name());
+ throw new AssertionError();
}
if (ret != sym) {
ret.setDeclarationAttributes(sym.getRawAttributes());
@@ -1931,27 +1931,8 @@
void addSymbol(Symbol sym, LambdaSymbolKind skind) {
Map<Symbol, Symbol> transMap = getSymbolMap(skind);
- Name preferredName;
- switch (skind) {
- case CAPTURED_THIS:
- preferredName = names.fromString("encl$" + transMap.size());
- break;
- case CAPTURED_VAR:
- preferredName = names.fromString("cap$" + transMap.size());
- break;
- case LOCAL_VAR:
- preferredName = sym.name;
- break;
- case PARAM:
- preferredName = sym.name;
- break;
- case TYPE_VAR:
- preferredName = sym.name;
- break;
- default: throw new AssertionError();
- }
if (!transMap.containsKey(sym)) {
- transMap.put(sym, translate(preferredName, sym, skind));
+ transMap.put(sym, translate(sym, skind));
}
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -194,7 +194,7 @@
void reportVerboseResolutionDiagnostic(DiagnosticPosition dpos, Name name, Type site,
List<Type> argtypes, List<Type> typeargtypes, Symbol bestSoFar) {
- boolean success = !bestSoFar.kind.isOverloadError();
+ boolean success = !bestSoFar.kind.isResolutionError();
if (success && !verboseResolutionMode.contains(VerboseResolutionMode.SUCCESS)) {
return;
@@ -1389,7 +1389,7 @@
if (currentSymbol.kind != VAR)
continue;
// invariant: sym.kind == Symbol.Kind.VAR
- if (!bestSoFar.kind.isOverloadError() &&
+ if (!bestSoFar.kind.isResolutionError() &&
currentSymbol.owner != bestSoFar.owner)
return new AmbiguityError(bestSoFar, currentSymbol);
else if (!bestSoFar.kind.betterThan(VAR)) {
@@ -1432,11 +1432,11 @@
!sym.isInheritedIn(site.tsym, types)) {
return bestSoFar;
} else if (useVarargs && (sym.flags() & VARARGS) == 0) {
- return bestSoFar.kind.isOverloadError() ?
+ return bestSoFar.kind.isResolutionError() ?
new BadVarargsMethod((ResolveError)bestSoFar.baseSymbol()) :
bestSoFar;
}
- Assert.check(!sym.kind.isOverloadError());
+ Assert.check(!sym.kind.isResolutionError());
try {
Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
allowBoxing, useVarargs, types.noWarnings);
@@ -1457,7 +1457,7 @@
? new AccessError(env, site, sym)
: bestSoFar;
}
- return (bestSoFar.kind.isOverloadError() && bestSoFar.kind != AMBIGUOUS)
+ return (bestSoFar.kind.isResolutionError() && bestSoFar.kind != AMBIGUOUS)
? sym
: mostSpecific(argtypes, sym, bestSoFar, env, site, useVarargs);
}
@@ -1939,8 +1939,8 @@
bestSoFar.kind != AMBIGUOUS && l.nonEmpty();
l = l.tail) {
sym = findMemberType(env, site, name, l.head.tsym);
- if (!bestSoFar.kind.isOverloadError() &&
- !sym.kind.isOverloadError() &&
+ if (!bestSoFar.kind.isResolutionError() &&
+ !sym.kind.isResolutionError() &&
sym.owner != bestSoFar.owner)
bestSoFar = new AmbiguityError(bestSoFar, sym);
else
@@ -2176,7 +2176,7 @@
List<Type> argtypes,
List<Type> typeargtypes,
LogResolveHelper logResolveHelper) {
- if (sym.kind.isOverloadError()) {
+ if (sym.kind.isResolutionError()) {
ResolveError errSym = (ResolveError)sym.baseSymbol();
sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol);
argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes);
@@ -2366,7 +2366,7 @@
}
@Override
Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
- if (sym.kind.isOverloadError()) {
+ if (sym.kind.isResolutionError()) {
sym = super.access(env, pos, location, sym);
} else if (allowMethodHandles) {
MethodSymbol msym = (MethodSymbol)sym;
@@ -2523,7 +2523,7 @@
}
@Override
Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
- if (sym.kind.isOverloadError()) {
+ if (sym.kind.isResolutionError()) {
if (sym.kind != WRONG_MTH &&
sym.kind != WRONG_MTHS) {
sym = super.access(env, pos, location, sym);
@@ -2555,7 +2555,8 @@
boolean allowBoxing,
boolean useVarargs) {
Symbol bestSoFar = methodNotFound;
- for (final Symbol sym : site.tsym.members().getSymbolsByName(names.init)) {
+ TypeSymbol tsym = site.tsym.isInterface() ? syms.objectType.tsym : site.tsym;
+ for (final Symbol sym : tsym.members().getSymbolsByName(names.init)) {
//- System.out.println(" e " + e.sym);
if (sym.kind == MTH &&
(sym.flags_field & SYNTHETIC) == 0) {
@@ -2933,7 +2934,7 @@
*/
final boolean shouldStop(Symbol sym, MethodResolutionPhase phase) {
return phase.ordinal() > maxPhase.ordinal() ||
- !sym.kind.isOverloadError() || sym.kind == AMBIGUOUS;
+ !sym.kind.isResolutionError() || sym.kind == AMBIGUOUS;
}
/**
@@ -2979,7 +2980,7 @@
@Override
Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
- if (sym.kind.isOverloadError()) {
+ if (sym.kind.isResolutionError()) {
//if nothing is found return the 'first' error
sym = accessMethod(sym, pos, location, site, name, true, argtypes, typeargtypes);
}
@@ -3321,7 +3322,7 @@
boolean hasEnclosingInstance(Env<AttrContext> env, Type type) {
Symbol encl = resolveSelfContainingInternal(env, type.tsym, false);
- return encl != null && !encl.kind.isOverloadError();
+ return encl != null && !encl.kind.isResolutionError();
}
private Symbol resolveSelfContainingInternal(Env<AttrContext> env,
@@ -3503,7 +3504,7 @@
@Override
public Symbol access(Name name, TypeSymbol location) {
- if (!sym.kind.isOverloadError() && sym.kind.matches(KindSelector.TYP))
+ if (!sym.kind.isResolutionError() && sym.kind.matches(KindSelector.TYP))
return types.createErrorType(name, location, sym.type).tsym;
else
return sym;
@@ -4053,7 +4054,7 @@
} else {
key = "bad.instance.method.in.unbound.lookup";
}
- return sym.kind.isOverloadError() ?
+ return sym.kind.isResolutionError() ?
((ResolveError)sym).getDiagnostic(dkind, pos, location, site, name, argtypes, typeargtypes) :
diags.create(dkind, log.currentSource(), pos, key, Kinds.kindName(sym), sym);
}
@@ -4232,8 +4233,8 @@
@Override
public Symbol mergeResults(Symbol bestSoFar, Symbol sym) {
//Check invariants (see {@code LookupHelper.shouldStop})
- Assert.check(bestSoFar.kind.isOverloadError() && bestSoFar.kind != AMBIGUOUS);
- if (!sym.kind.isOverloadError()) {
+ Assert.check(bestSoFar.kind.isResolutionError() && bestSoFar.kind != AMBIGUOUS);
+ if (!sym.kind.isResolutionError()) {
//varargs resolution successful
return sym;
} else {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.file;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.lang.ref.SoftReference;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.CodingErrorAction;
+import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.UnsupportedCharsetException;
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
+
+import com.sun.tools.javac.code.Lint;
+import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.file.FSInfo;
+import com.sun.tools.javac.file.Locations;
+import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.main.OptionHelper;
+import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
+import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Options;
+
+/**
+ * Utility methods for building a filemanager.
+ * There are no references here to file-system specific objects such as
+ * java.io.File or java.nio.file.Path.
+ */
+public abstract class BaseFileManager implements JavaFileManager {
+ protected BaseFileManager(Charset charset) {
+ this.charset = charset;
+ byteBufferCache = new ByteBufferCache();
+ locations = createLocations();
+ }
+
+ /**
+ * Set the context for JavacPathFileManager.
+ * @param context the context containing items to be associated with the file manager
+ */
+ public void setContext(Context context) {
+ log = Log.instance(context);
+ options = Options.instance(context);
+ classLoaderClass = options.get("procloader");
+ locations.update(log, Lint.instance(context), FSInfo.instance(context));
+ }
+
+ protected Locations createLocations() {
+ return new Locations();
+ }
+
+ /**
+ * The log to be used for error reporting.
+ */
+ public Log log;
+
+ /**
+ * User provided charset (through javax.tools).
+ */
+ protected Charset charset;
+
+ protected Options options;
+
+ protected String classLoaderClass;
+
+ protected Locations locations;
+
+ /**
+ * A flag for clients to use to indicate that this file manager should
+ * be closed when it is no longer required.
+ */
+ public boolean autoClose;
+
+ protected Source getSource() {
+ String sourceName = options.get(Option.SOURCE);
+ Source source = null;
+ if (sourceName != null)
+ source = Source.lookup(sourceName);
+ return (source != null ? source : Source.DEFAULT);
+ }
+
+ protected ClassLoader getClassLoader(URL[] urls) {
+ ClassLoader thisClassLoader = getClass().getClassLoader();
+
+ // Allow the following to specify a closeable classloader
+ // other than URLClassLoader.
+
+ // 1: Allow client to specify the class to use via hidden option
+ if (classLoaderClass != null) {
+ try {
+ Class<? extends ClassLoader> loader =
+ Class.forName(classLoaderClass).asSubclass(ClassLoader.class);
+ Class<?>[] constrArgTypes = { URL[].class, ClassLoader.class };
+ Constructor<? extends ClassLoader> constr = loader.getConstructor(constrArgTypes);
+ return constr.newInstance(urls, thisClassLoader);
+ } catch (ReflectiveOperationException t) {
+ // ignore errors loading user-provided class loader, fall through
+ }
+ }
+ return new URLClassLoader(urls, thisClassLoader);
+ }
+
+ public boolean isDefaultBootClassPath() {
+ return locations.isDefaultBootClassPath();
+ }
+
+ // <editor-fold defaultstate="collapsed" desc="Option handling">
+ @Override @DefinedBy(Api.COMPILER)
+ public boolean handleOption(String current, Iterator<String> remaining) {
+ OptionHelper helper = new GrumpyHelper(log) {
+ @Override
+ public String get(Option option) {
+ return options.get(option.getText());
+ }
+
+ @Override
+ public void put(String name, String value) {
+ options.put(name, value);
+ }
+
+ @Override
+ public void remove(String name) {
+ options.remove(name);
+ }
+
+ @Override
+ public boolean handleFileManagerOption(Option option, String value) {
+ return handleOption(option, value);
+ }
+ };
+
+ for (Option o: javacFileManagerOptions) {
+ if (o.matches(current)) {
+ if (o.hasArg()) {
+ if (remaining.hasNext()) {
+ if (!o.process(helper, current, remaining.next()))
+ return true;
+ }
+ } else {
+ if (!o.process(helper, current))
+ return true;
+ }
+ // operand missing, or process returned true
+ throw new IllegalArgumentException(current);
+ }
+ }
+
+ return false;
+ }
+ // where
+ private static final Set<Option> javacFileManagerOptions =
+ Option.getJavacFileManagerOptions();
+
+ @Override @DefinedBy(Api.COMPILER)
+ public int isSupportedOption(String option) {
+ for (Option o : javacFileManagerOptions) {
+ if (o.matches(option))
+ return o.hasArg() ? 1 : 0;
+ }
+ return -1;
+ }
+
+ /**
+ * Common back end for OptionHelper handleFileManagerOption.
+ * @param option the option whose value to be set
+ * @param value the value for the option
+ * @return true if successful, and false otherwise
+ */
+ public boolean handleOption(Option option, String value) {
+ return locations.handleOption(option, value);
+ }
+
+ /**
+ * Call handleOption for collection of options and corresponding values.
+ * @param map a collection of options and corresponding values
+ * @return true if all the calls are successful
+ */
+ public boolean handleOptions(Map<Option, String> map) {
+ boolean ok = true;
+ for (Map.Entry<Option, String> e: map.entrySet())
+ ok = ok & handleOption(e.getKey(), e.getValue());
+ return ok;
+ }
+
+ // </editor-fold>
+
+ // <editor-fold defaultstate="collapsed" desc="Encoding">
+ private String defaultEncodingName;
+ private String getDefaultEncodingName() {
+ if (defaultEncodingName == null) {
+ defaultEncodingName =
+ new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding();
+ }
+ return defaultEncodingName;
+ }
+
+ public String getEncodingName() {
+ String encName = options.get(Option.ENCODING);
+ if (encName == null)
+ return getDefaultEncodingName();
+ else
+ return encName;
+ }
+
+ @SuppressWarnings("cast")
+ public CharBuffer decode(ByteBuffer inbuf, boolean ignoreEncodingErrors) {
+ String encodingName = getEncodingName();
+ CharsetDecoder decoder;
+ try {
+ decoder = getDecoder(encodingName, ignoreEncodingErrors);
+ } catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
+ log.error("unsupported.encoding", encodingName);
+ return (CharBuffer)CharBuffer.allocate(1).flip();
+ }
+
+ // slightly overestimate the buffer size to avoid reallocation.
+ float factor =
+ decoder.averageCharsPerByte() * 0.8f +
+ decoder.maxCharsPerByte() * 0.2f;
+ CharBuffer dest = CharBuffer.
+ allocate(10 + (int)(inbuf.remaining()*factor));
+
+ while (true) {
+ CoderResult result = decoder.decode(inbuf, dest, true);
+ dest.flip();
+
+ if (result.isUnderflow()) { // done reading
+ // make sure there is at least one extra character
+ if (dest.limit() == dest.capacity()) {
+ dest = CharBuffer.allocate(dest.capacity()+1).put(dest);
+ dest.flip();
+ }
+ return dest;
+ } else if (result.isOverflow()) { // buffer too small; expand
+ int newCapacity =
+ 10 + dest.capacity() +
+ (int)(inbuf.remaining()*decoder.maxCharsPerByte());
+ dest = CharBuffer.allocate(newCapacity).put(dest);
+ } else if (result.isMalformed() || result.isUnmappable()) {
+ // bad character in input
+
+ log.error(new SimpleDiagnosticPosition(dest.limit()),
+ "illegal.char.for.encoding",
+ charset == null ? encodingName : charset.name());
+
+ // skip past the coding error
+ inbuf.position(inbuf.position() + result.length());
+
+ // undo the flip() to prepare the output buffer
+ // for more translation
+ dest.position(dest.limit());
+ dest.limit(dest.capacity());
+ dest.put((char)0xfffd); // backward compatible
+ } else {
+ throw new AssertionError(result);
+ }
+ }
+ // unreached
+ }
+
+ public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) {
+ Charset cs = (this.charset == null)
+ ? Charset.forName(encodingName)
+ : this.charset;
+ CharsetDecoder decoder = cs.newDecoder();
+
+ CodingErrorAction action;
+ if (ignoreEncodingErrors)
+ action = CodingErrorAction.REPLACE;
+ else
+ action = CodingErrorAction.REPORT;
+
+ return decoder
+ .onMalformedInput(action)
+ .onUnmappableCharacter(action);
+ }
+ // </editor-fold>
+
+ // <editor-fold defaultstate="collapsed" desc="ByteBuffers">
+ /**
+ * Make a byte buffer from an input stream.
+ * @param in the stream
+ * @return a byte buffer containing the contents of the stream
+ * @throws IOException if an error occurred while reading the stream
+ */
+ @SuppressWarnings("cast")
+ public ByteBuffer makeByteBuffer(InputStream in)
+ throws IOException {
+ int limit = in.available();
+ if (limit < 1024) limit = 1024;
+ ByteBuffer result = byteBufferCache.get(limit);
+ int position = 0;
+ while (in.available() != 0) {
+ if (position >= limit)
+ // expand buffer
+ result = ByteBuffer.
+ allocate(limit <<= 1).
+ put((ByteBuffer)result.flip());
+ int count = in.read(result.array(),
+ position,
+ limit - position);
+ if (count < 0) break;
+ result.position(position += count);
+ }
+ return (ByteBuffer)result.flip();
+ }
+
+ public void recycleByteBuffer(ByteBuffer bb) {
+ byteBufferCache.put(bb);
+ }
+
+ /**
+ * A single-element cache of direct byte buffers.
+ */
+ @SuppressWarnings("cast")
+ private static class ByteBufferCache {
+ private ByteBuffer cached;
+ ByteBuffer get(int capacity) {
+ if (capacity < 20480) capacity = 20480;
+ ByteBuffer result =
+ (cached != null && cached.capacity() >= capacity)
+ ? (ByteBuffer)cached.clear()
+ : ByteBuffer.allocate(capacity + capacity>>1);
+ cached = null;
+ return result;
+ }
+ void put(ByteBuffer x) {
+ cached = x;
+ }
+ }
+
+ private final ByteBufferCache byteBufferCache;
+ // </editor-fold>
+
+ // <editor-fold defaultstate="collapsed" desc="Content cache">
+ public CharBuffer getCachedContent(JavaFileObject file) {
+ ContentCacheEntry e = contentCache.get(file);
+ if (e == null)
+ return null;
+
+ if (!e.isValid(file)) {
+ contentCache.remove(file);
+ return null;
+ }
+
+ return e.getValue();
+ }
+
+ public void cache(JavaFileObject file, CharBuffer cb) {
+ contentCache.put(file, new ContentCacheEntry(file, cb));
+ }
+
+ public void flushCache(JavaFileObject file) {
+ contentCache.remove(file);
+ }
+
+ protected final Map<JavaFileObject, ContentCacheEntry> contentCache = new HashMap<>();
+
+ protected static class ContentCacheEntry {
+ final long timestamp;
+ final SoftReference<CharBuffer> ref;
+
+ ContentCacheEntry(JavaFileObject file, CharBuffer cb) {
+ this.timestamp = file.getLastModified();
+ this.ref = new SoftReference<>(cb);
+ }
+
+ boolean isValid(JavaFileObject file) {
+ return timestamp == file.getLastModified();
+ }
+
+ CharBuffer getValue() {
+ return ref.get();
+ }
+ }
+ // </editor-fold>
+
+ public static Kind getKind(Path path) {
+ return getKind(path.getFileName().toString());
+ }
+
+ public static Kind getKind(String name) {
+ if (name.endsWith(Kind.CLASS.extension))
+ return Kind.CLASS;
+ else if (name.endsWith(Kind.SOURCE.extension))
+ return Kind.SOURCE;
+ else if (name.endsWith(Kind.HTML.extension))
+ return Kind.HTML;
+ else
+ return Kind.OTHER;
+ }
+
+ protected static <T> T nullCheck(T o) {
+ return Objects.requireNonNull(o);
+ }
+
+ protected static <T> Collection<T> nullCheck(Collection<T> it) {
+ for (T t : it)
+ Objects.requireNonNull(t);
+ return it;
+ }
+}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileObject.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileObject.java Wed Apr 08 14:32:21 2015 -0700
@@ -38,7 +38,6 @@
import javax.tools.FileObject;
import javax.tools.JavaFileObject;
-import com.sun.tools.javac.util.BaseFileManager;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JRTIndex.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JRTIndex.java Wed Apr 08 14:32:21 2015 -0700
@@ -48,7 +48,6 @@
import javax.tools.FileObject;
import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
-import com.sun.tools.javac.nio.PathFileObject;
import com.sun.tools.javac.util.Context;
/**
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Wed Apr 08 14:32:21 2015 -0700
@@ -63,8 +63,6 @@
import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
import com.sun.tools.javac.file.RelativePath.RelativeFile;
-import com.sun.tools.javac.nio.PathFileObject;
-import com.sun.tools.javac.util.BaseFileManager;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
@@ -73,8 +71,6 @@
import static javax.tools.StandardLocation.*;
-import static com.sun.tools.javac.util.BaseFileManager.getKind;
-
/**
* This class provides access to the source, class and other files
* used by the compiler and related tools.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Wed Apr 08 14:32:21 2015 -0700
@@ -108,37 +108,23 @@
// Locations can use Paths.get(URI.create("jrt:"))
static final Path JRT_MARKER_FILE = Paths.get("JRT_MARKER_FILE");
- public Locations() {
+ Locations() {
initHandlers();
}
// could replace Lint by "boolean warn"
- public void update(Log log, Lint lint, FSInfo fsInfo) {
+ void update(Log log, Lint lint, FSInfo fsInfo) {
this.log = log;
warn = lint.isEnabled(Lint.LintCategory.PATH);
this.fsInfo = fsInfo;
}
- public Collection<Path> bootClassPath() {
- return getLocation(PLATFORM_CLASS_PATH);
- }
-
- public boolean isDefaultBootClassPath() {
+ boolean isDefaultBootClassPath() {
BootClassPathLocationHandler h
= (BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH);
return h.isDefault();
}
- public Collection<Path> userClassPath() {
- return getLocation(CLASS_PATH);
- }
-
- public Collection<Path> sourcePath() {
- Collection<Path> p = getLocation(SOURCE_PATH);
- // TODO: this should be handled by the LocationHandler
- return p == null || p.isEmpty() ? null : p;
- }
-
/**
* Split a search path into its elements. Empty path elements will be ignored.
*
@@ -753,7 +739,7 @@
}
}
- public boolean handleOption(Option option, String value) {
+ boolean handleOption(Option option, String value) {
LocationHandler h = handlersForOption.get(option);
return (h == null ? false : h.handleOption(option, value));
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,331 @@
+/*
+ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.file;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URI;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.CharsetDecoder;
+import java.nio.file.Files;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.util.Objects;
+
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.NestingKind;
+import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
+
+
+/**
+ * Implementation of JavaFileObject using java.nio.file API.
+ *
+ * <p>PathFileObjects are, for the most part, straightforward wrappers around
+ * Path objects. The primary complexity is the support for "inferBinaryName".
+ * This is left as an abstract method, implemented by each of a number of
+ * different factory methods, which compute the binary name based on
+ * information available at the time the file object is created.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+public abstract class PathFileObject implements JavaFileObject {
+ private final BaseFileManager fileManager;
+ private final Path path;
+
+ /**
+ * Create a PathFileObject within a directory, such that the binary name
+ * can be inferred from the relationship to the parent directory.
+ */
+ static PathFileObject createDirectoryPathFileObject(BaseFileManager fileManager,
+ final Path path, final Path dir) {
+ return new PathFileObject(fileManager, path) {
+ @Override
+ public String inferBinaryName(Iterable<? extends Path> paths) {
+ return toBinaryName(dir.relativize(path));
+ }
+ };
+ }
+
+ /**
+ * Create a PathFileObject in a file system such as a jar file, such that
+ * the binary name can be inferred from its position within the filesystem.
+ */
+ public static PathFileObject createJarPathFileObject(BaseFileManager fileManager,
+ final Path path) {
+ return new PathFileObject(fileManager, path) {
+ @Override
+ public String inferBinaryName(Iterable<? extends Path> paths) {
+ return toBinaryName(path);
+ }
+ };
+ }
+
+ /**
+ * Create a PathFileObject in a modular file system, such as jrt:, such that
+ * the binary name can be inferred from its position within the filesystem.
+ */
+ public static PathFileObject createJRTPathFileObject(BaseFileManager fileManager,
+ final Path path) {
+ return new PathFileObject(fileManager, path) {
+ @Override
+ public String inferBinaryName(Iterable<? extends Path> paths) {
+ // use subpath to ignore the leading component containing the module name
+ return toBinaryName(path.subpath(1, path.getNameCount()));
+ }
+ };
+ }
+
+ /**
+ * Create a PathFileObject whose binary name can be inferred from the
+ * relative path to a sibling.
+ */
+ static PathFileObject createSiblingPathFileObject(BaseFileManager fileManager,
+ final Path path, final String relativePath) {
+ return new PathFileObject(fileManager, path) {
+ @Override
+ public String inferBinaryName(Iterable<? extends Path> paths) {
+ return toBinaryName(relativePath, "/");
+ }
+ };
+ }
+
+ /**
+ * Create a PathFileObject whose binary name might be inferred from its
+ * position on a search path.
+ */
+ static PathFileObject createSimplePathFileObject(BaseFileManager fileManager,
+ final Path path) {
+ return new PathFileObject(fileManager, path) {
+ @Override
+ public String inferBinaryName(Iterable<? extends Path> paths) {
+ Path absPath = path.toAbsolutePath();
+ for (Path p: paths) {
+ Path ap = p.toAbsolutePath();
+ if (absPath.startsWith(ap)) {
+ try {
+ Path rp = ap.relativize(absPath);
+ if (rp != null) // maybe null if absPath same as ap
+ return toBinaryName(rp);
+ } catch (IllegalArgumentException e) {
+ // ignore this p if cannot relativize path to p
+ }
+ }
+ }
+ return null;
+ }
+ };
+ }
+
+ protected PathFileObject(BaseFileManager fileManager, Path path) {
+ this.fileManager = Objects.requireNonNull(fileManager);
+ this.path = Objects.requireNonNull(path);
+ }
+
+ public abstract String inferBinaryName(Iterable<? extends Path> paths);
+
+ /**
+ * Return the Path for this object.
+ * @return the Path for this object.
+ */
+ public Path getPath() {
+ return path;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public Kind getKind() {
+ return BaseFileManager.getKind(path.getFileName().toString());
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public boolean isNameCompatible(String simpleName, Kind kind) {
+ Objects.requireNonNull(simpleName);
+ // null check
+ if (kind == Kind.OTHER && getKind() != kind) {
+ return false;
+ }
+ String sn = simpleName + kind.extension;
+ String pn = path.getFileName().toString();
+ if (pn.equals(sn)) {
+ return true;
+ }
+ if (pn.equalsIgnoreCase(sn)) {
+ try {
+ // allow for Windows
+ return path.toRealPath(LinkOption.NOFOLLOW_LINKS).getFileName().toString().equals(sn);
+ } catch (IOException e) {
+ }
+ }
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public NestingKind getNestingKind() {
+ return null;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public Modifier getAccessLevel() {
+ return null;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public URI toUri() {
+ return path.toUri();
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public String getName() {
+ return path.toString();
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public InputStream openInputStream() throws IOException {
+ return Files.newInputStream(path);
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public OutputStream openOutputStream() throws IOException {
+ fileManager.flushCache(this);
+ ensureParentDirectoriesExist();
+ return Files.newOutputStream(path);
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
+ CharsetDecoder decoder = fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
+ return new InputStreamReader(openInputStream(), decoder);
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+ CharBuffer cb = fileManager.getCachedContent(this);
+ if (cb == null) {
+ try (InputStream in = openInputStream()) {
+ ByteBuffer bb = fileManager.makeByteBuffer(in);
+ JavaFileObject prev = fileManager.log.useSource(this);
+ try {
+ cb = fileManager.decode(bb, ignoreEncodingErrors);
+ } finally {
+ fileManager.log.useSource(prev);
+ }
+ fileManager.recycleByteBuffer(bb);
+ if (!ignoreEncodingErrors) {
+ fileManager.cache(this, cb);
+ }
+ }
+ }
+ return cb;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public Writer openWriter() throws IOException {
+ fileManager.flushCache(this);
+ ensureParentDirectoriesExist();
+ return new OutputStreamWriter(Files.newOutputStream(path), fileManager.getEncodingName());
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public long getLastModified() {
+ try {
+ return Files.getLastModifiedTime(path).toMillis();
+ } catch (IOException e) {
+ return -1;
+ }
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public boolean delete() {
+ try {
+ Files.delete(path);
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+ }
+
+ public boolean isSameFile(PathFileObject other) {
+ try {
+ return Files.isSameFile(path, other.path);
+ } catch (IOException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ return (other instanceof PathFileObject && path.equals(((PathFileObject) other).path));
+ }
+
+ @Override
+ public int hashCode() {
+ return path.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "[" + path + "]";
+ }
+
+ private void ensureParentDirectoriesExist() throws IOException {
+ Path parent = path.getParent();
+ if (parent != null)
+ Files.createDirectories(parent);
+ }
+
+ private long size() {
+ try {
+ return Files.size(path);
+ } catch (IOException e) {
+ return -1;
+ }
+ }
+
+ protected static String toBinaryName(Path relativePath) {
+ return toBinaryName(relativePath.toString(),
+ relativePath.getFileSystem().getSeparator());
+ }
+
+ protected static String toBinaryName(String relativePath, String sep) {
+ return removeExtension(relativePath).replace(sep, ".");
+ }
+
+ protected static String removeExtension(String fileName) {
+ int lastDot = fileName.lastIndexOf(".");
+ return (lastDot == -1 ? fileName : fileName.substring(0, lastDot));
+ }
+}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java Wed Apr 08 14:32:21 2015 -0700
@@ -497,13 +497,9 @@
case aaload: {
state.pop(1);// index
Type a = state.stack[state.stacksize-1];
+ Assert.check(!a.hasTag(BOT)); // null type as is cannot be indexed.
state.pop(1);
- //sometimes 'null type' is treated as a one-dimensional array type
- //see Gen.visitLiteral - we should handle this case accordingly
- Type stackType = a.hasTag(BOT) ?
- syms.objectType :
- types.erasure(types.elemtype(a));
- state.push(stackType); }
+ state.push(types.erasure(types.elemtype(a))); }
break;
case goto_:
markDead();
@@ -2166,7 +2162,11 @@
boolean keepLocalVariables = varDebugInfo ||
(var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations());
if (!keepLocalVariables) return;
- if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return;
+ //don't keep synthetic vars, unless they are lambda method parameters
+ boolean ignoredSyntheticVar = (var.sym.flags() & Flags.SYNTHETIC) != 0 &&
+ ((var.sym.owner.flags() & Flags.LAMBDA_METHOD) == 0 ||
+ (var.sym.flags() & Flags.PARAMETER) == 0);
+ if (ignoredSyntheticVar) return;
if (varBuffer == null)
varBuffer = new LocalVar[20];
else
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Apr 08 14:32:21 2015 -0700
@@ -1860,6 +1860,13 @@
public void visitAssign(JCAssign tree) {
Item l = genExpr(tree.lhs, tree.lhs.type);
genExpr(tree.rhs, tree.lhs.type).load();
+ if (tree.rhs.type.hasTag(BOT)) {
+ /* This is just a case of widening reference conversion that per 5.1.5 simply calls
+ for "regarding a reference as having some other type in a manner that can be proved
+ correct at compile time."
+ */
+ code.state.forceStackTop(tree.lhs.type);
+ }
result = items.makeAssignItem(l);
}
@@ -2272,12 +2279,7 @@
public void visitLiteral(JCLiteral tree) {
if (tree.type.hasTag(BOT)) {
code.emitop0(aconst_null);
- if (types.dimensions(pt) > 1) {
- code.emitop2(checkcast, makeRef(tree.pos(), pt));
- result = items.makeStackItem(pt);
- } else {
- result = items.makeStackItem(tree.type);
- }
+ result = items.makeStackItem(tree.type);
}
else
result = items.makeImmediateItem(tree.type, tree.value);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java Wed Apr 08 14:32:21 2015 -0700
@@ -42,7 +42,7 @@
import com.sun.tools.javac.jvm.Profile;
import com.sun.tools.javac.jvm.Target;
import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
-import com.sun.tools.javac.util.BaseFileManager;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java Wed Apr 08 14:32:21 2015 -0700
@@ -39,6 +39,7 @@
import com.sun.tools.javac.api.BasicJavacTask;
import com.sun.tools.javac.file.CacheFSInfo;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.processing.AnnotationProcessingError;
import com.sun.tools.javac.util.*;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Wed Apr 08 13:12:52 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,547 +0,0 @@
-/*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.nio;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.FileVisitOption;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.lang.model.SourceVersion;
-import javax.tools.FileObject;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.JavaFileObject.Kind;
-import javax.tools.StandardLocation;
-
-import com.sun.tools.javac.util.BaseFileManager;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.DefinedBy;
-import com.sun.tools.javac.util.DefinedBy.Api;
-import com.sun.tools.javac.util.List;
-import com.sun.tools.javac.util.ListBuffer;
-
-import static java.nio.file.FileVisitOption.*;
-
-import static javax.tools.StandardLocation.*;
-
-import static com.sun.tools.javac.main.Option.*;
-
-
-// NOTE the imports carefully for this compilation unit.
-//
-// Path: java.nio.file.Path -- the new NIO type for which this file manager exists
-//
-// Paths: com.sun.tools.javac.file.Paths -- legacy javac type for handling path options
-// The other Paths (java.nio.file.Paths) is not used
-
-// NOTE this and related classes depend on new API in JDK 7.
-// This requires special handling while bootstrapping the JDK build,
-// when these classes might not yet have been compiled. To workaround
-// this, the build arranges to make stubs of these classes available
-// when compiling this and related classes. The set of stub files
-// is specified in make/build.properties.
-
-/**
- * Implementation of PathFileManager: a JavaFileManager based on the use
- * of java.nio.file.Path.
- *
- * <p>Just as a Path is somewhat analagous to a File, so too is this
- * JavacPathFileManager analogous to JavacFileManager, as it relates to the
- * support of FileObjects based on File objects (i.e. just RegularFileObject,
- * not ZipFileObject and its variants.)
- *
- * <p>The default values for the standard locations supported by this file
- * manager are the same as the default values provided by JavacFileManager --
- * i.e. as determined by the javac.file.Paths class. To override these values,
- * call {@link #setLocation}.
- *
- * <p>To reduce confusion with Path objects, the locations such as "class path",
- * "source path", etc, are generically referred to here as "search paths".
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.</b>
- */
-public class JavacPathFileManager extends BaseFileManager implements PathFileManager {
- protected FileSystem defaultFileSystem;
-
- /**
- * Create a JavacPathFileManager using a given context, optionally registering
- * it as the JavaFileManager for that context.
- */
- public JavacPathFileManager(Context context, boolean register, Charset charset) {
- super(charset);
- if (register)
- context.put(JavaFileManager.class, this);
- pathsForLocation = new HashMap<>();
- fileSystems = new HashMap<>();
- setContext(context);
- }
-
- /**
- * Set the context for JavacPathFileManager.
- */
- @Override
- public void setContext(Context context) {
- super.setContext(context);
- }
-
- @Override
- public FileSystem getDefaultFileSystem() {
- if (defaultFileSystem == null)
- defaultFileSystem = FileSystems.getDefault();
- return defaultFileSystem;
- }
-
- @Override
- public void setDefaultFileSystem(FileSystem fs) {
- defaultFileSystem = fs;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public void flush() throws IOException {
- contentCache.clear();
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public void close() throws IOException {
- for (FileSystem fs: fileSystems.values())
- fs.close();
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public ClassLoader getClassLoader(Location location) {
- nullCheck(location);
- Iterable<? extends Path> path = getLocation(location);
- if (path == null)
- return null;
- ListBuffer<URL> lb = new ListBuffer<>();
- for (Path p: path) {
- try {
- lb.append(p.toUri().toURL());
- } catch (MalformedURLException e) {
- throw new AssertionError(e);
- }
- }
-
- return getClassLoader(lb.toArray(new URL[lb.size()]));
- }
-
- // <editor-fold defaultstate="collapsed" desc="Location handling">
-
- @DefinedBy(Api.COMPILER)
- public boolean hasLocation(Location location) {
- return (getLocation(location) != null);
- }
-
- public Iterable<? extends Path> getLocation(Location location) {
- nullCheck(location);
- lazyInitSearchPaths();
- PathsForLocation path = pathsForLocation.get(location);
- if (path == null && !pathsForLocation.containsKey(location)) {
- setDefaultForLocation(location);
- path = pathsForLocation.get(location);
- }
- return path;
- }
-
- private Path getOutputLocation(Location location) {
- Iterable<? extends Path> paths = getLocation(location);
- return (paths == null ? null : paths.iterator().next());
- }
-
- public void setLocation(Location location, Iterable<? extends Path> searchPath)
- throws IOException
- {
- nullCheck(location);
- lazyInitSearchPaths();
- if (searchPath == null) {
- setDefaultForLocation(location);
- } else {
- if (location.isOutputLocation())
- checkOutputPath(searchPath);
- PathsForLocation pl = new PathsForLocation();
- for (Path p: searchPath)
- pl.add(p); // TODO -Xlint:path warn if path not found
- pathsForLocation.put(location, pl);
- }
- }
-
- private void checkOutputPath(Iterable<? extends Path> searchPath) throws IOException {
- Iterator<? extends Path> pathIter = searchPath.iterator();
- if (!pathIter.hasNext())
- throw new IllegalArgumentException("empty path for directory");
- Path path = pathIter.next();
- if (pathIter.hasNext())
- throw new IllegalArgumentException("path too long for directory");
- if (!isDirectory(path))
- throw new IOException(path + ": not a directory");
- }
-
- private void setDefaultForLocation(Location locn) {
- Collection<Path> files = null;
- if (locn instanceof StandardLocation) {
- switch ((StandardLocation) locn) {
- case CLASS_PATH:
- files = locations.userClassPath();
- break;
- case PLATFORM_CLASS_PATH:
- files = locations.bootClassPath();
- break;
- case SOURCE_PATH:
- files = locations.sourcePath();
- break;
- case CLASS_OUTPUT: {
- String arg = options.get(D);
- files = (arg == null ? null : Collections.singleton(Paths.get(arg)));
- break;
- }
- case SOURCE_OUTPUT: {
- String arg = options.get(S);
- files = (arg == null ? null : Collections.singleton(Paths.get(arg)));
- break;
- }
- }
- }
-
- PathsForLocation pl = new PathsForLocation();
- if (files != null) {
- for (Path f: files)
- pl.add(f);
- }
- if (!pl.isEmpty())
- pathsForLocation.put(locn, pl);
- }
-
- private void lazyInitSearchPaths() {
- if (!inited) {
- setDefaultForLocation(PLATFORM_CLASS_PATH);
- setDefaultForLocation(CLASS_PATH);
- setDefaultForLocation(SOURCE_PATH);
- inited = true;
- }
- }
- // where
- private boolean inited = false;
-
- private Map<Location, PathsForLocation> pathsForLocation;
-
- private static class PathsForLocation extends LinkedHashSet<Path> {
- private static final long serialVersionUID = 6788510222394486733L;
- }
-
- // </editor-fold>
-
- // <editor-fold defaultstate="collapsed" desc="FileObject handling">
-
- @Override
- public Path getPath(FileObject fo) {
- nullCheck(fo);
- if (!(fo instanceof PathFileObject))
- throw new IllegalArgumentException();
- return ((PathFileObject) fo).getPath();
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public boolean isSameFile(FileObject a, FileObject b) {
- nullCheck(a);
- nullCheck(b);
- if (!(a instanceof PathFileObject))
- throw new IllegalArgumentException("Not supported: " + a);
- if (!(b instanceof PathFileObject))
- throw new IllegalArgumentException("Not supported: " + b);
- return ((PathFileObject) a).isSameFile((PathFileObject) b);
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public Iterable<JavaFileObject> list(Location location,
- String packageName, Set<Kind> kinds, boolean recurse)
- throws IOException {
- // validatePackageName(packageName);
- nullCheck(packageName);
- nullCheck(kinds);
-
- Iterable<? extends Path> paths = getLocation(location);
- if (paths == null)
- return List.nil();
- ListBuffer<JavaFileObject> results = new ListBuffer<>();
-
- for (Path path : paths)
- list(path, packageName, kinds, recurse, results);
-
- return results.toList();
- }
-
- private void list(Path path, String packageName, final Set<Kind> kinds,
- boolean recurse, final ListBuffer<JavaFileObject> results)
- throws IOException {
- if (!Files.exists(path))
- return;
-
- final Path pathDir;
- if (isDirectory(path))
- pathDir = path;
- else {
- FileSystem fs = getFileSystem(path);
- if (fs == null)
- return;
- pathDir = fs.getRootDirectories().iterator().next();
- }
- String sep = path.getFileSystem().getSeparator();
- Path packageDir = packageName.isEmpty() ? pathDir
- : pathDir.resolve(packageName.replace(".", sep));
- if (!Files.exists(packageDir))
- return;
-
-/* Alternate impl of list, superceded by use of Files.walkFileTree */
-// Deque<Path> queue = new LinkedList<Path>();
-// queue.add(packageDir);
-//
-// Path dir;
-// while ((dir = queue.poll()) != null) {
-// DirectoryStream<Path> ds = dir.newDirectoryStream();
-// try {
-// for (Path p: ds) {
-// String name = p.getFileName().toString();
-// if (isDirectory(p)) {
-// if (recurse && SourceVersion.isIdentifier(name)) {
-// queue.add(p);
-// }
-// } else {
-// if (kinds.contains(getKind(name))) {
-// JavaFileObject fe =
-// PathFileObject.createDirectoryPathFileObject(this, p, pathDir);
-// results.append(fe);
-// }
-// }
-// }
-// } finally {
-// ds.close();
-// }
-// }
- int maxDepth = (recurse ? Integer.MAX_VALUE : 1);
- Set<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS);
- Files.walkFileTree(packageDir, opts, maxDepth,
- new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
- Path name = dir.getFileName();
- if (name == null || SourceVersion.isIdentifier(name.toString()))
- return FileVisitResult.CONTINUE;
- else
- return FileVisitResult.SKIP_SUBTREE;
- }
-
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
- if (attrs.isRegularFile() && kinds.contains(getKind(file.getFileName().toString()))) {
- // WORKAROUND for .jimage files
- if (!file.isAbsolute())
- file = pathDir.resolve(file);
- JavaFileObject fe =
- PathFileObject.createDirectoryPathFileObject(
- JavacPathFileManager.this, file, pathDir);
- results.append(fe);
- }
- return FileVisitResult.CONTINUE;
- }
- });
- }
-
- @Override
- public Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(
- Iterable<? extends Path> paths) {
- ArrayList<PathFileObject> result;
- if (paths instanceof Collection<?>)
- result = new ArrayList<>(((Collection<?>)paths).size());
- else
- result = new ArrayList<>();
- for (Path p: paths)
- result.add(PathFileObject.createSimplePathFileObject(this, nullCheck(p)));
- return result;
- }
-
- @Override
- public Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths) {
- return getJavaFileObjectsFromPaths(Arrays.asList(nullCheck(paths)));
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public JavaFileObject getJavaFileForInput(Location location,
- String className, Kind kind) throws IOException {
- return getFileForInput(location, getRelativePath(className, kind));
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public FileObject getFileForInput(Location location,
- String packageName, String relativeName) throws IOException {
- return getFileForInput(location, getRelativePath(packageName, relativeName));
- }
-
- private JavaFileObject getFileForInput(Location location, String relativePath)
- throws IOException {
- for (Path p: getLocation(location)) {
- if (isDirectory(p)) {
- Path f = resolve(p, relativePath);
- if (Files.exists(f))
- return PathFileObject.createDirectoryPathFileObject(this, f, p);
- } else {
- FileSystem fs = getFileSystem(p);
- if (fs != null) {
- Path file = getPath(fs, relativePath);
- if (Files.exists(file))
- return PathFileObject.createJarPathFileObject(this, file);
- }
- }
- }
- return null;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public JavaFileObject getJavaFileForOutput(Location location,
- String className, Kind kind, FileObject sibling) throws IOException {
- return getFileForOutput(location, getRelativePath(className, kind), sibling);
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public FileObject getFileForOutput(Location location, String packageName,
- String relativeName, FileObject sibling)
- throws IOException {
- return getFileForOutput(location, getRelativePath(packageName, relativeName), sibling);
- }
-
- private JavaFileObject getFileForOutput(Location location,
- String relativePath, FileObject sibling) {
- Path dir = getOutputLocation(location);
- if (dir == null) {
- if (location == CLASS_OUTPUT) {
- Path siblingDir = null;
- if (sibling != null && sibling instanceof PathFileObject) {
- siblingDir = ((PathFileObject) sibling).getPath().getParent();
- }
- return PathFileObject.createSiblingPathFileObject(this,
- siblingDir.resolve(getBaseName(relativePath)),
- relativePath);
- } else if (location == SOURCE_OUTPUT) {
- dir = getOutputLocation(CLASS_OUTPUT);
- }
- }
-
- Path file;
- if (dir != null) {
- file = resolve(dir, relativePath);
- return PathFileObject.createDirectoryPathFileObject(this, file, dir);
- } else {
- file = getPath(getDefaultFileSystem(), relativePath);
- return PathFileObject.createSimplePathFileObject(this, file);
- }
-
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public String inferBinaryName(Location location, JavaFileObject fo) {
- nullCheck(fo);
- // Need to match the path semantics of list(location, ...)
- Iterable<? extends Path> paths = getLocation(location);
- if (paths == null) {
- return null;
- }
-
- if (!(fo instanceof PathFileObject))
- throw new IllegalArgumentException(fo.getClass().getName());
-
- return ((PathFileObject) fo).inferBinaryName(paths);
- }
-
- private FileSystem getFileSystem(Path p) throws IOException {
- FileSystem fs = fileSystems.get(p);
- if (fs == null) {
- fs = FileSystems.newFileSystem(p, null);
- fileSystems.put(p, fs);
- }
- return fs;
- }
-
- private Map<Path,FileSystem> fileSystems;
-
- // </editor-fold>
-
- // <editor-fold defaultstate="collapsed" desc="Utility methods">
-
- private static String getRelativePath(String className, Kind kind) {
- return className.replace(".", "/") + kind.extension;
- }
-
- private static String getRelativePath(String packageName, String relativeName) {
- return packageName.isEmpty()
- ? relativeName : packageName.replace(".", "/") + "/" + relativeName;
- }
-
- private static String getBaseName(String relativePath) {
- int lastSep = relativePath.lastIndexOf("/");
- return relativePath.substring(lastSep + 1); // safe if "/" not found
- }
-
- private static boolean isDirectory(Path path) throws IOException {
- BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
- return attrs.isDirectory();
- }
-
- private static Path getPath(FileSystem fs, String relativePath) {
- return fs.getPath(relativePath.replace("/", fs.getSeparator()));
- }
-
- private static Path resolve(Path base, String relativePath) {
- FileSystem fs = base.getFileSystem();
- Path rp = fs.getPath(relativePath.replace("/", fs.getSeparator()));
- return base.resolve(rp);
- }
-
- // </editor-fold>
-
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/PathFileManager.java Wed Apr 08 13:12:52 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.nio;
-
-import java.io.IOException;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.Path;
-import javax.tools.FileObject;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-
-/**
- * File manager based on {@link java.nio.file.Path}.
- *
- * Eventually, this should be moved to javax.tools.
- * Also, JavaCompiler might reasonably provide a method getPathFileManager,
- * similar to {@link javax.tools.JavaCompiler#getStandardFileManager
- * getStandardFileManager}. However, would need to be handled carefully
- * as another forward reference from langtools to jdk.
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.</b>
- */
-public interface PathFileManager extends JavaFileManager {
- /**
- * Get the default file system used to create paths. If no value has been
- * set, the default file system is {@link FileSystems#getDefault}.
- */
- FileSystem getDefaultFileSystem();
-
- /**
- * Set the default file system used to create paths.
- * @param fs the default file system used to create any new paths.
- */
- void setDefaultFileSystem(FileSystem fs);
-
- /**
- * Get file objects representing the given files.
- *
- * @param paths a list of paths
- * @return a list of file objects
- * @throws IllegalArgumentException if the list of paths includes
- * a directory
- */
- Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(
- Iterable<? extends Path> paths);
-
- /**
- * Get file objects representing the given paths.
- * Convenience method equivalent to:
- *
- * <pre>
- * getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths))
- * </pre>
- *
- * @param paths an array of paths
- * @return a list of file objects
- * @throws IllegalArgumentException if the array of files includes
- * a directory
- * @throws NullPointerException if the given array contains null
- * elements
- */
- Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths);
-
- /**
- * Return the Path for a file object that has been obtained from this
- * file manager.
- *
- * @param fo A file object that has been obtained from this file manager.
- * @return The underlying Path object.
- * @throws IllegalArgumentException is the file object was not obtained from
- * from this file manager.
- */
- Path getPath(FileObject fo);
-
- /**
- * Get the search path associated with the given location.
- *
- * @param location a location
- * @return a list of paths or {@code null} if this location has no
- * associated search path
- * @see #setLocation
- */
- Iterable<? extends Path> getLocation(Location location);
-
- /**
- * Associate the given search path with the given location. Any
- * previous value will be discarded.
- *
- * @param location a location
- * @param searchPath a list of files, if {@code null} use the default
- * search path for this location
- * @see #getLocation
- * @throws IllegalArgumentException if location is an output
- * location and searchpath does not contain exactly one element
- * @throws IOException if location is an output location and searchpath
- * does not represent an existing directory
- */
- void setLocation(Location location, Iterable<? extends Path> searchPath) throws IOException;
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/PathFileObject.java Wed Apr 08 13:12:52 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,331 +0,0 @@
-/*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.nio;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.URI;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.CharsetDecoder;
-import java.nio.file.Files;
-import java.nio.file.LinkOption;
-import java.nio.file.Path;
-import java.util.Objects;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.NestingKind;
-import javax.tools.JavaFileObject;
-
-import com.sun.tools.javac.util.BaseFileManager;
-import com.sun.tools.javac.util.DefinedBy;
-import com.sun.tools.javac.util.DefinedBy.Api;
-
-
-/**
- * Implementation of JavaFileObject using java.nio.file API.
- *
- * <p>PathFileObjects are, for the most part, straightforward wrappers around
- * Path objects. The primary complexity is the support for "inferBinaryName".
- * This is left as an abstract method, implemented by each of a number of
- * different factory methods, which compute the binary name based on
- * information available at the time the file object is created.
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.</b>
- */
-public abstract class PathFileObject implements JavaFileObject {
- private final BaseFileManager fileManager;
- private final Path path;
-
- /**
- * Create a PathFileObject within a directory, such that the binary name
- * can be inferred from the relationship to the parent directory.
- */
- static PathFileObject createDirectoryPathFileObject(BaseFileManager fileManager,
- final Path path, final Path dir) {
- return new PathFileObject(fileManager, path) {
- @Override
- public String inferBinaryName(Iterable<? extends Path> paths) {
- return toBinaryName(dir.relativize(path));
- }
- };
- }
-
- /**
- * Create a PathFileObject in a file system such as a jar file, such that
- * the binary name can be inferred from its position within the filesystem.
- */
- public static PathFileObject createJarPathFileObject(BaseFileManager fileManager,
- final Path path) {
- return new PathFileObject(fileManager, path) {
- @Override
- public String inferBinaryName(Iterable<? extends Path> paths) {
- return toBinaryName(path);
- }
- };
- }
-
- /**
- * Create a PathFileObject in a modular file system, such as jrt:, such that
- * the binary name can be inferred from its position within the filesystem.
- */
- public static PathFileObject createJRTPathFileObject(BaseFileManager fileManager,
- final Path path) {
- return new PathFileObject(fileManager, path) {
- @Override
- public String inferBinaryName(Iterable<? extends Path> paths) {
- // use subpath to ignore the leading component containing the module name
- return toBinaryName(path.subpath(1, path.getNameCount()));
- }
- };
- }
-
- /**
- * Create a PathFileObject whose binary name can be inferred from the
- * relative path to a sibling.
- */
- static PathFileObject createSiblingPathFileObject(BaseFileManager fileManager,
- final Path path, final String relativePath) {
- return new PathFileObject(fileManager, path) {
- @Override
- public String inferBinaryName(Iterable<? extends Path> paths) {
- return toBinaryName(relativePath, "/");
- }
- };
- }
-
- /**
- * Create a PathFileObject whose binary name might be inferred from its
- * position on a search path.
- */
- static PathFileObject createSimplePathFileObject(BaseFileManager fileManager,
- final Path path) {
- return new PathFileObject(fileManager, path) {
- @Override
- public String inferBinaryName(Iterable<? extends Path> paths) {
- Path absPath = path.toAbsolutePath();
- for (Path p: paths) {
- Path ap = p.toAbsolutePath();
- if (absPath.startsWith(ap)) {
- try {
- Path rp = ap.relativize(absPath);
- if (rp != null) // maybe null if absPath same as ap
- return toBinaryName(rp);
- } catch (IllegalArgumentException e) {
- // ignore this p if cannot relativize path to p
- }
- }
- }
- return null;
- }
- };
- }
-
- protected PathFileObject(BaseFileManager fileManager, Path path) {
- this.fileManager = Objects.requireNonNull(fileManager);
- this.path = Objects.requireNonNull(path);
- }
-
- public abstract String inferBinaryName(Iterable<? extends Path> paths);
-
- /**
- * Return the Path for this object.
- * @return the Path for this object.
- */
- public Path getPath() {
- return path;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public Kind getKind() {
- return BaseFileManager.getKind(path.getFileName().toString());
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public boolean isNameCompatible(String simpleName, Kind kind) {
- Objects.requireNonNull(simpleName);
- // null check
- if (kind == Kind.OTHER && getKind() != kind) {
- return false;
- }
- String sn = simpleName + kind.extension;
- String pn = path.getFileName().toString();
- if (pn.equals(sn)) {
- return true;
- }
- if (pn.equalsIgnoreCase(sn)) {
- try {
- // allow for Windows
- return path.toRealPath(LinkOption.NOFOLLOW_LINKS).getFileName().toString().equals(sn);
- } catch (IOException e) {
- }
- }
- return false;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public NestingKind getNestingKind() {
- return null;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public Modifier getAccessLevel() {
- return null;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public URI toUri() {
- return path.toUri();
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public String getName() {
- return path.toString();
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public InputStream openInputStream() throws IOException {
- return Files.newInputStream(path);
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public OutputStream openOutputStream() throws IOException {
- fileManager.flushCache(this);
- ensureParentDirectoriesExist();
- return Files.newOutputStream(path);
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
- CharsetDecoder decoder = fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
- return new InputStreamReader(openInputStream(), decoder);
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
- CharBuffer cb = fileManager.getCachedContent(this);
- if (cb == null) {
- try (InputStream in = openInputStream()) {
- ByteBuffer bb = fileManager.makeByteBuffer(in);
- JavaFileObject prev = fileManager.log.useSource(this);
- try {
- cb = fileManager.decode(bb, ignoreEncodingErrors);
- } finally {
- fileManager.log.useSource(prev);
- }
- fileManager.recycleByteBuffer(bb);
- if (!ignoreEncodingErrors) {
- fileManager.cache(this, cb);
- }
- }
- }
- return cb;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public Writer openWriter() throws IOException {
- fileManager.flushCache(this);
- ensureParentDirectoriesExist();
- return new OutputStreamWriter(Files.newOutputStream(path), fileManager.getEncodingName());
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public long getLastModified() {
- try {
- return Files.getLastModifiedTime(path).toMillis();
- } catch (IOException e) {
- return -1;
- }
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public boolean delete() {
- try {
- Files.delete(path);
- return true;
- } catch (IOException e) {
- return false;
- }
- }
-
- public boolean isSameFile(PathFileObject other) {
- try {
- return Files.isSameFile(path, other.path);
- } catch (IOException e) {
- return false;
- }
- }
-
- @Override
- public boolean equals(Object other) {
- return (other instanceof PathFileObject && path.equals(((PathFileObject) other).path));
- }
-
- @Override
- public int hashCode() {
- return path.hashCode();
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + "[" + path + "]";
- }
-
- private void ensureParentDirectoriesExist() throws IOException {
- Path parent = path.getParent();
- if (parent != null)
- Files.createDirectories(parent);
- }
-
- private long size() {
- try {
- return Files.size(path);
- } catch (IOException e) {
- return -1;
- }
- }
-
- protected static String toBinaryName(Path relativePath) {
- return toBinaryName(relativePath.toString(),
- relativePath.getFileSystem().getSeparator());
- }
-
- protected static String toBinaryName(String relativePath, String sep) {
- return removeExtension(relativePath).replace(sep, ".");
- }
-
- protected static String removeExtension(String fileName) {
- int lastDot = fileName.lastIndexOf(".");
- return (lastDot == -1 ? fileName : fileName.substring(0, lastDot));
- }
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -797,7 +797,7 @@
loop:
while (isIdentifierStart(ch)) {
int namePos = bp;
- Name name = readIdentifier();
+ Name name = readAttributeName();
skipWhitespace();
List<DCTree> value = null;
ValueKind vkind = ValueKind.EMPTY;
@@ -905,6 +905,14 @@
return names.fromChars(buf, start, bp - start);
}
+ protected Name readAttributeName() {
+ int start = bp;
+ nextChar();
+ while (bp < buflen && (Character.isUnicodeIdentifierPart(ch) || ch == '-'))
+ nextChar();
+ return names.fromChars(buf, start, bp - start);
+ }
+
protected Name readTagName() {
int start = bp;
nextChar();
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Apr 08 14:32:21 2015 -0700
@@ -2010,6 +2010,16 @@
compiler.misc.diamond.non.generic=\
cannot use ''<>'' with non-generic class {0}
+# 0: list of type, 1: message segment
+compiler.misc.diamond.invalid.arg=\
+ type argument {0} inferred for {1} is not allowed in this context\n\
+ inferred argument is not expressible in the Signature attribute
+
+# 0: list of type, 1: message segment
+compiler.misc.diamond.invalid.args=\
+ type arguments {0} inferred for {1} are not allowed in this context\n\
+ inferred arguments are not expressible in the Signature attribute
+
# 0: unused
compiler.misc.diamond.and.explicit.params=\
cannot use ''<>'' with explicit type parameters for constructor
@@ -2271,10 +2281,6 @@
compiler.misc.varargs.clash.with=\
{0} in {1} overrides {2} in {3}
-# 0: unused
-compiler.misc.diamond.and.anon.class=\
- cannot use ''<>'' with anonymous inner classes
-
# 0: symbol kind, 1: symbol, 2: symbol, 3: message segment
compiler.misc.inapplicable.method=\
{0} {1}.{2} is not applicable\n\
@@ -2284,6 +2290,11 @@
# Diagnostics for language feature changes
########################################
# 0: string
+compiler.misc.diamond.and.anon.class.not.supported.in.source=\
+ cannot use ''<>'' with anonymous inner classes in -source {0}\n\
+ (use -source 9 or higher to enable ''<>'' with anonymous inner classes)
+
+# 0: string
compiler.err.unsupported.binary.lit=\
binary literals are not supported in -source {0}\n\
(use -source 7 or higher to enable binary literals)
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -190,6 +190,18 @@
}
}
+ /** Return true if the given tree represents a type elided anonymous class instance creation. */
+ public static boolean isAnonymousDiamond(JCTree tree) {
+ switch(tree.getTag()) {
+ case NEWCLASS: {
+ JCNewClass nc = (JCNewClass)tree;
+ return nc.def != null && isDiamond(nc.clazz);
+ }
+ case ANNOTATED_TYPE: return isAnonymousDiamond(((JCAnnotatedType)tree).underlyingType);
+ default: return false;
+ }
+ }
+
public static boolean isEnumInit(JCTree tree) {
switch (tree.getTag()) {
case VARDEF:
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/BaseFileManager.java Wed Apr 08 13:12:52 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,443 +0,0 @@
-/*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.lang.ref.SoftReference;
-import java.lang.reflect.Constructor;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CoderResult;
-import java.nio.charset.CodingErrorAction;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.UnsupportedCharsetException;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.JavaFileObject.Kind;
-
-import com.sun.tools.javac.code.Lint;
-import com.sun.tools.javac.code.Source;
-import com.sun.tools.javac.file.FSInfo;
-import com.sun.tools.javac.file.Locations;
-import com.sun.tools.javac.main.Option;
-import com.sun.tools.javac.main.OptionHelper;
-import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
-import com.sun.tools.javac.util.DefinedBy.Api;
-import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
-
-/**
- * Utility methods for building a filemanager.
- * There are no references here to file-system specific objects such as
- * java.io.File or java.nio.file.Path.
- */
-public abstract class BaseFileManager implements JavaFileManager {
- protected BaseFileManager(Charset charset) {
- this.charset = charset;
- byteBufferCache = new ByteBufferCache();
- locations = createLocations();
- }
-
- /**
- * Set the context for JavacPathFileManager.
- * @param context the context containing items to be associated with the file manager
- */
- public void setContext(Context context) {
- log = Log.instance(context);
- options = Options.instance(context);
- classLoaderClass = options.get("procloader");
- locations.update(log, Lint.instance(context), FSInfo.instance(context));
- }
-
- protected Locations createLocations() {
- return new Locations();
- }
-
- /**
- * The log to be used for error reporting.
- */
- public Log log;
-
- /**
- * User provided charset (through javax.tools).
- */
- protected Charset charset;
-
- protected Options options;
-
- protected String classLoaderClass;
-
- protected Locations locations;
-
- /**
- * A flag for clients to use to indicate that this file manager should
- * be closed when it is no longer required.
- */
- public boolean autoClose;
-
- protected Source getSource() {
- String sourceName = options.get(Option.SOURCE);
- Source source = null;
- if (sourceName != null)
- source = Source.lookup(sourceName);
- return (source != null ? source : Source.DEFAULT);
- }
-
- protected ClassLoader getClassLoader(URL[] urls) {
- ClassLoader thisClassLoader = getClass().getClassLoader();
-
- // Allow the following to specify a closeable classloader
- // other than URLClassLoader.
-
- // 1: Allow client to specify the class to use via hidden option
- if (classLoaderClass != null) {
- try {
- Class<? extends ClassLoader> loader =
- Class.forName(classLoaderClass).asSubclass(ClassLoader.class);
- Class<?>[] constrArgTypes = { URL[].class, ClassLoader.class };
- Constructor<? extends ClassLoader> constr = loader.getConstructor(constrArgTypes);
- return constr.newInstance(urls, thisClassLoader);
- } catch (ReflectiveOperationException t) {
- // ignore errors loading user-provided class loader, fall through
- }
- }
- return new URLClassLoader(urls, thisClassLoader);
- }
-
- public boolean isDefaultBootClassPath() {
- return locations.isDefaultBootClassPath();
- }
-
- // <editor-fold defaultstate="collapsed" desc="Option handling">
- @Override @DefinedBy(Api.COMPILER)
- public boolean handleOption(String current, Iterator<String> remaining) {
- OptionHelper helper = new GrumpyHelper(log) {
- @Override
- public String get(Option option) {
- return options.get(option.getText());
- }
-
- @Override
- public void put(String name, String value) {
- options.put(name, value);
- }
-
- @Override
- public void remove(String name) {
- options.remove(name);
- }
-
- @Override
- public boolean handleFileManagerOption(Option option, String value) {
- return handleOption(option, value);
- }
- };
-
- for (Option o: javacFileManagerOptions) {
- if (o.matches(current)) {
- if (o.hasArg()) {
- if (remaining.hasNext()) {
- if (!o.process(helper, current, remaining.next()))
- return true;
- }
- } else {
- if (!o.process(helper, current))
- return true;
- }
- // operand missing, or process returned true
- throw new IllegalArgumentException(current);
- }
- }
-
- return false;
- }
- // where
- private static final Set<Option> javacFileManagerOptions =
- Option.getJavacFileManagerOptions();
-
- @Override @DefinedBy(Api.COMPILER)
- public int isSupportedOption(String option) {
- for (Option o : javacFileManagerOptions) {
- if (o.matches(option))
- return o.hasArg() ? 1 : 0;
- }
- return -1;
- }
-
- /**
- * Common back end for OptionHelper handleFileManagerOption.
- * @param option the option whose value to be set
- * @param value the value for the option
- * @return true if successful, and false otherwise
- */
- public boolean handleOption(Option option, String value) {
- return locations.handleOption(option, value);
- }
-
- /**
- * Call handleOption for collection of options and corresponding values.
- * @param map a collection of options and corresponding values
- * @return true if all the calls are successful
- */
- public boolean handleOptions(Map<Option, String> map) {
- boolean ok = true;
- for (Map.Entry<Option, String> e: map.entrySet())
- ok = ok & handleOption(e.getKey(), e.getValue());
- return ok;
- }
-
- // </editor-fold>
-
- // <editor-fold defaultstate="collapsed" desc="Encoding">
- private String defaultEncodingName;
- private String getDefaultEncodingName() {
- if (defaultEncodingName == null) {
- defaultEncodingName =
- new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding();
- }
- return defaultEncodingName;
- }
-
- public String getEncodingName() {
- String encName = options.get(Option.ENCODING);
- if (encName == null)
- return getDefaultEncodingName();
- else
- return encName;
- }
-
- @SuppressWarnings("cast")
- public CharBuffer decode(ByteBuffer inbuf, boolean ignoreEncodingErrors) {
- String encodingName = getEncodingName();
- CharsetDecoder decoder;
- try {
- decoder = getDecoder(encodingName, ignoreEncodingErrors);
- } catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
- log.error("unsupported.encoding", encodingName);
- return (CharBuffer)CharBuffer.allocate(1).flip();
- }
-
- // slightly overestimate the buffer size to avoid reallocation.
- float factor =
- decoder.averageCharsPerByte() * 0.8f +
- decoder.maxCharsPerByte() * 0.2f;
- CharBuffer dest = CharBuffer.
- allocate(10 + (int)(inbuf.remaining()*factor));
-
- while (true) {
- CoderResult result = decoder.decode(inbuf, dest, true);
- dest.flip();
-
- if (result.isUnderflow()) { // done reading
- // make sure there is at least one extra character
- if (dest.limit() == dest.capacity()) {
- dest = CharBuffer.allocate(dest.capacity()+1).put(dest);
- dest.flip();
- }
- return dest;
- } else if (result.isOverflow()) { // buffer too small; expand
- int newCapacity =
- 10 + dest.capacity() +
- (int)(inbuf.remaining()*decoder.maxCharsPerByte());
- dest = CharBuffer.allocate(newCapacity).put(dest);
- } else if (result.isMalformed() || result.isUnmappable()) {
- // bad character in input
-
- log.error(new SimpleDiagnosticPosition(dest.limit()),
- "illegal.char.for.encoding",
- charset == null ? encodingName : charset.name());
-
- // skip past the coding error
- inbuf.position(inbuf.position() + result.length());
-
- // undo the flip() to prepare the output buffer
- // for more translation
- dest.position(dest.limit());
- dest.limit(dest.capacity());
- dest.put((char)0xfffd); // backward compatible
- } else {
- throw new AssertionError(result);
- }
- }
- // unreached
- }
-
- public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) {
- Charset cs = (this.charset == null)
- ? Charset.forName(encodingName)
- : this.charset;
- CharsetDecoder decoder = cs.newDecoder();
-
- CodingErrorAction action;
- if (ignoreEncodingErrors)
- action = CodingErrorAction.REPLACE;
- else
- action = CodingErrorAction.REPORT;
-
- return decoder
- .onMalformedInput(action)
- .onUnmappableCharacter(action);
- }
- // </editor-fold>
-
- // <editor-fold defaultstate="collapsed" desc="ByteBuffers">
- /**
- * Make a byte buffer from an input stream.
- * @param in the stream
- * @return a byte buffer containing the contents of the stream
- * @throws IOException if an error occurred while reading the stream
- */
- @SuppressWarnings("cast")
- public ByteBuffer makeByteBuffer(InputStream in)
- throws IOException {
- int limit = in.available();
- if (limit < 1024) limit = 1024;
- ByteBuffer result = byteBufferCache.get(limit);
- int position = 0;
- while (in.available() != 0) {
- if (position >= limit)
- // expand buffer
- result = ByteBuffer.
- allocate(limit <<= 1).
- put((ByteBuffer)result.flip());
- int count = in.read(result.array(),
- position,
- limit - position);
- if (count < 0) break;
- result.position(position += count);
- }
- return (ByteBuffer)result.flip();
- }
-
- public void recycleByteBuffer(ByteBuffer bb) {
- byteBufferCache.put(bb);
- }
-
- /**
- * A single-element cache of direct byte buffers.
- */
- @SuppressWarnings("cast")
- private static class ByteBufferCache {
- private ByteBuffer cached;
- ByteBuffer get(int capacity) {
- if (capacity < 20480) capacity = 20480;
- ByteBuffer result =
- (cached != null && cached.capacity() >= capacity)
- ? (ByteBuffer)cached.clear()
- : ByteBuffer.allocate(capacity + capacity>>1);
- cached = null;
- return result;
- }
- void put(ByteBuffer x) {
- cached = x;
- }
- }
-
- private final ByteBufferCache byteBufferCache;
- // </editor-fold>
-
- // <editor-fold defaultstate="collapsed" desc="Content cache">
- public CharBuffer getCachedContent(JavaFileObject file) {
- ContentCacheEntry e = contentCache.get(file);
- if (e == null)
- return null;
-
- if (!e.isValid(file)) {
- contentCache.remove(file);
- return null;
- }
-
- return e.getValue();
- }
-
- public void cache(JavaFileObject file, CharBuffer cb) {
- contentCache.put(file, new ContentCacheEntry(file, cb));
- }
-
- public void flushCache(JavaFileObject file) {
- contentCache.remove(file);
- }
-
- protected final Map<JavaFileObject, ContentCacheEntry> contentCache = new HashMap<>();
-
- protected static class ContentCacheEntry {
- final long timestamp;
- final SoftReference<CharBuffer> ref;
-
- ContentCacheEntry(JavaFileObject file, CharBuffer cb) {
- this.timestamp = file.getLastModified();
- this.ref = new SoftReference<>(cb);
- }
-
- boolean isValid(JavaFileObject file) {
- return timestamp == file.getLastModified();
- }
-
- CharBuffer getValue() {
- return ref.get();
- }
- }
- // </editor-fold>
-
- public static Kind getKind(Path path) {
- return getKind(path.getFileName().toString());
- }
-
- public static Kind getKind(String name) {
- if (name.endsWith(Kind.CLASS.extension))
- return Kind.CLASS;
- else if (name.endsWith(Kind.SOURCE.extension))
- return Kind.SOURCE;
- else if (name.endsWith(Kind.HTML.extension))
- return Kind.HTML;
- else
- return Kind.OTHER;
- }
-
- protected static <T> T nullCheck(T o) {
- return Objects.requireNonNull(o);
- }
-
- protected static <T> Collection<T> nullCheck(Collection<T> it) {
- for (T t : it)
- Objects.requireNonNull(t);
- return it;
- }
-}
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java Wed Apr 08 14:32:21 2015 -0700
@@ -56,17 +56,10 @@
DocFileFactory f = factories.get(configuration);
if (f == null) {
JavaFileManager fm = configuration.getFileManager();
- if (fm instanceof StandardJavaFileManager)
+ if (fm instanceof StandardJavaFileManager) {
f = new StandardDocFileFactory(configuration);
- else {
- try {
- Class<?> pathFileManagerClass =
- Class.forName("com.sun.tools.javac.nio.PathFileManager");
- if (pathFileManagerClass.isAssignableFrom(fm.getClass()))
- f = new PathDocFileFactory(configuration);
- } catch (Throwable t) {
- throw new IllegalStateException(t);
- }
+ } else {
+ throw new IllegalStateException();
}
factories.put(configuration, f);
}
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java Wed Apr 08 13:12:52 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,320 +0,0 @@
-/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.tools.doclets.internal.toolkit.util;
-
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.nio.file.DirectoryStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.tools.DocumentationTool;
-import javax.tools.FileObject;
-import javax.tools.JavaFileManager.Location;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardLocation;
-
-import com.sun.tools.doclets.internal.toolkit.Configuration;
-import com.sun.tools.javac.nio.PathFileManager;
-
-
-/**
- * Implementation of DocFileFactory using a {@link PathFileManager}.
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.</b>
- *
- * @since 1.8
- */
-class PathDocFileFactory extends DocFileFactory {
- private final PathFileManager fileManager;
- private final Path destDir;
-
- public PathDocFileFactory(Configuration configuration) {
- super(configuration);
- fileManager = (PathFileManager) configuration.getFileManager();
-
- if (!configuration.destDirName.isEmpty()
- || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) {
- try {
- String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName;
- Path dir = fileManager.getDefaultFileSystem().getPath(dirName);
- fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
- } catch (IOException e) {
- throw new DocletAbortException(e);
- }
- }
-
- destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next();
- }
-
- public DocFile createFileForDirectory(String file) {
- return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file));
- }
-
- public DocFile createFileForInput(String file) {
- return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file));
- }
-
- public DocFile createFileForOutput(DocPath path) {
- return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
- }
-
- @Override
- Iterable<DocFile> list(Location location, DocPath path) {
- if (location != StandardLocation.SOURCE_PATH)
- throw new IllegalArgumentException();
-
- Set<DocFile> files = new LinkedHashSet<>();
- if (fileManager.hasLocation(location)) {
- for (Path f: fileManager.getLocation(location)) {
- if (Files.isDirectory(f)) {
- f = f.resolve(path.getPath());
- if (Files.exists(f))
- files.add(new StandardDocFile(f));
- }
- }
- }
- return files;
- }
-
- class StandardDocFile extends DocFile {
- private Path file;
-
- /** Create a StandardDocFile for a given file. */
- private StandardDocFile(Path file) {
- super(configuration);
- this.file = file;
- }
-
- /** Create a StandardDocFile for a given location and relative path. */
- private StandardDocFile(Location location, DocPath path) {
- super(configuration, location, path);
- this.file = destDir.resolve(path.getPath());
- }
-
- /** Open an input stream for the file. */
- public InputStream openInputStream() throws IOException {
- JavaFileObject fo = getJavaFileObjectForInput(file);
- return new BufferedInputStream(fo.openInputStream());
- }
-
- /**
- * Open an output stream for the file.
- * The file must have been created with a location of
- * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
- */
- public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
- if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
- throw new IllegalStateException();
-
- OutputStream out = getFileObjectForOutput(path).openOutputStream();
- return new BufferedOutputStream(out);
- }
-
- /**
- * Open an writer for the file, using the encoding (if any) given in the
- * doclet configuration.
- * The file must have been created with a location of
- * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
- */
- public Writer openWriter() throws IOException, UnsupportedEncodingException {
- if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
- throw new IllegalStateException();
-
- OutputStream out = getFileObjectForOutput(path).openOutputStream();
- if (configuration.docencoding == null) {
- return new BufferedWriter(new OutputStreamWriter(out));
- } else {
- return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding));
- }
- }
-
- /** Return true if the file can be read. */
- public boolean canRead() {
- return Files.isReadable(file);
- }
-
- /** Return true if the file can be written. */
- public boolean canWrite() {
- return Files.isWritable(file);
- }
-
- /** Return true if the file exists. */
- public boolean exists() {
- return Files.exists(file);
- }
-
- /** Return the base name (last component) of the file name. */
- public String getName() {
- return file.getFileName().toString();
- }
-
- /** Return the file system path for this file. */
- public String getPath() {
- return file.toString();
- }
-
- /** Return true is file has an absolute path name. */
- public boolean isAbsolute() {
- return file.isAbsolute();
- }
-
- /** Return true is file identifies a directory. */
- public boolean isDirectory() {
- return Files.isDirectory(file);
- }
-
- /** Return true is file identifies a file. */
- public boolean isFile() {
- return Files.isRegularFile(file);
- }
-
- /** Return true if this file is the same as another. */
- public boolean isSameFile(DocFile other) {
- if (!(other instanceof StandardDocFile))
- return false;
-
- try {
- return Files.isSameFile(file, ((StandardDocFile) other).file);
- } catch (IOException e) {
- return false;
- }
- }
-
- /** If the file is a directory, list its contents. */
- public Iterable<DocFile> list() throws IOException {
- List<DocFile> files = new ArrayList<>();
- try (DirectoryStream<Path> ds = Files.newDirectoryStream(file)) {
- for (Path f: ds) {
- files.add(new StandardDocFile(f));
- }
- }
- return files;
- }
-
- /** Create the file as a directory, including any parent directories. */
- public boolean mkdirs() {
- try {
- Files.createDirectories(file);
- return true;
- } catch (IOException e) {
- return false;
- }
- }
-
- /**
- * Derive a new file by resolving a relative path against this file.
- * The new file will inherit the configuration and location of this file
- * If this file has a path set, the new file will have a corresponding
- * new path.
- */
- public DocFile resolve(DocPath p) {
- return resolve(p.getPath());
- }
-
- /**
- * Derive a new file by resolving a relative path against this file.
- * The new file will inherit the configuration and location of this file
- * If this file has a path set, the new file will have a corresponding
- * new path.
- */
- public DocFile resolve(String p) {
- if (location == null && path == null) {
- return new StandardDocFile(file.resolve(p));
- } else {
- return new StandardDocFile(location, path.resolve(p));
- }
- }
-
- /**
- * Resolve a relative file against the given output location.
- * @param locn Currently, only
- * {@link DocumentationTool.Location.DOCUMENTATION_OUTPUT} is supported.
- */
- public DocFile resolveAgainst(Location locn) {
- if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
- throw new IllegalArgumentException();
- return new StandardDocFile(destDir.resolve(file));
- }
-
- /** Return a string to identify the contents of this object,
- * for debugging purposes.
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("PathDocFile[");
- if (location != null)
- sb.append("locn:").append(location).append(",");
- if (path != null)
- sb.append("path:").append(path.getPath()).append(",");
- sb.append("file:").append(file);
- sb.append("]");
- return sb.toString();
- }
-
- private JavaFileObject getJavaFileObjectForInput(Path file) {
- return fileManager.getJavaFileObjects(file).iterator().next();
- }
-
- private FileObject getFileObjectForOutput(DocPath path) throws IOException {
- // break the path into a package-part and the rest, by finding
- // the position of the last '/' before an invalid character for a
- // package name, such as the "." before an extension or the "-"
- // in filenames like package-summary.html, doc-files or src-html.
- String p = path.getPath();
- int lastSep = -1;
- for (int i = 0; i < p.length(); i++) {
- char ch = p.charAt(i);
- if (ch == '/') {
- lastSep = i;
- } else if (i == lastSep + 1 && !Character.isJavaIdentifierStart(ch)
- || !Character.isJavaIdentifierPart(ch)) {
- break;
- }
- }
- String pkg = (lastSep == -1) ? "" : p.substring(0, lastSep);
- String rest = p.substring(lastSep + 1);
- return fileManager.getFileForOutput(location, pkg, rest, null);
- }
- }
-
-}
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java Wed Apr 08 14:32:21 2015 -0700
@@ -42,7 +42,7 @@
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.main.CommandLine;
import com.sun.tools.javac.main.Option;
-import com.sun.tools.javac.util.BaseFileManager;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.util.ClientCodeException;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTool.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTool.java Wed Apr 08 14:32:21 2015 -0700
@@ -46,7 +46,7 @@
import com.sun.tools.javac.api.ClientCodeWrapper;
import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.util.BaseFileManager;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.util.ClientCodeException;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.DefinedBy;
--- a/langtools/test/tools/javac/MethodParameters/LambdaTest.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/MethodParameters/LambdaTest.out Wed Apr 08 14:32:21 2015 -0700
@@ -2,6 +2,6 @@
LambdaTest.<init>()
LambdaTest.foo(i)
LambdaTest.lambda$static$1(x1/*synthetic*/)/*synthetic*/
-LambdaTest.lambda$null$0(final cap$0/*synthetic*/, x2/*synthetic*/)/*synthetic*/
+LambdaTest.lambda$null$0(final x1/*synthetic*/, x2/*synthetic*/)/*synthetic*/
static interface LambdaTest$I -- inner
LambdaTest$I.m(x)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T7040592/CoerceNullToMoreSpecificTypeTest.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7040592
+ * @summary Test that the assertion in State.forceStackTop does not fail at compile time.
+ */
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import org.w3c.dom.Element;
+
+public class CoerceNullToMoreSpecificTypeTest {
+ abstract class NodeImpl {
+ }
+
+ NodeImpl ownerNode;
+
+ public Element getElement() {
+ return (Element) (isOwned() ? ownerNode : null);
+ }
+
+ boolean isOwned() {
+ return true;
+ }
+
+ static void processArrays(boolean expectNulls, Object [] nulla, Object [][] nullaa) {
+ if (expectNulls) {
+ if (nulla != null || nullaa != null) {
+ throw new AssertionError("Null actual, but not null formal");
+ }
+ } else {
+ if (nulla.length != 123 || nullaa.length != 321)
+ throw new AssertionError("Wrong arrays received");
+ }
+ }
+
+ public static void main(String[] args) {
+ ArrayList<Class<?>> typeList = new ArrayList<>();
+ Field rf = null;
+ typeList.add((rf != null) ? rf.getType() : null);
+ processArrays(true, null, null);
+ processArrays(false, new Object[123], new Object[321][]);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T7040592/T7040592.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7040592
+ * @summary Verify that null can be assigned freely to array types without a checkcast
+ */
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.file.Paths;
+
+public class T7040592 {
+
+ private static final String assertionErrorMsg =
+ "null should be assignable to array type without a checkcast";
+
+ public static void main(String[] args) {
+ new T7040592().run();
+ }
+
+ void run() {
+ check("-c", Paths.get(System.getProperty("test.classes"),
+ "T7040592_01.class").toString());
+ }
+
+ void check(String... params) {
+ StringWriter s;
+ String out;
+ try (PrintWriter pw = new PrintWriter(s = new StringWriter())) {
+ com.sun.tools.javap.Main.run(params, pw);
+ out = s.toString();
+ }
+ if (out.contains("checkcast")) {
+ throw new AssertionError(assertionErrorMsg);
+ }
+ }
+
+}
+
+class T7040592_01 {
+ static void handleArrays(Object [] a, Object [][] b, Object [][][] c) {
+ }
+ public static void main(String[] args) {
+ Object a[];
+ Object o = (a = null)[0];
+ Object b[][];
+ o = (b = null)[0][0];
+ Object c[][][];
+ o = (c = null)[0][0][0];
+ handleArrays(null, null, null);
+ }
+}
--- a/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8042251
+ * @bug 8042251 8062373
* @summary Testing InnerClasses_attribute of inner classes in anonymous class.
* @library /tools/lib /tools/javac/lib ../lib
* @build InnerClassesTestBase TestResult TestBase InMemoryFileManager ToolBox
@@ -73,6 +73,6 @@
public void getAdditionalFlags(Map<String, Set<String>> class2Flags, ClassType type, Modifier... flags) {
super.getAdditionalFlags(class2Flags, type, flags);
class2Flags.put("Anonymous", getFlags(currentClassType, Arrays.asList(flags)));
- class2Flags.put("1", new HashSet<>());
+ class2Flags.put("1", new HashSet<>() {});
}
}
--- a/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -21,9 +21,8 @@
* questions.
*/
-// key: compiler.err.prob.found.req
// key: compiler.misc.cant.access.inner.cls.constr
-// key: compiler.misc.invalid.mref
+// key: compiler.err.invalid.mref
class CantAccessInnerClsConstructor {
--- a/langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -21,8 +21,10 @@
* questions.
*/
-// key: compiler.misc.diamond.and.anon.class
+// key: compiler.misc.diamond.and.anon.class.not.supported.in.source
// key: compiler.err.cant.apply.diamond.1
+// key: compiler.warn.source.no.bootclasspath
+// options: -source 8
import java.util.*;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/DiamondAndNonDenotableTypes.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.misc.diamond
+// key: compiler.err.cant.apply.diamond.1
+// key: compiler.misc.diamond.invalid.arg
+// key: compiler.misc.diamond.invalid.args
+
+import java.util.*;
+
+class DiamondAndNonDenotableType<T> {
+ DiamondAndNonDenotableType(T t) {}
+}
+
+class DiamondAndNonDenotableTypes<T, S> {
+ DiamondAndNonDenotableTypes(T t, S s) {}
+ void m() {
+ List<?> wl = null;
+ new DiamondAndNonDenotableTypes<>(wl, wl) {};
+ new DiamondAndNonDenotableType<>(wl) {};
+ };
+}
--- a/langtools/test/tools/javac/doctree/AttrTest.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/doctree/AttrTest.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 7021614
+ * @bug 7021614 8076026
* @summary extend com.sun.source API to support parsing javadoc comments
* @build DocCommentTester
* @run main DocCommentTester AttrTest.java
@@ -55,6 +55,30 @@
*/
/**
+ * <a name-test=hyphened>foo</a>
+ */
+ void hyphened_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+ firstSentence: 3
+ StartElement[START_ELEMENT, pos:1
+ name:a
+ attributes: 1
+ Attribute[ATTRIBUTE, pos:4
+ name: name-test
+ vkind: UNQUOTED
+ value: 1
+ Text[TEXT, pos:14, hyphened]
+ ]
+ ]
+ Text[TEXT, pos:23, foo]
+ EndElement[END_ELEMENT, pos:26, a]
+ body: empty
+ block tags: empty
+]
+*/
+
+ /**
* <a name="double_quoted">foo</a>
*/
void double_quoted_attr() { }
--- a/langtools/test/tools/javac/failover/CheckAttributedTree.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/failover/CheckAttributedTree.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6970584 8006694
+ * @bug 6970584 8006694 8062373
* @summary assorted position errors in compiler syntax trees
* temporarily workaround combo tests are causing time out in several platforms
* @library ../lib
@@ -290,7 +290,7 @@
}
public void finished(TaskEvent e) { }
});
-
+ int i = 0;
try {
Iterable<? extends CompilationUnitTree> trees = task.parse();
// JavaCompiler c = JavaCompiler.instance(((JavacTaskImpl) task).getContext());
@@ -308,7 +308,7 @@
if (def.hasTag(CLASSDEF) &&
analyzedElems.contains(((JCTree.JCClassDecl)def).sym)) {
//System.err.println("Adding pair..." + cu.sourcefile + " " + ((JCTree.JCClassDecl) def).name);
- res.add(new Pair<>(cu, def));
+ res.add((i++ % 2) == 0 ? new Pair<>(cu, def) {} : new Pair<>(cu, def));
}
}
}
--- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,11 +1,12 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939780 7020044 8009459 8021338 8064365
+ * @bug 6939780 7020044 8009459 8021338 8064365 8062373
*
- * @summary add a warning to detect diamond sites
+ * @summary add a warning to detect diamond sites (including anonymous class instance creation at source >= 9)
* @author mcimadamore
* @compile/ref=T6939780_7.out -Xlint:-options -source 7 T6939780.java -XDrawDiagnostics -XDfind=diamond
- * @compile/ref=T6939780_8.out T6939780.java -XDrawDiagnostics -XDfind=diamond
+ * @compile/ref=T6939780_8.out -Xlint:-options -source 8 T6939780.java -XDrawDiagnostics -XDfind=diamond
+ * @compile/ref=T6939780_9.out -Xlint:-options -source 9 T6939780.java -XDrawDiagnostics -XDfind=diamond
*
*/
--- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
-T6939780.java:21:28: compiler.warn.diamond.redundant.args
-T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
-T6939780.java:30:19: compiler.warn.diamond.redundant.args
-T6939780.java:31:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:22:28: compiler.warn.diamond.redundant.args
+T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:31:19: compiler.warn.diamond.redundant.args
+T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
4 warnings
--- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out Wed Apr 08 14:32:21 2015 -0700
@@ -1,7 +1,7 @@
-T6939780.java:20:33: compiler.warn.diamond.redundant.args
-T6939780.java:21:28: compiler.warn.diamond.redundant.args
-T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
-T6939780.java:29:19: compiler.warn.diamond.redundant.args
+T6939780.java:21:33: compiler.warn.diamond.redundant.args
+T6939780.java:22:28: compiler.warn.diamond.redundant.args
+T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
T6939780.java:30:19: compiler.warn.diamond.redundant.args
-T6939780.java:31:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:31:19: compiler.warn.diamond.redundant.args
+T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
6 warnings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_9.out Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,13 @@
+T6939780.java:21:33: compiler.warn.diamond.redundant.args
+T6939780.java:22:28: compiler.warn.diamond.redundant.args
+T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:24:33: compiler.warn.diamond.redundant.args
+T6939780.java:25:28: compiler.warn.diamond.redundant.args
+T6939780.java:26:28: compiler.warn.diamond.redundant.args
+T6939780.java:30:19: compiler.warn.diamond.redundant.args
+T6939780.java:31:19: compiler.warn.diamond.redundant.args
+T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:33:19: compiler.warn.diamond.redundant.args
+T6939780.java:34:19: compiler.warn.diamond.redundant.args
+T6939780.java:35:19: compiler.warn.diamond.redundant.args
+12 warnings
--- a/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6996914 7020044
+ * @bug 6996914 7020044 8062373
* @summary Diamond inference: problem when accessing protected constructor
* @run main T6996914a
*/
@@ -53,6 +53,17 @@
}
}
+ enum DiamondKind {
+ STANDARD("new Foo<>();"),
+ ANON("new Foo<>() {};");
+
+ String expr;
+
+ DiamondKind(String expr) {
+ this.expr = expr;
+ }
+ }
+
enum ConstructorKind {
PACKAGE(""),
PROTECTED("protected"),
@@ -93,14 +104,14 @@
final static String sourceStub =
"#I\n" +
"class Test {\n" +
- " Foo<String> fs = new Foo<>();\n" +
+ " Foo<String> fs = #D\n" +
"}\n";
String source;
- public ClientClass(PackageKind pk) {
+ public ClientClass(PackageKind pk, DiamondKind dk) {
super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
- source = sourceStub.replace("#I", pk.importDecl);
+ source = sourceStub.replace("#I", pk.importDecl).replace("#D", dk.expr);
}
@Override
@@ -112,20 +123,22 @@
public static void main(String... args) throws Exception {
for (PackageKind pk : PackageKind.values()) {
for (ConstructorKind ck : ConstructorKind.values()) {
- compileAndCheck(pk, ck);
+ for (DiamondKind dk : DiamondKind.values()) {
+ compileAndCheck(pk, ck, dk);
+ }
}
}
}
- static void compileAndCheck(PackageKind pk, ConstructorKind ck) throws Exception {
+ static void compileAndCheck(PackageKind pk, ConstructorKind ck, DiamondKind dk) throws Exception {
FooClass foo = new FooClass(pk, ck);
- ClientClass client = new ClientClass(pk);
+ ClientClass client = new ClientClass(pk, dk);
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
ErrorListener el = new ErrorListener();
JavacTask ct = (JavacTask)tool.getTask(null, null, el,
null, null, Arrays.asList(foo, client));
ct.analyze();
- if (el.errors > 0 == check(pk, ck)) {
+ if (el.errors > 0 == check(pk, ck, dk)) {
String msg = el.errors > 0 ?
"Error compiling files" :
"No error when compiling files";
@@ -133,9 +146,10 @@
}
}
- static boolean check(PackageKind pk, ConstructorKind ck) {
+ static boolean check(PackageKind pk, ConstructorKind ck, DiamondKind dk) {
switch (pk) {
- case A: return ck == ConstructorKind.PUBLIC;
+ case A: return ck == ConstructorKind.PUBLIC ||
+ (ck == ConstructorKind.PROTECTED && dk == DiamondKind.ANON);
case DEFAULT: return ck != ConstructorKind.PRIVATE;
default: throw new AssertionError("Unknown package kind");
}
--- a/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6996914 7020044
+ * @bug 6996914 7020044 8062373
* @summary Diamond inference: problem when accessing protected constructor
* @compile T6996914b.java
*/
@@ -35,4 +35,5 @@
class Test {
Super<String,Integer> ssi1 = new Super<>(1, "", 2);
+ Super<String,Integer> ssi2 = new Super<>(1, "", 2) {};
}
--- a/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 8065986
+ * @bug 8065986 8062373
*
* @summary Compiler fails to NullPointerException when calling super with Object<>()
* @compile/fail/ref=T8065986b.out T8065986b.java -XDrawDiagnostics
@@ -29,5 +29,12 @@
this(cond ? o1 : o2);
}
+ T8065986b(int x) {
+ this(new Object<>() {});
+ }
+
+ T8065986b(int x, int y) {
+ this(new ArrayList<>() {});
+ }
static void m() { }
}
--- a/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.out Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,8 @@
T8065986b.java:13:24: compiler.err.cant.apply.diamond.1: java.lang.Object, (compiler.misc.diamond.non.generic: java.lang.Object)
-T8065986b.java:17:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList<java.lang.Object>,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-T8065986b.java:21:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @435,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-T8065986b.java:25:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @516,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-T8065986b.java:29:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @603,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-5 errors
+T8065986b.java:17:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList<java.lang.Object>,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:21:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @443,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:25:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @524,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:29:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @611,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:33:24: compiler.err.cant.apply.diamond.1: java.lang.Object, (compiler.misc.diamond.non.generic: java.lang.Object)
+T8065986b.java:37:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList<java.lang.Object>,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+7 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/MultipleInferenceHooksTest.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8062373
+ * @summary Test that <>(){} works fine without verify error when there are multiple post inference hooks.
+ */
+
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.Set;
+
+public class MultipleInferenceHooksTest {
+ public static void main(String[] args) {
+ Set<String> result = Collections.newSetFromMap(new IdentityHashMap<>() {});
+ }
+}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg01.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond fails when inference violates declared bounds
* (basic test with nested class, generic/non-generic constructors)
@@ -25,5 +25,16 @@
Neg01<? extends String> n6 = new Neg01<>("", "");
Neg01<?> n7 = new Neg01<>("", "");
Foo<? super String> n8 = new Neg01<>("", "");
+
+ Neg01<String> n9 = new Neg01<>("", ""){};
+ Neg01<? extends String> n10 = new Neg01<>("", ""){};
+ Neg01<?> n11 = new Neg01<>("", ""){};
+ Neg01<? super String> n12 = new Neg01<>("", ""){};
+
+ Neg01<String> n13 = new Neg01<>(""){};
+ Neg01<? extends String> n14 = new Neg01<>(""){};
+ Neg01<?> n15 = new Neg01<>(""){};
+ Neg01<? super String> n16 = new Neg01<>(""){};
+
}
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg01.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.out Wed Apr 08 14:32:21 2015 -0700
@@ -12,4 +12,18 @@
Neg01.java:26:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
Neg01.java:27:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01<X>, null)
Neg01.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-14 errors
+Neg01.java:29:15: compiler.err.not.within.bounds: java.lang.String, X
+Neg01.java:29:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:30:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg01.java:30:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:31:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:32:15: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg01.java:32:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:34:15: compiler.err.not.within.bounds: java.lang.String, X
+Neg01.java:34:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:35:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg01.java:35:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:36:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:37:15: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg01.java:37:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+28 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg02.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond fails when inference violates declared bounds
* (test with nested class, qualified/simple type expressions)
@@ -26,6 +26,16 @@
Foo<? extends String> f6 = new Foo<>("", "");
Foo<?> f7 = new Foo<>("", "");
Foo<? super String> f8 = new Foo<>("", "");
+
+ Foo<String> f9 = new Foo<>(""){};
+ Foo<? extends String> f10 = new Foo<>(""){};
+ Foo<?> f11 = new Foo<>(""){};
+ Foo<? super String> f12 = new Foo<>(""){};
+
+ Foo<String> f13 = new Foo<>("", ""){};
+ Foo<? extends String> f14 = new Foo<>("", ""){};
+ Foo<?> f15 = new Foo<>("", ""){};
+ Foo<? super String> f16 = new Foo<>("", ""){};
}
void testQualified() {
@@ -38,5 +48,15 @@
Foo<? extends String> f6 = new Neg02.Foo<>("", "");
Foo<?> f7 = new Neg02.Foo<>("", "");
Foo<? super String> f8 = new Neg02.Foo<>("", "");
+
+ Foo<String> f9 = new Neg02.Foo<>(""){};
+ Foo<? extends String> f10 = new Neg02.Foo<>(""){};
+ Foo<?> f11 = new Neg02.Foo<>(""){};
+ Foo<? super String> f12 = new Neg02.Foo<>(""){};
+
+ Foo<String> f13 = new Neg02.Foo<>("", ""){};
+ Foo<? extends String> f14 = new Neg02.Foo<>("", ""){};
+ Foo<?> f15 = new Neg02.Foo<>("", ""){};
+ Foo<? super String> f16 = new Neg02.Foo<>("", ""){};
}
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg02.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.out Wed Apr 08 14:32:21 2015 -0700
@@ -12,18 +12,46 @@
Neg02.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
Neg02.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, X
Neg02.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:32:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:37:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-28 errors
+Neg02.java:30:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:30:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:31:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:31:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:32:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:33:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:33:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:35:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:35:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:36:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:37:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:38:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:38:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:42:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:42:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:43:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:43:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:44:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:45:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:45:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:47:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:47:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:48:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:48:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:49:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:50:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:50:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:52:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:52:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:53:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:53:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:54:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:55:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:55:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:57:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:57:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:58:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:58:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:59:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:60:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:60:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+56 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg03.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond fails when inference violates declared bounds
* (test with inner class, qualified/simple type expressions)
@@ -26,6 +26,16 @@
Foo<? extends String> f6 = new Foo<>("", "");
Foo<?> f7 = new Foo<>("", "");
Foo<? super String> f8 = new Foo<>("", "");
+
+ Foo<String> f9 = new Foo<>(""){};
+ Foo<? extends String> f10 = new Foo<>(""){};
+ Foo<?> f11 = new Foo<>(""){};
+ Foo<? super String> f12 = new Foo<>(""){};
+
+ Foo<String> f13 = new Foo<>("", ""){};
+ Foo<? extends String> f14 = new Foo<>("", ""){};
+ Foo<?> f15 = new Foo<>("", ""){};
+ Foo<? super String> f16 = new Foo<>("", ""){};
}
void testQualified_1() {
@@ -38,6 +48,16 @@
Foo<? extends String> f6 = new Neg03<U>.Foo<>("", "");
Foo<?> f7 = new Neg03<U>.Foo<>("", "");
Foo<? super String> f8 = new Neg03<U>.Foo<>("", "");
+
+ Foo<String> f9 = new Neg03<U>.Foo<>(""){};
+ Foo<? extends String> f10 = new Neg03<U>.Foo<>(""){};
+ Foo<?> f11 = new Neg03<U>.Foo<>(""){};
+ Foo<? super String> f12 = new Neg03<U>.Foo<>(""){};
+
+ Foo<String> f13 = new Neg03<U>.Foo<>("", ""){};
+ Foo<? extends String> f14 = new Neg03<U>.Foo<>("", ""){};
+ Foo<?> f15 = new Neg03<U>.Foo<>("", ""){};
+ Foo<? super String> f16 = new Neg03<U>.Foo<>("", ""){};
}
void testQualified_2(Neg03<U> n) {
@@ -50,5 +70,15 @@
Foo<? extends String> f6 = n.new Foo<>("", "");
Foo<?> f7 = n.new Foo<>("", "");
Foo<? super String> f8 = n.new Foo<>("", "");
+
+ Foo<String> f9 = n.new Foo<>(""){};
+ Foo<? extends String> f10 = n.new Foo<>(""){};
+ Foo<?> f11 = n.new Foo<>(""){};
+ Foo<? super String> f12 = n.new Foo<>(""){};
+
+ Foo<String> f13 = n.new Foo<>("", ""){};
+ Foo<? extends String> f14 = n.new Foo<>("", ""){};
+ Foo<?> f15 = n.new Foo<>("", ""){};
+ Foo<? super String> f16 = n.new Foo<>("", ""){};
}
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg03.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.out Wed Apr 08 14:32:21 2015 -0700
@@ -12,32 +12,74 @@
Neg03.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
Neg03.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, V
Neg03.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:32:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:37:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:44:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:44:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:45:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:45:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:46:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:47:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:49:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:49:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:50:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:50:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:51:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:52:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:52:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-42 errors
+Neg03.java:30:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:30:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:31:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:31:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:32:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:33:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:33:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:35:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:35:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:36:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:37:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:38:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:38:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:42:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:42:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:43:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:43:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:44:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:45:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:45:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:47:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:47:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:48:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:48:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:49:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:50:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:50:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:52:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:52:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:53:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:53:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:54:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:55:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:55:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:57:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:57:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:58:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:58:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:59:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:60:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:60:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:64:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:64:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:65:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:65:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:66:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:67:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:67:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:69:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:69:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:70:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:70:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:71:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:72:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:72:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:74:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:74:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:75:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:75:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:76:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:77:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:77:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:79:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:79:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:80:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:80:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:81:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:82:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:82:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+84 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg04.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond fails when inference violates declared bounds
* (test with local class, qualified/simple type expressions)
@@ -25,5 +25,15 @@
Foo<? extends String> n6 = new Foo<>("", "");
Foo<?> n7 = new Foo<>("", "");
Foo<? super String> n8 = new Foo<>("", "");
+
+ Foo<String> n9 = new Foo<>(""){};
+ Foo<? extends String> n10 = new Foo<>(""){};
+ Foo<?> n11 = new Foo<>(""){};
+ Foo<? super String> n12 = new Foo<>(""){};
+
+ Foo<String> n13 = new Foo<>("", ""){};
+ Foo<? extends String> n14 = new Foo<>("", ""){};
+ Foo<?> n15 = new Foo<>("", ""){};
+ Foo<? super String> n16 = new Foo<>("", ""){};
}
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg04.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.out Wed Apr 08 14:32:21 2015 -0700
@@ -12,4 +12,18 @@
Neg04.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
Neg04.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, V
Neg04.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-14 errors
+Neg04.java:29:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg04.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg04.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg04.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:34:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg04.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg04.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg04.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+28 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg05.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that usage of rare types doesn't cause spurious diamond diagnostics
* @author mcimadamore
@@ -25,6 +25,16 @@
Neg05<?>.Foo<? extends String> f6 = new Neg05.Foo<>("", "");
Neg05<?>.Foo<?> f7 = new Neg05.Foo<>("", "");
Neg05<?>.Foo<? super String> f8 = new Neg05.Foo<>("", "");
+
+ Neg05<?>.Foo<String> f9 = new Neg05.Foo<>(""){};
+ Neg05<?>.Foo<? extends String> f10 = new Neg05.Foo<>(""){};
+ Neg05<?>.Foo<?> f11 = new Neg05.Foo<>(""){};
+ Neg05<?>.Foo<? super String> f12 = new Neg05.Foo<>(""){};
+
+ Neg05<?>.Foo<String> f13 = new Neg05.Foo<>("", ""){};
+ Neg05<?>.Foo<? extends String> f14 = new Neg05.Foo<>("", ""){};
+ Neg05<?>.Foo<?> f15 = new Neg05.Foo<>("", ""){};
+ Neg05<?>.Foo<? super String> f16 = new Neg05.Foo<>("", ""){};
}
void testRare_2(Neg05 n) {
@@ -37,5 +47,15 @@
Neg05<?>.Foo<? extends String> f6 = n.new Foo<>("", "");
Neg05<?>.Foo<?> f7 = n.new Foo<>("", "");
Neg05<?>.Foo<? super String> f8 = n.new Foo<>("", "");
+
+ Neg05<?>.Foo<String> f9 = n.new Foo<>(""){};
+ Neg05<?>.Foo<? extends String> f10 = n.new Foo<>(""){};
+ Neg05<?>.Foo<?> f11 = n.new Foo<>(""){};
+ Neg05<?>.Foo<? super String> f12 = n.new Foo<>(""){};
+
+ Neg05<?>.Foo<String> f13 = n.new Foo<>("", ""){};
+ Neg05<?>.Foo<? extends String> f14 = n.new Foo<>("", ""){};
+ Neg05<?>.Foo<?> f15 = n.new Foo<>("", ""){};
+ Neg05<?>.Foo<? super String> f16 = n.new Foo<>("", ""){};
}
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg05.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.out Wed Apr 08 14:32:21 2015 -0700
@@ -6,20 +6,52 @@
Neg05.java:25:58: compiler.err.improperly.formed.type.inner.raw.param
Neg05.java:26:43: compiler.err.improperly.formed.type.inner.raw.param
Neg05.java:27:56: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:31:37: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:31:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
-Neg05.java:32:47: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:32:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
-Neg05.java:33:32: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:33:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<?>))
-Neg05.java:34:45: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:34:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
-Neg05.java:36:37: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:36:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
-Neg05.java:37:47: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:37:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
-Neg05.java:38:32: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:38:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<?>))
-Neg05.java:39:45: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:39:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
-24 errors
+Neg05.java:29:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:29:35: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:30:59: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:30:46: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:31:44: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:31:31: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:32:57: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:32:44: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:34:49: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:34:36: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:35:59: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:35:46: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:36:44: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:36:31: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:37:57: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:37:44: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:41:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:41:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:42:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:42:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:43:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:43:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:44:45: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:44:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+Neg05.java:46:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:46:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:47:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:47:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:48:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:48:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:49:45: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:49:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+Neg05.java:51:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:51:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:52:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:52:55: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:53:33: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:53:40: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:54:46: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:54:53: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+Neg05.java:56:38: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:56:45: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:57:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:57:55: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:58:33: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:58:40: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:59:46: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:59:53: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+56 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond works where LHS is supertype of RHS (nilary constructor)
* @author mcimadamore
@@ -9,9 +9,13 @@
*/
class Neg06 {
+ interface ISuperFoo<X> {}
+ interface IFoo<X extends Number> extends ISuperFoo<X> {}
static class CSuperFoo<X> {}
static class CFoo<X extends Number> extends CSuperFoo<X> {}
+ ISuperFoo<String> isf = new IFoo<>() {};
CSuperFoo<String> csf1 = new CFoo<>();
+ CSuperFoo<String> csf2 = new CFoo<>() {};
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.out Wed Apr 08 14:32:21 2015 -0700
@@ -1,2 +1,6 @@
-Neg06.java:16:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
-1 error
+Neg06.java:18:36: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
+Neg06.java:18:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: java.lang.Object, Neg06.ISuperFoo<java.lang.String>)
+Neg06.java:19:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
+Neg06.java:20:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
+Neg06.java:20:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: <any>, Neg06.CSuperFoo<java.lang.String>)
+5 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg07.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond works where LHS is supertype of RHS (1-ary constructor)
* @author mcimadamore
@@ -15,4 +15,5 @@
}
SuperFoo<String> sf1 = new Foo<>("");
+ SuperFoo<String> sf2 = new Foo<>("") {};
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg07.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.out Wed Apr 08 14:32:21 2015 -0700
@@ -1,2 +1,3 @@
Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)
-1 error
+Neg07.java:18:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)
+2 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg09.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,10 +1,10 @@
/*
* @test /nodynamiccopyright/
- * @bug 7020044
+ * @bug 7020044 8062373
*
- * @summary Check that diamond is not allowed with anonymous inner class expressions
+ * @summary Check that diamond is not allowed with anonymous inner class expressions at source < 9
* @author Maurizio Cimadamore
- * @compile/fail/ref=Neg09.out Neg09.java -XDrawDiagnostics
+ * @compile/fail/ref=Neg09.out Neg09.java -source 8 -XDrawDiagnostics
*
*/
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg09.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.out Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,7 @@
-Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class: Neg09.Member<X>)
-Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class: Neg09.Nested<X>)
-Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class: Neg09.Member<X>)
-Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class: Neg09.Nested<X>)
+- compiler.warn.source.no.bootclasspath: 1.8
+Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
+Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
+Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
+Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
4 errors
+1 warning
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg12.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,33 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary Test diamond + anonymous classes with non-denotable types
+ * @author mcimadamore
+ * @compile/fail/ref=Neg12.out Neg12.java -XDrawDiagnostics
+ *
+ */
+
+ class Neg12 {
+ static class Foo<X> {
+ Foo(X x) { }
+ }
+
+ static class DoubleFoo<X,Y> {
+ DoubleFoo(X x,Y y) { }
+ }
+
+ static class TripleFoo<X,Y,Z> {
+ TripleFoo(X x,Y y,Z z) { }
+ }
+
+ Foo<? extends Integer> fi = new Foo<>(1);
+ Foo<?> fw = new Foo<>(fi) {}; // Error.
+ Foo<?> fw1 = new Foo<>(fi); // OK.
+ Foo<? extends Double> fd = new Foo<>(3.0);
+ DoubleFoo<?,?> dw = new DoubleFoo<>(fi,fd) {}; // Error.
+ DoubleFoo<?,?> dw1 = new DoubleFoo<>(fi,fd); // OK.
+ Foo<String> fs = new Foo<>("one");
+ TripleFoo<?,?,?> tw = new TripleFoo<>(fi,fd,fs) {}; // Error.
+ TripleFoo<?,?,?> tw1 = new TripleFoo<>(fi,fd,fs); // OK.
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg12.out Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,4 @@
+Neg12.java:25:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.Foo), (compiler.misc.diamond.invalid.arg: Neg12.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>, (compiler.misc.diamond: Neg12.Foo))
+Neg12.java:28:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.DoubleFoo), (compiler.misc.diamond.invalid.args: Neg12.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg12.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg12.DoubleFoo))
+Neg12.java:31:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.TripleFoo), (compiler.misc.diamond.invalid.args: Neg12.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg12.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg12.TripleFoo))
+3 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg13.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,49 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary Test diamond + anonymous classes with abstract super type
+ * @author sadayapalam
+ * @compile/fail/ref=Neg13.out Neg13.java -XDrawDiagnostics
+ *
+ */
+class Neg13 {
+
+ static abstract class A<T> {
+ abstract void foo();
+ }
+
+ static void foo(A<String> as) {}
+
+ public static void main(String[] args) {
+
+ // Method invocation context - good <>(){}
+ foo(new A<>() {
+ public void foo() {}
+ });
+
+ // Assignment context - good <>(){}
+ A<?> aq = new A<>() {
+ public void foo() {}
+ };
+
+ // When the anonymous type subtypes an abstract class but is missing definitions for
+ // abstract methods, expect no overload resolution error, but an attribution error
+ // while attributing anonymous class body.
+
+
+ // Method invocation context - bad <>(){}
+ foo(new A<>() {
+ });
+
+ // Assignment invocation context - bad <>(){}
+ aq = new A<>() {
+ };
+
+ // Method invocation context - bad <>()
+ foo(new A<>());
+
+ // Assignment invocation context - bad <>()
+ aq = new A<>();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg13.out Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,5 @@
+Neg13.java:36:23: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg13$3, foo(), Neg13.A
+Neg13.java:40:24: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg13$4, foo(), Neg13.A
+Neg13.java:44:13: compiler.err.abstract.cant.be.instantiated: Neg13.A
+Neg13.java:47:14: compiler.err.abstract.cant.be.instantiated: Neg13.A
+4 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg14.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,49 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary Test diamond + anonymous classes with super type being an interface.
+ * @author sadayapalam
+ * @compile/fail/ref=Neg14.out Neg14.java -XDrawDiagnostics
+ *
+ */
+class Neg14 {
+
+ static interface A<T> {
+ void foo();
+ }
+
+ static void foo(A<String> as) {}
+
+ public static void main(String[] args) {
+
+ // Method invocation context - good <>(){}
+ foo(new A<>() {
+ public void foo() {}
+ });
+
+ // Assignment context - good <>(){}
+ A<?> aq = new A<>() {
+ public void foo() {}
+ };
+
+ // When the anonymous type subtypes an interface but is missing definitions for
+ // abstract methods, expect no overload resolution error, but an attribution error
+ // while attributing anonymous class body.
+
+
+ // Method invocation context - bad <>(){}
+ foo(new A<>() {
+ });
+
+ // Assignment invocation context - bad <>(){}
+ aq = new A<>() {
+ };
+
+ // Method invocation context - bad <>()
+ foo(new A<>());
+
+ // Assignment invocation context - bad <>()
+ aq = new A<>();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg14.out Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,5 @@
+Neg14.java:36:23: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg14$3, foo(), Neg14.A
+Neg14.java:40:24: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg14$4, foo(), Neg14.A
+Neg14.java:44:13: compiler.err.abstract.cant.be.instantiated: Neg14.A
+Neg14.java:47:14: compiler.err.abstract.cant.be.instantiated: Neg14.A
+4 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg15.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,66 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary Test that javac complains when a <> inferred class contains a public method that does override a supertype method.
+ * @author sadayapalam
+ * @compile/fail/ref=Neg15.out Neg15.java -XDrawDiagnostics
+ *
+ */
+
+class Neg15 {
+
+ interface Predicate<T> {
+ default boolean test(T t) {
+ System.out.println("Default method");
+ return false;
+ }
+ }
+
+
+ static void someMethod(Predicate<? extends Number> p) {
+ if (!p.test(null))
+ throw new Error("Blew it");
+ }
+
+ public static void main(String[] args) {
+
+ someMethod(new Predicate<Integer>() {
+ public boolean test(Integer n) {
+ System.out.println("Override");
+ return true;
+ }
+ boolean test(Integer n, int i) {
+ System.out.println("Override");
+ return true;
+ }
+ protected boolean test(Integer n, int i, int j) {
+ System.out.println("Override");
+ return true;
+ }
+ private boolean test(Integer n, int i, long j) {
+ System.out.println("Override");
+ return true;
+ }
+ });
+
+ someMethod(new Predicate<>() {
+ public boolean test(Integer n) { // bad.
+ System.out.println("Override");
+ return true;
+ }
+ boolean test(Integer n, int i) { // bad, package access.
+ System.out.println("Override");
+ return true;
+ }
+ protected boolean test(Integer n, int i, int j) { // bad, protected access.
+ System.out.println("Override");
+ return true;
+ }
+ private boolean test(Integer n, int i, long j) { // OK, private method.
+ System.out.println("Override");
+ return true;
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg15.out Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,4 @@
+Neg15.java:48:28: compiler.err.method.does.not.override.superclass
+Neg15.java:52:21: compiler.err.method.does.not.override.superclass
+Neg15.java:56:31: compiler.err.method.does.not.override.superclass
+3 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg16.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,36 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that javac does not recommend a diamond site that would result in error.
+ * @compile/ref=Neg16.out -Xlint:-options Neg16.java -XDrawDiagnostics -XDfind=diamond
+ */
+
+class Neg16 {
+
+ interface Predicate<T> {
+ default boolean test(T t) {
+ System.out.println("Default method");
+ return false;
+ }
+ }
+
+ static void someMethod(Predicate<? extends Number> p) {
+ if (!p.test(null))
+ throw new Error("Blew it");
+ }
+
+ public static void main(String[] args) {
+ someMethod(new Predicate<Integer>() { // cannot convert to diamond
+ public boolean test(Integer n) {
+ System.out.println("Override");
+ return true;
+ }
+ });
+ someMethod(new Predicate<Number>() { // can convert to diamond.
+ public boolean test(Number n) {
+ System.out.println("Override");
+ return true;
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg16.out Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,2 @@
+Neg16.java:29:33: compiler.warn.diamond.redundant.args
+1 warning
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg17.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that the anonymous class constructor appears to returns a Foo<T>, when it actually returns a Anon$1. (status as of now - may change in future)
+ * @compile/fail/ref=Neg17.out Neg17.java -XDrawDiagnostics
+ */
+
+import java.util.Collections;
+
+abstract class Neg17<T> {
+
+ abstract void m();
+
+ public static void main(String[] args) {
+ Collections.singletonList(new Neg17<>() { void m() {} }).get(0).m(); // good.
+ Collections.singletonList(new Neg17<>() {
+ void m() {}
+ private void n() {}
+ }).get(0).n(); // bad unknown method n()
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg17.out Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,2 @@
+Neg17.java:19:21: compiler.err.cant.resolve.location.args: kindname.method, n, , , (compiler.misc.location: kindname.class, Neg17<java.lang.Object>, null)
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg18.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that inaccessible vararg element type triggers an error during diamond inferred anonymous class instance creation.
+ * @compile/fail/ref=Neg18.out Neg18.java -XDrawDiagnostics
+ */
+
+import java.util.Collections;
+import pkg.Neg18_01;
+
+class Neg18 {
+
+ public static void main(String[] args) {
+ new Neg18_01<>() {};
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg18.out Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,3 @@
+Neg18.java:14:21: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: pkg.Neg18_01), (compiler.misc.inaccessible.varargs.type: pkg.Neg18_01.PkgPrivate, kindname.class, Neg18))
+Neg18.java:14:26: compiler.err.not.def.public.cant.access: pkg.Neg18_01.PkgPrivate, pkg.Neg18_01
+2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg19.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that when inaccessible types constitute the inferred types of <> the compiler complains.
+ * @compile/fail/ref=Neg19.out Neg19.java -XDrawDiagnostics
+ */
+
+
+
+class Neg19 {
+ public static void main(String[] args) {
+ new Neg19_01<Neg19>().foo(new Neg19_01<>()); // OK.
+ new Neg19_01<Neg19>().foo(new Neg19_01<>() {}); // ERROR.
+ }
+}
+
+class Neg19_01<T> {
+ private class Private {}
+ Neg19_01() {}
+ void foo(Neg19_01<Private> p) {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg19.out Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,2 @@
+Neg19.java:13:34: compiler.err.report.access: Neg19_01.Private, private, Neg19_01
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/pkg/Neg18_01.java Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg;
+
+public class Neg18_01<T> {
+ static class PkgPrivate {}
+ public Neg18_01 (PkgPrivate ... pp) {}
+}
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos01.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos01.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary basic test for diamond (generic/non-generic constructors)
* @author mcimadamore
@@ -48,7 +48,17 @@
Pos01<? extends Integer> p6 = new Pos01<>(1, "");
Pos01<?> p7 = new Pos01<>(1, "");
Pos01<? super Integer> p8 = new Pos01<>(1, "");
- }
+
+ Pos01<Integer> p9 = new Pos01<>(1){};
+ Pos01<? extends Integer> p10 = new Pos01<>(1){};
+ Pos01<?> p11 = new Pos01<>(1){};
+ Pos01<? super Integer> p12 = new Pos01<>(1){};
+
+ Pos01<Integer> p13 = new Pos01<>(1, ""){};
+ Pos01<? extends Integer> p14= new Pos01<>(1, ""){};
+ Pos01<?> p15 = new Pos01<>(1, ""){};
+ Pos01<? super Integer> p16 = new Pos01<>(1, ""){};
+ }
public static void main(String[] args) {
Pos01<String> p1 = new Pos01<>("");
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos02.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos02.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary basic test for diamond (simple/qualified type-expressions)
* @author mcimadamore
@@ -48,6 +48,16 @@
Foo<? extends Integer> f6 = new Foo<>(1, "");
Foo<?> f7 = new Foo<>(1, "");
Foo<? super Integer> f8 = new Foo<>(1, "");
+
+ Foo<Integer> f9 = new Foo<>(1){};
+ Foo<? extends Integer> f10 = new Foo<>(1){};
+ Foo<?> f11 = new Foo<>(1){};
+ Foo<? super Integer> f12 = new Foo<>(1){};
+
+ Foo<Integer> f13 = new Foo<>(1, ""){};
+ Foo<? extends Integer> f14 = new Foo<>(1, ""){};
+ Foo<?> f15 = new Foo<>(1, ""){};
+ Foo<? super Integer> f16 = new Foo<>(1, ""){};
}
void testQualified() {
@@ -60,6 +70,16 @@
Foo<? extends Integer> f6 = new Pos02.Foo<>(1, "");
Foo<?> f7 = new Pos02.Foo<>(1, "");
Foo<? super Integer> f8 = new Pos02.Foo<>(1, "");
+
+ Foo<Integer> f9 = new Pos02.Foo<>(1){};
+ Foo<? extends Integer> f10 = new Pos02.Foo<>(1){};
+ Foo<?> f11 = new Pos02.Foo<>(1){};
+ Foo<? super Integer> f12 = new Pos02.Foo<>(1){};
+
+ Foo<Integer> f13 = new Pos02.Foo<>(1, ""){};
+ Foo<? extends Integer> f14 = new Pos02.Foo<>(1, ""){};
+ Foo<?> f15 = new Pos02.Foo<>(1, ""){};
+ Foo<? super Integer> f16 = new Pos02.Foo<>(1, ""){};
}
public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos03.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos03.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary basic test for diamond (simple/qualified type-expressions, member inner)
* @author mcimadamore
@@ -49,6 +49,16 @@
Foo<? extends Integer> f6 = new Foo<>(1, "");
Foo<?> f7 = new Foo<>(1, "");
Foo<? super Integer> f8 = new Foo<>(1, "");
+
+ Foo<Integer> f9 = new Foo<>(1){};
+ Foo<? extends Integer> f10 = new Foo<>(1){};
+ Foo<?> f11 = new Foo<>(1){};
+ Foo<? super Integer> f12 = new Foo<>(1){};
+
+ Foo<Integer> f13 = new Foo<>(1, ""){};
+ Foo<? extends Integer> f14 = new Foo<>(1, ""){};
+ Foo<?> f15 = new Foo<>(1, ""){};
+ Foo<? super Integer> f16 = new Foo<>(1, ""){};
}
void testQualified_1() {
@@ -61,6 +71,16 @@
Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1, "");
Foo<?> f7 = new Pos03<U>.Foo<>(1, "");
Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1, "");
+
+ Foo<Integer> f9 = new Pos03<U>.Foo<>(1){};
+ Foo<? extends Integer> f10 = new Pos03<U>.Foo<>(1){};
+ Foo<?> f11 = new Pos03<U>.Foo<>(1){};
+ Foo<? super Integer> f12 = new Pos03<U>.Foo<>(1){};
+
+ Foo<Integer> f13 = new Pos03<U>.Foo<>(1, ""){};
+ Foo<? extends Integer> f14 = new Pos03<U>.Foo<>(1, ""){};
+ Foo<?> f15 = new Pos03<U>.Foo<>(1, ""){};
+ Foo<? super Integer> f16 = new Pos03<U>.Foo<>(1, ""){};
}
void testQualified_2(Pos03<U> p) {
@@ -73,6 +93,16 @@
Foo<? extends Integer> f6 = p.new Foo<>(1, "");
Foo<?> f7 = p.new Foo<>(1, "");
Foo<? super Integer> f8 = p.new Foo<>(1, "");
+
+ Foo<Integer> f9 = p.new Foo<>(1){};
+ Foo<? extends Integer> f10 = p.new Foo<>(1){};
+ Foo<?> f11 = p.new Foo<>(1){};
+ Foo<? super Integer> f12 = p.new Foo<>(1){};
+
+ Foo<Integer> f13 = p.new Foo<>(1, ""){};
+ Foo<? extends Integer> f14 = p.new Foo<>(1, ""){};
+ Foo<?> f15 = p.new Foo<>(1, ""){};
+ Foo<? super Integer> f16 = p.new Foo<>(1, ""){};
}
public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos04.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos04.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary basic test for diamond (simple/qualified type-expressions, local class)
* @author mcimadamore
@@ -48,6 +48,16 @@
Foo<? extends Integer> p6 = new Foo<>(1, "");
Foo<?> p7 = new Foo<>(1, "");
Foo<? super Integer> p8 = new Foo<>(1, "");
+
+ Foo<Integer> p9 = new Foo<>(1){};
+ Foo<? extends Integer> p10 = new Foo<>(1){};
+ Foo<?> p11 = new Foo<>(1){};
+ Foo<? super Integer> p12 = new Foo<>(1){};
+
+ Foo<Integer> p13 = new Foo<>(1, ""){};
+ Foo<? extends Integer> p14 = new Foo<>(1, ""){};
+ Foo<?> p15 = new Foo<>(1, ""){};
+ Foo<? super Integer> p16 = new Foo<>(1, ""){};
}
public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos05.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos05.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,10 @@
/*
* @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that 'complex' inference sometimes works in method context
* @author mcimadamore
- * @compile Pos05.java
*
*/
@@ -41,5 +40,11 @@
void test() {
m(new Foo<>(1));
+ m(new Foo<>(1) {});
}
+
+ public static void main(String [] args) {
+ new Pos05().test();
+ }
+
}
--- a/langtools/test/tools/javac/generics/inference/5073060/GenericsAndPackages.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/inference/5073060/GenericsAndPackages.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 5073060
+ * @bug 5073060 8075610
* @summary Package private members not found for intersection types
* @author Bruce Eckel
* see http://www.artima.com/forums/flat.jsp?forum=106&thread=136204
@@ -33,7 +33,7 @@
package code;
interface HasColor {
- java.awt.Color getColor();
+ String getColor();
}
class Dimension {
@@ -44,6 +44,6 @@
T item;
ColoredDimension(T item) { this.item = item; }
T getItem() { return item; }
- java.awt.Color f() { return item.getColor(); }
+ String f() { return item.getColor(); }
int getX() { return item.x; }
}
--- a/langtools/test/tools/javac/generics/inference/8055963/T8055963.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/generics/inference/8055963/T8055963.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,10 @@
/**
* @test
- * @bug 8055963
+ * @bug 8055963 8062373
* @summary Inference failure with nested invocation
- * @compile T8055963.java
*/
-class T8055963 {
+public class T8055963 {
static class C<T> {}
@@ -38,4 +37,8 @@
void test() {
C<String> cs = choose(new C<String>(), new C<>());
}
+
+ public static void main(String [] args) {
+ new T8055963().test();
+ }
}
--- a/langtools/test/tools/javac/lambda/8066974/T8066974.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/lambda/8066974/T8066974.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 8066974
+ * @bug 8066974 8062373
* @summary Compiler doesn't infer method's generic type information in lambda body
* @compile/fail/ref=T8066974.out -XDrawDiagnostics T8066974.java
*/
@@ -34,11 +34,13 @@
map(p->p.m(rt));
map(mapper(rt));
map(new ThrowingMapper<>(rt));
+ map(new ThrowingMapper<>(rt) {});
}
void testChecked(CheckedThrowing ct) {
map(p->p.m(ct));
map(mapper(ct));
map(new ThrowingMapper<>(ct));
+ map(new ThrowingMapper<>(ct) {});
}
}
--- a/langtools/test/tools/javac/lambda/8066974/T8066974.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/lambda/8066974/T8066974.out Wed Apr 08 14:32:21 2015 -0700
@@ -1,4 +1,5 @@
-T8066974.java:40:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
T8066974.java:41:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
-T8066974.java:42:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
-3 errors
+T8066974.java:42:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T8066974.java:43:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T8066974.java:44:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+4 errors
--- a/langtools/test/tools/javac/lambda/LocalVariableTable.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/lambda/LocalVariableTable.java Wed Apr 08 14:32:21 2015 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8025998 8026749
+ * @bug 8025998 8026749 8054220 8058227
* @summary Missing LV table in lambda bodies
* @compile -g LocalVariableTable.java
* @run main LocalVariableTable
@@ -183,7 +183,7 @@
Run1 r = (a) -> { int x = a; };
}
- @Expect({ "a", "x" })
+ @Expect({ "a", "x", "v" })
static class Lambda_Args1_Local1_Captured1 {
void m() {
int v = 0;
@@ -191,7 +191,7 @@
}
}
- @Expect({ "a1", "a2", "x1", "x2", "this" })
+ @Expect({ "a1", "a2", "x1", "x2", "this", "v1", "v2" })
static class Lambda_Args2_Local2_Captured2_this {
int v;
void m() {
@@ -204,7 +204,7 @@
}
}
- @Expect({ "e" })
+ @Expect({ "e", "c" })
static class Lambda_Try_Catch {
private static Runnable asUncheckedRunnable(Closeable c) {
return () -> {
--- a/langtools/test/tools/javac/lambda/MethodReference23.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/lambda/MethodReference23.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 8003280
+ * @bug 8003280 8075184
* @summary Add lambda tests
* check that pair of bound/non-bound constructor references is flagged as ambiguous
* @author Maurizio Cimadamore
--- a/langtools/test/tools/javac/lambda/MethodReference23.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/lambda/MethodReference23.out Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
-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))
-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)))
-MethodReference23.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23))
-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)))
+MethodReference23.java:52:19: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23)
+MethodReference23.java:53:16: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23)
+MethodReference23.java:57:19: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)
+MethodReference23.java:58:16: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)
MethodReference23.java:72:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference23.SAM21), MethodReference23, kindname.method, call3(MethodReference23.SAM22), MethodReference23
5 errors
--- a/langtools/test/tools/javac/lambda/TargetType46.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType46.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 8003280
+ * @bug 8003280 8062373
* @summary Add lambda tests
* compiler doesn't report accessibility problem due to inaccessible target
* @compile/fail/ref=TargetType46.out -XDrawDiagnostics TargetType46.java
@@ -22,6 +22,7 @@
outer.m(()->{}); //access error
outer.m(this::g); //access error
outer.m(new ArrayList<>()); //ok
+ outer.m(new ArrayList<>() {}); // access error
outer.m(Collections.emptyList()); //ok
}
--- a/langtools/test/tools/javac/lambda/TargetType46.out Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType46.out Wed Apr 08 14:32:21 2015 -0700
@@ -1,3 +1,4 @@
TargetType46.java:22:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
TargetType46.java:23:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
-2 errors
+TargetType46.java:25:16: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
+3 errors
--- a/langtools/test/tools/javac/lambda/TargetType68.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType68.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
/*
* @test
- * @bug 8010303
+ * @bug 8010303 8062373
* @summary Graph inference: missing incorporation step causes spurious inference error
- * @compile TargetType68.java
+ * @compile/fail/ref=TargetType68.out -XDrawDiagnostics TargetType68.java
*/
import java.util.*;
@@ -58,6 +58,6 @@
List<XYChart.Data<Number, Number>> data_2 = new ArrayList<>();
numberChart.getData().setAll(
Arrays.asList(new XYChart.Series<>("Data", FXCollections.observableList(data_1)),
- new XYChart.Series<>("Data", FXCollections.observableList(data_2))));
+ new XYChart.Series<>("Data", FXCollections.observableList(data_2)) {}));
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType68.out Wed Apr 08 14:32:21 2015 -0700
@@ -0,0 +1,3 @@
+TargetType68.java:61:32: compiler.err.cant.inherit.from.final: TargetType68.XYChart.Series
+TargetType68.java:61:39: compiler.err.cant.inherit.from.final: TargetType68.XYChart.Series
+2 errors
--- a/langtools/test/tools/javac/lambda/TargetType69.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType69.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8010303
+ * @bug 8010303 8062373
* @summary Graph inference: missing incorporation step causes spurious inference error
* @compile TargetType69.java
*/
@@ -47,5 +47,6 @@
void test(Function<Integer, Integer> classifier, Function<Integer, Map<Integer, List<Integer>>> coll) {
exerciseMapTabulation(coll, new GroupedMapAssertion<>(classifier));
+ exerciseMapTabulation(coll, new GroupedMapAssertion<>(classifier) {});
}
}
--- a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceNullCheckTest.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceNullCheckTest.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,12 +25,11 @@
/**
* @test
- * @bug 8024696
+ * @bug 8024696 8075752
* @summary Missing null check in bound method reference capture
*/
-import com.sun.tools.javac.util.Assert;
-import java.util.function.*;
+import java.util.function.Supplier;
public class MethodReferenceNullCheckTest {
public static void main(String[] args) {
@@ -41,7 +40,8 @@
} catch (NullPointerException npe) {
npeFired = true;
} finally {
- Assert.check(npeFired, "NPE should have been thrown");
+ if (!npeFired)
+ throw new AssertionError("NPE should have been thrown");
}
}
}
--- a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -108,9 +108,10 @@
public static List<Pair<TestKind, Hierarchy>> generateCases() {
ArrayList<Pair<TestKind,Hierarchy>> list = new ArrayList<>();
HierarchyGenerator hg = new HierarchyGenerator();
+ int i = 0;
for (TestKind tk : TestKind.values()) {
for (Hierarchy hs : tk.getHierarchy(hg)) {
- list.add(new Pair<>(tk, hs));
+ list.add((i++ % 2) == 0 ? new Pair<>(tk, hs) {} : new Pair<>(tk, hs));
}
}
return list;
--- a/langtools/test/tools/javac/scope/DupUnsharedTest.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javac/scope/DupUnsharedTest.java Wed Apr 08 14:32:21 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@
}
void runScopeContentTest() throws Exception {
- Set<Symbol> expected = Collections.newSetFromMap(new IdentityHashMap<>());
+ Set<Symbol> expected = Collections.newSetFromMap(new IdentityHashMap<>() {});
Set<Symbol> notExpected = Collections.newSetFromMap(new IdentityHashMap<>());
WriteableScope s1 = WriteableScope.create(symtab.rootPackage);
ClassSymbol acceptSym = symtab.arrayClass;
@@ -105,7 +105,7 @@
}
Set<Symbol> toSet(Iterable<Symbol> it) {
- Set<Symbol> result = Collections.newSetFromMap(new IdentityHashMap<>());
+ Set<Symbol> result = Collections.newSetFromMap(new IdentityHashMap<>() {});
for (Symbol sym : it) {
result.add(sym);
--- a/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java Wed Apr 08 13:12:52 2015 -0700
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java Wed Apr 08 14:32:21 2015 -0700
@@ -45,8 +45,6 @@
import javax.tools.ToolProvider;
import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.nio.JavacPathFileManager;
-import com.sun.tools.javac.nio.PathFileManager;
import com.sun.tools.javac.util.Context;
/**
@@ -59,7 +57,7 @@
/**
* Verify that an alternate file manager can be specified:
- * in this case, a PathFileManager.
+ * in this case, a TestFileManager.
*/
@Test
public void testFileManager() throws Exception {