This commit is contained in:
Lana Steuck 2015-04-08 14:32:21 -07:00
commit be57816f26
111 changed files with 1553 additions and 1587 deletions

View File

@ -43,7 +43,6 @@ $(eval $(call SetupJavaCompilation,BUILD_INTERIM_LANGTOOLS, \
$(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, \

View File

@ -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)

View File

@ -47,12 +47,11 @@ boot.javac.source = 8
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

View File

@ -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"

View File

@ -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" />

View File

@ -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" />

View File

@ -56,11 +56,6 @@
<type>build</type>
<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>
@ -105,19 +100,6 @@
<target>clean</target>
<target>build</target>
</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>
@ -255,18 +237,6 @@
<action name="debug">
<target>debug</target>
</action>
<action name="debug.single">
<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>
@ -331,19 +301,6 @@
</arity>
</context>
</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>
@ -416,10 +373,6 @@
</export>
<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>
@ -476,37 +429,30 @@
<subprojects/>
</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>

View File

@ -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;
}

View File

@ -40,6 +40,7 @@ import com.sun.source.tree.*;
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;

View File

@ -44,7 +44,7 @@ import com.sun.source.util.JavacTask;
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;

View File

@ -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 @@ public class Kinds {
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 @@ public class Kinds {
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() {

View File

@ -209,6 +209,9 @@ public enum Source {
public boolean allowPrivateSafeVarargs() {
return compareTo(JDK1_9) >= 0;
}
public boolean allowDiamondWithAnonymousClassCreation() {
return compareTo(JDK1_9) >= 0;
}
public boolean allowUnderscoreIdentifier() {
return compareTo(JDK1_8) <= 0;
}

View File

@ -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 @@ public class Analyzer {
final DeferredAttr deferredAttr;
final TreeMaker make;
final Names names;
private final boolean allowDiamondWithAnonymousClassCreation;
final EnumSet<AnalyzerMode> analyzerModes;
@ -112,6 +113,7 @@ public class Analyzer {
String findOpt = options.get("find");
//parse modes
Source source = Source.instance(context);
allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation();
analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source);
}
@ -210,7 +212,7 @@ public class Analyzer {
boolean match(JCNewClass tree) {
return tree.clazz.hasTag(TYPEAPPLY) &&
!TreeInfo.isDiamond(tree) &&
tree.def == null;
(tree.def == null || allowDiamondWithAnonymousClassCreation);
}
@Override

View File

@ -46,6 +46,10 @@ import com.sun.tools.javac.comp.DeferredAttr.AttrMode;
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.*;
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 @@ public class Attr extends JCTree.Visitor {
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 @@ public class Attr extends JCTree.Visitor {
//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 @@ public class Attr extends JCTree.Visitor {
} 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 @@ public class Attr extends JCTree.Visitor {
(((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 @@ public class Attr extends JCTree.Visitor {
// 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 @@ public class Attr extends JCTree.Visitor {
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 @@ public class Attr extends JCTree.Visitor {
// 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 @@ public class Attr extends JCTree.Visitor {
}
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 @@ public class Attr extends JCTree.Visitor {
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 @@ public class Attr extends JCTree.Visitor {
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;

View File

@ -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 @@ public class AttrContext {
*/
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 @@ public class AttrContext {
info.defaultSuperCallSite = defaultSuperCallSite;
info.isSerializable = isSerializable;
info.isSpeculative = isSpeculative;
info.isAnonymousDiamond = isAnonymousDiamond;
return info;
}

View File

@ -32,6 +32,8 @@ import javax.tools.JavaFileManager;
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 @@ public class Check {
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 @@ public class Check {
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 @@ public class Check {
*/
boolean allowPrivateSafeVarargs;
/** Switch: can diamond inference be used in anonymous instance creation ?
*/
boolean allowDiamondWithAnonymousClassCreation;
/** Switch: -complexinference option set?
*/
boolean complexInference;
@ -773,10 +781,9 @@ public class Check {
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 @@ public class Check {
}
}
/** 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 @@ public class Check {
* 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 @@ public class Check {
}
}
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) {

View File

@ -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 @@ public class DeferredAttr extends JCTree.Visitor {
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 @@ public class DeferredAttr extends JCTree.Visitor {
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 @@ public class DeferredAttr extends JCTree.Visitor {
* 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 @@ public class DeferredAttr extends JCTree.Visitor {
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())) {

View File

@ -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 @@ public class Enter extends JCTree.Visitor {
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;
}

View File

@ -1885,7 +1885,7 @@ public class LambdaToMethod extends TreeTranslator {
* 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 @@ public class LambdaToMethod extends TreeTranslator {
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 @@ public class LambdaToMethod extends TreeTranslator {
((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 @@ public class LambdaToMethod extends TreeTranslator {
};
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 @@ public class LambdaToMethod extends TreeTranslator {
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));
}
}

View File

@ -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 @@ public class Resolve {
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 @@ public class Resolve {
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 @@ public class Resolve {
!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 @@ public class Resolve {
? 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 @@ public class Resolve {
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 @@ public class Resolve {
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 @@ public class Resolve {
}
@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 @@ public class Resolve {
}
@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 @@ public class Resolve {
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 @@ public class Resolve {
*/
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 @@ public class Resolve {
@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 @@ public class Resolve {
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 @@ public class Resolve {
@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 @@ public class Resolve {
} 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 @@ public class Resolve {
@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 {

View File

@ -23,7 +23,7 @@
* questions.
*/
package com.sun.tools.javac.util;
package com.sun.tools.javac.file;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -60,8 +60,12 @@ 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.

View File

@ -38,7 +38,6 @@ import javax.lang.model.element.NestingKind;
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;

View File

@ -48,7 +48,6 @@ import java.util.Set;
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;
/**

View File

@ -63,8 +63,6 @@ import javax.tools.StandardJavaFileManager;
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 com.sun.tools.javac.util.ListBuffer;
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.

View File

@ -108,37 +108,23 @@ public class Locations {
// 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 class Locations {
}
}
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));
}

View File

@ -23,7 +23,7 @@
* questions.
*/
package com.sun.tools.javac.nio;
package com.sun.tools.javac.file;
import java.io.IOException;
import java.io.InputStream;
@ -40,11 +40,11 @@ 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;

View File

@ -497,13 +497,9 @@ public class Code {
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 @@ public class Code {
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

View File

@ -1860,6 +1860,13 @@ public class Gen extends JCTree.Visitor {
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 class Gen extends JCTree.Visitor {
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);

View File

@ -42,7 +42,7 @@ import com.sun.tools.javac.file.JavacFileManager;
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;

View File

@ -39,6 +39,7 @@ import javax.tools.JavaFileManager;
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.*;

View File

@ -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>
}

View File

@ -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;
}

View File

@ -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 @@ public class DocCommentParser {
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 @@ public class DocCommentParser {
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();

View File

@ -2010,6 +2010,16 @@ compiler.misc.diamond=\
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.implement=\
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\
@ -2283,6 +2289,11 @@ compiler.misc.inapplicable.method=\
########################################
# 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\

View File

@ -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 @@ public class TreeInfo {
}
}
/** 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:

View File

@ -56,17 +56,10 @@ abstract class DocFileFactory {
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);
}

View File

@ -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);
}
}
}

View File

@ -42,7 +42,7 @@ import com.sun.javadoc.*;
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;

View File

@ -46,7 +46,7 @@ import javax.tools.StandardJavaFileManager;
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;

View File

@ -2,6 +2,6 @@ class LambdaTest --
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)

View File

@ -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][]);
}
}

View File

@ -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);
}
}

View File

@ -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 class InnerClassesInAnonymousClassTest extends InnerClassesTestBase {
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<>() {});
}
}

View File

@ -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 {

View File

@ -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.*;

View File

@ -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) {};
};
}

View File

@ -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
@ -52,6 +52,30 @@ DocComment[DOC_COMMENT, pos:1
body: empty
block tags: empty
]
*/
/**
* <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
]
*/
/**

View File

@ -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 class CheckAttributedTree extends JavacTestingAbstractThreadedTest {
}
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 @@ public class CheckAttributedTree extends JavacTestingAbstractThreadedTest {
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));
}
}
}

View File

@ -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
*
*/

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 @@ public class T6996914a {
}
}
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 @@ public class T6996914a {
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 class T6996914a {
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 @@ public class T6996914a {
}
}
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");
}

View File

@ -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 Super<X,Y> {
class Test {
Super<String,Integer> ssi1 = new Super<>(1, "", 2);
Super<String,Integer> ssi2 = new Super<>(1, "", 2) {};
}

View File

@ -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 @@ class T8065986b {
this(cond ? o1 : o2);
}
T8065986b(int x) {
this(new Object<>() {});
}
T8065986b(int x, int y) {
this(new ArrayList<>() {});
}
static void m() { }
}

View File

@ -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

View File

@ -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<>() {});
}
}

View File

@ -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 @@ class Neg01<X extends Number> {
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<>(""){};
}
}

View File

@ -12,4 +12,18 @@ Neg01.java:25:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01
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

View File

@ -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 @@ class Neg02 {
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 @@ class Neg02 {
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<>("", ""){};
}
}

View File

@ -12,18 +12,46 @@ Neg02.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02
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

View File

@ -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 @@ class Neg03<U> {
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 @@ class Neg03<U> {
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 @@ class Neg03<U> {
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<>("", ""){};
}
}

View File

@ -12,32 +12,74 @@ Neg03.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03
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

View File

@ -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 @@ class Neg04 {
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<>("", ""){};
}
}

View File

@ -12,4 +12,18 @@ Neg04.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo),
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

View File

@ -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 @@ class Neg05<U> {
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 @@ class Neg05<U> {
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<>("", ""){};
}
}

View File

@ -6,20 +6,52 @@ Neg05.java:24:48: compiler.err.improperly.formed.type.inner.raw.param
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

View File

@ -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<>() {};
}

View File

@ -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

View File

@ -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 @@ class Neg07 {
}
SuperFoo<String> sf1 = new Foo<>("");
SuperFoo<String> sf2 = new Foo<>("") {};
}

View File

@ -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

View File

@ -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
*
*/

View File

@ -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

View File

@ -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.
}

View File

@ -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

View File

@ -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<>();
}
}

View File

@ -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

View File

@ -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<>();
}
}

View File

@ -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

View File

@ -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;
}
});
}
}

View File

@ -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

View File

@ -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;
}
});
}
}

View File

@ -0,0 +1,2 @@
Neg16.java:29:33: compiler.warn.diamond.redundant.args
1 warning

View File

@ -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()
}
}

View File

@ -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

View File

@ -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<>() {};
}
}

View File

@ -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

View File

@ -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) {}
}

View File

@ -0,0 +1,2 @@
Neg19.java:13:34: compiler.err.report.access: Neg19_01.Private, private, Neg19_01
1 error

View File

@ -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) {}
}

View File

@ -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 @@ public class Pos01<X> {
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<>("");

View File

@ -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 @@ public class Pos02 {
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 @@ public class Pos02 {
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) {

View File

@ -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 @@ public class Pos03<U> {
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 @@ public class Pos03<U> {
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 @@ public class Pos03<U> {
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) {

View File

@ -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 @@ public class Pos04<U> {
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) {

View File

@ -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 @@ public class Pos05 {
void test() {
m(new Foo<>(1));
m(new Foo<>(1) {});
}
public static void main(String [] args) {
new Pos05().test();
}
}

View File

@ -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 @@ class ColoredDimension<T extends Dimension & HasColor> {
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; }
}

View File

@ -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 @@ class T8055963 {
void test() {
C<String> cs = choose(new C<String>(), new C<>());
}
public static void main(String [] args) {
new T8055963().test();
}
}

View File

@ -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 @@ class T8066974 {
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) {});
}
}

View File

@ -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

View File

@ -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 @@ public class LocalVariableTable {
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 @@ public class LocalVariableTable {
}
}
@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 @@ public class LocalVariableTable {
}
}
@Expect({ "e" })
@Expect({ "e", "c" })
static class Lambda_Try_Catch {
private static Runnable asUncheckedRunnable(Closeable c) {
return () -> {

Some files were not shown because too many files have changed in this diff Show More