提交 170e305e 编写于 作者: K kizune

Merge

......@@ -240,3 +240,4 @@ af6244ba81b6b8d1bf4ab06587a2067e021e4570 jdk8-b111
3c040b04af05646878798216ebf939d27e6fe687 jdk8-b116
19de039a03a619b99f1a8b454e1618c9fa9dae66 jdk8-b117
4fd6a7ff8c068eceaaaf8bf12a394195203b99b3 jdk8-b118
43a80d75d06ed22d6942f25f067587a3be3a129d jdk8-b119
......@@ -81,6 +81,7 @@ $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d: $(PROPSOURCES) $(BUILD_TOOLS)
$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties
$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties
$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties
$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties
$(ECHO) Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles
$(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \
-compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \
......@@ -94,6 +95,9 @@ $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d: $(PROPSOURCES) $(BUILD_TOOLS)
java.util.ListResourceBundle \
-compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties \
$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.java \
java.util.ListResourceBundle \
-compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties \
$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.java \
java.util.ListResourceBundle
$(ECHO) PROPS_ARE_CREATED = yes > $@
......
#
# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 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
......@@ -23,199 +23,27 @@
# questions.
#
# Makefile for langtools: wrapper around Ant build.xml file
#
# On Solaris, the standard 'make' utility will not work with these makefiles.
# This little rule is only understood by Solaris make, and is harmless
# when seen by the GNU make tool. If using Solaris make, this causes the
# make command to fail.
#
SUN_MAKE_TEST:sh = @echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33
#
# Minimal platform defs
# Need FullPath because we can't rely on gnumake abspath, until we use v3.81
#
SYSTEM_UNAME := $(shell uname)
# Where is unwanted output to be delivered?
# On Windows, MKS uses the special file "NUL", cygwin uses the customary unix file.
ifeq ($(SYSTEM_UNAME), Windows_NT)
DEV_NULL = NUL
else
DEV_NULL = /dev/null
endif
ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME)))
USING_CYGWIN = true
endif
ifdef USING_CYGWIN
define FullPath
$(shell cygpath -a -s -m $1 2> $(DEV_NULL))
endef
else
define FullPath
$(shell cd $1 2> $(DEV_NULL) && pwd)
endef
endif
#
# Makefile args
#
ifdef QUIET
ANT_OPTIONS += -quiet
endif
ifdef VERBOSE
ANT_OPTIONS += -verbose -debug
endif
ifdef JDK_VERSION
ANT_OPTIONS += -Djdk.version=$(JDK_VERSION)
endif
ifdef FULL_VERSION
ANT_OPTIONS += -Dfull.version='$(FULL_VERSION)' # will contain spaces
endif
ifdef MILESTONE
ifneq ($(MILESTONE),fcs)
ANT_OPTIONS += -Dmilestone=$(MILESTONE)
else
ANT_OPTIONS += -Drelease=$(JDK_VERSION)
endif
endif
ifdef BUILD_NUMBER
ANT_OPTIONS += -Dbuild.number=$(BUILD_NUMBER)
# Locate this Makefile
ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))), )
makefile_path := $(CURDIR)/$(lastword $(MAKEFILE_LIST))
else
ifdef JDK_BUILD_NUMBER
ANT_OPTIONS += -Dbuild.number=$(JDK_BUILD_NUMBER)
endif
makefile_path := $(lastword $(MAKEFILE_LIST))
endif
repo_dir := $(patsubst %/make/Makefile, %, $(makefile_path))
ifeq ($(VARIANT), DBG)
ANT_OPTIONS += -Djavac.debug=true
else
ifeq ($(VARIANT), OPT)
ANT_OPTIONS += -Djavac.debug=false
endif
endif
ifeq ($(DEBUG_CLASSFILES), true)
ANT_OPTIONS += -Djavac.debug=true
ANT_OPTIONS += -Ddebug.classfiles=true
endif
# What is the name of this subsystem (langtools, corba, etc)?
subsystem_name := $(notdir $(repo_dir))
# Note: jdk/make/common/Defs.gmk uses LANGUAGE_VERSION (-source NN)
# and the somewhat misnamed CLASS_VERSION (-target NN)
ifdef TARGET_CLASS_VERSION
ANT_OPTIONS += -Djavac.target=$(TARGET_CLASS_VERSION)
# 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
ifdef JAVAC_TARGET_ARG
ANT_OPTIONS += -Djavac.target=$(JAVAC_TARGET_ARG)
endif
endif
ifdef SOURCE_LANGUAGE_VERSION
ANT_OPTIONS += -Djavac.source=$(SOURCE_LANGUAGE_VERSION)
else
ifdef JAVAC_SOURCE_ARG
ANT_OPTIONS += -Djavac.source=$(JAVAC_SOURCE_ARG)
endif
endif
ifdef ALT_BOOTDIR
ANT_OPTIONS += -Dboot.java.home=$(ALT_BOOTDIR)
ANT_JAVA_HOME = JAVA_HOME=$(ALT_BOOTDIR)
endif
# To facilitate bootstrapping, much of langtools can be compiled with (just)
# a boot JDK. However, some source files need to be compiled against
# new JDK API. In a bootstrap build, an import JDK may not be available,
# so build.xml can also build against the source files in a jdk repo,
# in which case it will automatically generate stub files for the new JDK API.
ifdef JDK_TOPDIR
ANT_OPTIONS += -Dimport.jdk=$(JDK_TOPDIR)
else
ifdef ALT_JDK_TOPDIR
ANT_OPTIONS += -Dimport.jdk=$(ALT_JDK_TOPDIR)
else
ifdef ALT_JDK_IMPORT_PATH
ANT_OPTIONS += -Dimport.jdk=$(ALT_JDK_IMPORT_PATH)
endif
endif
endif
ifdef ALT_OUTPUTDIR
OUTPUTDIR = $(ALT_OUTPUTDIR)
ANT_OPTIONS += -Dbuild.dir=$(ALT_OUTPUTDIR)/build
ANT_OPTIONS += -Ddist.dir=$(ALT_OUTPUTDIR)/dist
else
OUTPUTDIR = ..
endif
#ABS_OUTPUTDIR = $(abspath $(OUTPUTDIR))
ABS_OUTPUTDIR = $(call FullPath,$(OUTPUTDIR))
ANT_TMPDIR = $(ABS_OUTPUTDIR)/build/ant-tmp
ANT_OPTS = ANT_OPTS=-Djava.io.tmpdir='$(ANT_TMPDIR)'
ifdef FINDBUGS_HOME
ANT_OPTIONS += -Dfindbugs.home=$(FINDBUGS_HOME)
$(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
ifdef ANT_HOME
ANT = $(ANT_HOME)/bin/ant
ifneq ($(shell test -x $(ANT) && echo OK), OK)
$(error $(ANT) not found -- please update ANT_HOME)
endif
else
ANT = ant
ifneq ($(shell test -x "`which $(ANT)`" && echo OK), OK)
$(error 'ant' not found -- please set ANT_HOME or put 'ant' on your PATH)
endif
endif
# Default target and expected 'do everything' target
all: build
# Standard make clobber target
clobber: clean
# All ant targets of interest
ANT_TARGETS = build clean sanity post-sanity diagnostics build-all-tools # for now
# Create diagnostics log (careful, ant 1.8.0 -diagnostics always does an exit 1)
$(OUTPUTDIR)/build/ant-diagnostics.log:
@mkdir -p $(OUTPUTDIR)/build $(ANT_TMPDIR)
@$(RM) $@
$(ANT_JAVA_HOME) $(ANT_OPTS) $(ANT) -diagnostics > $@ ; \
$(ANT_JAVA_HOME) $(ANT_OPTS) $(ANT) -version >> $@
# Create a make target for each
$(ANT_TARGETS): $(OUTPUTDIR)/build/ant-diagnostics.log
@ mkdir -p $(OUTPUTDIR)/build $(ANT_TMPDIR)
$(ANT_JAVA_HOME) $(ANT_OPTS) $(ANT) $(ANT_OPTIONS) $@
#-------------------------------------------------------------------
#
# Targets for Oracle's internal JPRT build system
CD = cd
ZIP = zip
JPRT_ARCHIVE_BUNDLE=$(ABS_OUTPUTDIR)/$(JPRT_BUILD_FLAVOR)-bundle.zip
jprt_build_product jprt_build_debug jprt_build_fastdebug: all
( $(CD) $(OUTPUTDIR) && \
$(ZIP) -q -r $(JPRT_ARCHIVE_BUNDLE) build dist )
#-------------------------------------------------------------------
# Declare these phony (not filenames)
.PHONY: $(ANT_TARGETS) all clobber \
jprt_build_product jprt_build_debug jprt_build_fastdebug
all:
@$(MAKE) -f $(top_level_makefile) $(subsystem_name)
#
# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# 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.
#
# Properties for jprt
# Locked down to jdk8
jprt.tools.default.release=jdk8
# The different build flavors we want, we override here so we just get these 2
jprt.build.flavors=product,fastdebug
# Standard list of jprt build targets for this source tree
jprt.build.targets= \
solaris_sparcv9_5.10-{product|fastdebug}, \
solaris_x64_5.10-{product|fastdebug}, \
linux_i586_2.6-{product|fastdebug}, \
linux_x64_2.6-{product|fastdebug}, \
macosx_x64_10.7-{product|fastdebug}, \
windows_i586_6.1-{product|fastdebug}, \
windows_x64_6.1-{product|fastdebug}
# Test target list (no fastdebug & limited c2 testing)
jprt.my.test.target.set= \
solaris_sparcv9_5.10-product-c2-TESTNAME, \
solaris_x64_5.10-product-c2-TESTNAME, \
linux_i586_2.6-product-{c1|c2}-TESTNAME, \
linux_x64_2.6-product-c2-TESTNAME, \
macosx_x64_10.7-product-c2-TESTNAME, \
windows_i586_6.1-product-c1-TESTNAME, \
windows_x64_6.1-product-c2-TESTNAME
# Default test targets
jprt.make.rule.test.targets= \
${jprt.my.test.target.set:TESTNAME=jtreg}
# Directories to be excluded from the source bundles
jprt.bundle.exclude.src.dirs=build dist webrev
# Test target list (no fastdebug & limited c2 testing)
jprt.my.test.target.set= \
solaris_sparcv9_5.10-product-c2-TESTNAME, \
solaris_x64_5.10-product-c2-TESTNAME, \
linux_i586_2.6-product-{c1|c2}-TESTNAME, \
linux_x64_2.6-product-c2-TESTNAME, \
macosx_x64_10.7-product-c2-TESTNAME, \
windows_i586_6.1-product-c1-TESTNAME, \
windows_x64_6.1-product-c2-TESTNAME
# Default test targets
jprt.make.rule.test.targets= \
${jprt.my.test.target.set:TESTNAME=jtreg}
#
# Copyright (c) 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.
#
# Locate this Makefile
ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))), )
makefile_path := $(CURDIR)/$(lastword $(MAKEFILE_LIST))
else
makefile_path := $(lastword $(MAKEFILE_LIST))
endif
repo_dir := $(patsubst %/makefiles/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)/../common/makefiles/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)
......@@ -204,12 +204,27 @@ public class ConfigurationImpl extends Configuration {
"com.sun.tools.doclets.formats.html.resources.standard");
}
private final String versionRBName = "com.sun.tools.javadoc.resources.version";
private ResourceBundle versionRB;
/**
* Return the build date for the doclet.
*/
@Override
public String getDocletSpecificBuildDate() {
return BUILD_DATE;
if (versionRB == null) {
try {
versionRB = ResourceBundle.getBundle(versionRBName);
} catch (MissingResourceException e) {
return BUILD_DATE;
}
}
try {
return versionRB.getString("release");
} catch (MissingResourceException e) {
return BUILD_DATE;
}
}
/**
......
......@@ -331,7 +331,7 @@ public abstract class HtmlDocWriter extends HtmlWriter {
if (timestamp) {
Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
Date today = calendar.getTime();
text += " ("+ ConfigurationImpl.BUILD_DATE + ") on " + today;
text += " ("+ configuration.getDocletSpecificBuildDate() + ") on " + today;
}
return new Comment(text);
}
......
......@@ -293,7 +293,7 @@ public class Flags {
ExtendedStandardFlags = (long)StandardFlags | DEFAULT,
ModifierFlags = ((long)StandardFlags & ~INTERFACE) | DEFAULT,
InterfaceMethodMask = ABSTRACT | STATIC | PUBLIC | STRICTFP | DEFAULT,
AnnotationTypeElementMask = FINAL | ABSTRACT | PUBLIC | STRICTFP,
AnnotationTypeElementMask = ABSTRACT | PUBLIC,
LocalVarFlags = FINAL | PARAMETER;
......
......@@ -970,13 +970,6 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
public boolean allInterfaces;
public enum IntersectionKind {
EXPLICIT,
IMPLICT;
}
public IntersectionKind intersectionKind;
public IntersectionClassType(List<Type> bounds, ClassSymbol csym, boolean allInterfaces) {
super(Type.noType, List.<Type>nil(), csym);
this.allInterfaces = allInterfaces;
......@@ -1008,9 +1001,7 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
@Override
public <R, P> R accept(TypeVisitor<R, P> v, P p) {
return intersectionKind == IntersectionKind.EXPLICIT ?
v.visitIntersection(this, p) :
v.visitDeclared(this, p);
return v.visitIntersection(this, p);
}
}
......
......@@ -933,7 +933,8 @@ public class Attr extends JCTree.Visitor {
chk.validate(tree.typarams, localEnv);
// Check that result type is well-formed.
chk.validate(tree.restype, localEnv);
if (tree.restype != null && !tree.restype.type.hasTag(VOID))
chk.validate(tree.restype, localEnv);
// Check that receiver type is well-formed.
if (tree.recvparam != null) {
......@@ -3982,10 +3983,6 @@ public class Attr extends JCTree.Visitor {
return bounds.head.type;
} else {
Type owntype = types.makeCompoundType(TreeInfo.types(bounds));
if (tree.hasTag(TYPEINTERSECTION)) {
((IntersectionClassType)owntype).intersectionKind =
IntersectionClassType.IntersectionKind.EXPLICIT;
}
// ... the variable's bound is a class type flagged COMPOUND
// (see comment for TypeVar.bound).
// In this case, generate a class tree that represents the
......
......@@ -1326,6 +1326,14 @@ public class Check {
tree.underlyingType.accept(this);
}
@Override
public void visitTypeIdent(JCPrimitiveTypeTree that) {
if (that.type.hasTag(TypeTag.VOID)) {
log.error(that.pos(), "void.not.allowed.here");
}
super.visitTypeIdent(that);
}
/** Default visitor method: do nothing.
*/
@Override
......
......@@ -357,9 +357,11 @@ public class LambdaToMethod extends TreeTranslator {
//first determine the method symbol to be used to generate the sam instance
//this is either the method reference symbol, or the bridged reference symbol
Symbol refSym = localContext.needsBridge() ?
localContext.bridgeSym :
tree.sym;
Symbol refSym = localContext.needsBridge()
? localContext.bridgeSym
: localContext.isSignaturePolymorphic()
? localContext.sigPolySym
: tree.sym;
//build the bridge method, if needed
if (localContext.needsBridge()) {
......@@ -1995,6 +1997,7 @@ public class LambdaToMethod extends TreeTranslator {
final boolean isSuper;
final Symbol bridgeSym;
final Symbol sigPolySym;
ReferenceTranslationContext(JCMemberReference tree) {
super(tree);
......@@ -2004,6 +2007,12 @@ public class LambdaToMethod extends TreeTranslator {
referenceBridgeName(), null,
owner.enclClass())
: null;
this.sigPolySym = isSignaturePolymorphic()
? makePrivateSyntheticMethod(tree.sym.flags(),
tree.sym.name,
bridgedRefSig(),
tree.sym.enclClass())
: null;
if (dumpLambdaToMethodStats) {
String key = bridgeSym == null ?
"mref.stat" : "mref.stat.1";
......@@ -2105,6 +2114,15 @@ public class LambdaToMethod extends TreeTranslator {
types.erasure(owner.enclClass().asType()));
}
/**
* Signature polymorphic methods need special handling.
* e.g. MethodHandle.invoke() MethodHandle.invokeExact()
*/
final boolean isSignaturePolymorphic() {
return tree.sym.kind == MTH &&
types.isSignaturePolymorphic((MethodSymbol)tree.sym);
}
/**
* Does this reference needs a bridge (i.e. var args need to be
* expanded or "super" is used)
......
......@@ -1378,11 +1378,14 @@ public class Lower extends TreeTranslator {
ref = make.Ident(sym);
args = make.Idents(md.params);
} else {
Symbol msym = sym;
if (sym.owner.isInterface()) {
msym = msym.clone(types.supertype(accessor.owner.type).tsym);
JCExpression site = make.Ident(md.params.head);
if (acode % 2 != 0) {
//odd access codes represent qualified super accesses - need to
//emit reference to the direct superclass, even if the refered
//member is from an indirect superclass (JLS 13.1)
site.setType(types.erasure(types.supertype(vsym.owner.enclClass().type)));
}
ref = make.Select(make.Ident(md.params.head), msym);
ref = make.Select(site, sym);
args = make.Idents(md.params.tail);
}
JCStatement stat; // The statement accessing the private symbol.
......
......@@ -1174,9 +1174,8 @@ public class ClassWriter extends ClassFile {
}
// counter for number of generic local variables
int nGenericVars = 0;
if (code.varBufferSize > 0) {
if (code.varDebugInfo && code.varBufferSize > 0) {
int nGenericVars = 0;
int alenIdx = writeAttr(names.LocalVariableTable);
databuf.appendChar(code.getLVTSize());
for (int i=0; i<code.varBufferSize; i++) {
......@@ -1195,37 +1194,38 @@ public class ClassWriter extends ClassFile {
Type vartype = sym.erasure(types);
databuf.appendChar(pool.put(typeSig(vartype)));
databuf.appendChar(var.reg);
if (needsLocalVariableTypeEntry(var.sym.type))
if (needsLocalVariableTypeEntry(var.sym.type)) {
nGenericVars++;
}
}
}
endAttr(alenIdx);
acount++;
}
if (nGenericVars > 0) {
int alenIdx = writeAttr(names.LocalVariableTypeTable);
databuf.appendChar(nGenericVars);
int count = 0;
if (nGenericVars > 0) {
alenIdx = writeAttr(names.LocalVariableTypeTable);
databuf.appendChar(nGenericVars);
int count = 0;
for (int i=0; i<code.varBufferSize; i++) {
Code.LocalVar var = code.varBuffer[i];
VarSymbol sym = var.sym;
if (!needsLocalVariableTypeEntry(sym.type))
continue;
for (Code.LocalVar.Range r : var.aliveRanges) {
// write variable info
databuf.appendChar(r.start_pc);
databuf.appendChar(r.length);
databuf.appendChar(pool.put(sym.name));
databuf.appendChar(pool.put(typeSig(sym.type)));
databuf.appendChar(var.reg);
count++;
for (int i=0; i<code.varBufferSize; i++) {
Code.LocalVar var = code.varBuffer[i];
VarSymbol sym = var.sym;
if (!needsLocalVariableTypeEntry(sym.type))
continue;
for (Code.LocalVar.Range r : var.aliveRanges) {
// write variable info
databuf.appendChar(r.start_pc);
databuf.appendChar(r.length);
databuf.appendChar(pool.put(sym.name));
databuf.appendChar(pool.put(typeSig(sym.type)));
databuf.appendChar(var.reg);
count++;
}
}
Assert.check(count == nGenericVars);
endAttr(alenIdx);
acount++;
}
Assert.check(count == nGenericVars);
endAttr(alenIdx);
acount++;
}
if (code.stackMapBufferSize > 0) {
......
......@@ -2420,7 +2420,7 @@ public class Gen extends JCTree.Visitor {
if (isInvokeDynamic(sym)) {
result = items.makeDynamicItem(sym);
return;
} else if (!accessSuper) {
} else {
sym = binaryQualifier(sym, tree.selected.type);
}
if ((sym.flags() & STATIC) != 0) {
......
......@@ -280,7 +280,7 @@ public class DocCommentParser {
try {
nextChar();
if (isIdentifierStart(ch)) {
Name name = readIdentifier();
Name name = readTagName();
TagParser tp = tagParsers.get(name);
if (tp == null) {
List<DCTree> content = blockContent();
......@@ -329,7 +329,7 @@ public class DocCommentParser {
try {
nextChar();
if (isIdentifierStart(ch)) {
Name name = readIdentifier();
Name name = readTagName();
skipWhitespace();
TagParser tp = tagParsers.get(name);
......@@ -905,6 +905,14 @@ public class DocCommentParser {
return names.fromChars(buf, start, bp - start);
}
protected Name readTagName() {
int start = bp;
nextChar();
while (bp < buflen && (Character.isUnicodeIdentifierPart(ch) || ch == '.'))
nextChar();
return names.fromChars(buf, start, bp - start);
}
protected boolean isJavaIdentifierStart(char ch) {
return Character.isJavaIdentifierStart(ch);
}
......
......@@ -39,6 +39,7 @@ import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type.ClassType;
import com.sun.tools.javac.comp.Check;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.util.Context;
......@@ -146,6 +147,9 @@ public class DocEnv {
chk = Check.instance(context);
types = Types.instance(context);
fileManager = context.get(JavaFileManager.class);
if (fileManager instanceof JavacFileManager) {
((JavacFileManager)fileManager).setSymbolFileEnabled(false);
}
// Default. Should normally be reset with setLocale.
this.doclocale = new DocLocale(this, "", breakiterator);
......
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -49,14 +49,6 @@ import javax.lang.model.util.Types;
* Types#directSupertypes(TypeMirror)} method. This returns the
* supertypes with any type arguments substituted in.
*
* <p> This interface is also used to represent intersection types.
* An intersection type is implicit in a program rather than being
* explictly declared. For example, the bound of the type parameter
* {@code <T extends Number & Runnable>}
* is an intersection type. It is represented by a {@code DeclaredType}
* with {@code Number} as its superclass and {@code Runnable} as its
* lone superinterface.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ah&eacute;
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -30,9 +30,15 @@ import java.util.List;
/**
* Represents an intersection type.
*
* As of the {@link javax.lang.model.SourceVersion#RELEASE_8
* RELEASE_8} source version, intersection types can appear as the target type
* of a cast expression.
* <p>An intersection type can be either implicitly or explicitly
* declared in a program. For example, the bound of the type parameter
* {@code <T extends Number & Runnable>} is an (implicit) intersection
* type. As of {@link javax.lang.model.SourceVersion#RELEASE_8
* RELEASE_8}, this is represented by an {@code IntersectionType} with
* {@code Number} and {@code Runnable} as its bounds. Also as of the
* {@link javax.lang.model.SourceVersion#RELEASE_8 RELEASE_8},
* intersection types can explicitly appear as the target type of a
* cast expression.
*
* @since 1.8
*/
......
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -62,10 +62,9 @@ public interface TypeVariable extends ReferenceType {
* <p> If this type variable was declared with no explicit
* upper bounds, the result is {@code java.lang.Object}.
* If it was declared with multiple upper bounds,
* the result is an intersection type (modeled as a
* {@link DeclaredType}).
* Individual bounds can be found by examining the result's
* {@linkplain Types#directSupertypes(TypeMirror) supertypes}.
* the result is an {@linkplain IntersectionType intersection type};
* individual bounds can be found by examining the result's
* {@linkplain IntersectionType#getBounds() bounds}.
*
* @return the upper bound of this type variable
*/
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8027977
* @summary Test to verify javadoc executes without CompletionFailure exception.
* @author Bhavesh Patel
* @library ../lib/
* @build JavadocTester TestCompletionFailure
* @run main TestCompletionFailure
*/
public class TestCompletionFailure extends JavadocTester {
private static final String BUG_ID = "8027977";
//Input for string search tests.
private static final String[][] NEGATED_TEST = {
{ERROR_OUTPUT, "TestCompletionFailure: error - " +
"com.sun.tools.javac.code.Symbol$CompletionFailure: class file for " +
"sun.util.locale.provider.LocaleProviderAdapter not found"
}
};
private static final String[] ARGS = new String[] {
"-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) throws Exception {
TestCompletionFailure tester = new TestCompletionFailure();
run(tester, ARGS, NO_TEST, NEGATED_TEST);
tester.printSummary();
}
/**
* {@inheritDoc}
*/
public String getBugId() {
return BUG_ID;
}
/**
* {@inheritDoc}
*/
public String getBugName() {
return getClass().getName();
}
}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg1;
import java.text.NumberFormat;
public abstract class NumberFormatTest extends NumberFormat { }
/*
* @test /nodynamiccopyright/
* @bug 8006248
* @bug 8006248 8028318
* @summary DocLint should report unknown tags
* @build DocLintTester
* @run main DocLintTester CustomTagTest.java
* @run main DocLintTester -XcustomTags: -ref CustomTagTest.out CustomTagTest.java
* @run main DocLintTester -XcustomTags:customTag -ref CustomTagTestWithOption.out CustomTagTest.java
* @run main DocLintTester -XcustomTags:customTag,anotherCustomTag -ref CustomTagTestWithOption.out CustomTagTest.java
* @run main DocLintTester -XcustomTags:customTag,custom.tag -ref CustomTagTestWithOption.out CustomTagTest.java
* @run main DocLintTester -XcustomTags:customTag,custom.tag,anotherCustomTag -ref CustomTagTestWithOption.out CustomTagTest.java
* @author bpatel
*/
/**
* @customTag Text for a custom tag.
* @custom.tag Text for another custom tag.
* @unknownTag Text for an unknown tag.
*/
public class CustomTagTest {
......
CustomTagTest.java:14: error: unknown tag: customTag
* @customTag Text for a custom tag.
^
CustomTagTest.java:15: error: unknown tag: unknownTag
CustomTagTest.java:15: error: unknown tag: custom.tag
* @custom.tag Text for another custom tag.
^
CustomTagTest.java:16: error: unknown tag: unknownTag
* @unknownTag Text for an unknown tag.
^
2 errors
3 errors
CustomTagTest.java:15: error: unknown tag: unknownTag
CustomTagTest.java:16: error: unknown tag: unknownTag
* @unknownTag Text for an unknown tag.
^
1 error
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8028504
* @summary javac generates LocalVariableTable even with -g:none
* @compile -g:none DontGenerateLVTForGNoneOpTest.java
* @run main DontGenerateLVTForGNoneOpTest
*/
import java.io.File;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.nio.file.Paths;
import com.sun.tools.classfile.Attribute;
import com.sun.tools.classfile.ClassFile;
import com.sun.tools.classfile.Code_attribute;
import com.sun.tools.classfile.Method;
public class DontGenerateLVTForGNoneOpTest {
public static void main(String[] args) throws Exception {
new DontGenerateLVTForGNoneOpTest().run();
}
void run() throws Exception {
checkClassFile(new File(Paths.get(System.getProperty("test.classes"),
this.getClass().getName() + ".class").toUri()));
}
void checkClassFile(final File cfile) throws Exception {
ClassFile classFile = ClassFile.read(cfile);
for (Method method : classFile.methods) {
Code_attribute code = (Code_attribute)method.attributes.get(Attribute.Code);
if (code != null) {
if (code.attributes.get(Attribute.LocalVariableTable) != null) {
throw new AssertionError("LVT shouldn't be generated for g:none");
}
}
}
}
public void bar() {
try {
System.out.println();
} catch(@TA Exception e) {
} catch(Throwable t) {}
}
@Target(ElementType.TYPE_USE)
@interface TA {}
}
/*
* @test /nodynamiccopyright/
* @bug 8028428
* @summary Test that only 'public' and 'abstract' elements compile
* @compile/fail/ref=AnnotationTypeElementModifiers.out -XDrawDiagnostics AnnotationTypeElementModifiers.java
*/
public @interface AnnotationTypeElementModifiers {
// First 4 should work
public int A();
public int AA() default 1;
abstract int B();
abstract int BB() default 1;
// These shouldn't work
private int C();
private int CC() default 1;
protected int D();
protected int DD() default 1;
static int E();
static int EE() default 1;
final int F();
final int FF() default 1;
synchronized int H();
synchronized int HH() default 1;
volatile int I();
volatile int II() default 1;
transient int J();
transient int JJ() default 1;
native int K();
native int KK() default 1;
strictfp float L();
strictfp float LL() default 0.1f;
default int M();
default int MM() default 1;
}
AnnotationTypeElementModifiers.java:17:17: compiler.err.mod.not.allowed.here: private
AnnotationTypeElementModifiers.java:18:17: compiler.err.mod.not.allowed.here: private
AnnotationTypeElementModifiers.java:20:19: compiler.err.mod.not.allowed.here: protected
AnnotationTypeElementModifiers.java:21:19: compiler.err.mod.not.allowed.here: protected
AnnotationTypeElementModifiers.java:23:16: compiler.err.mod.not.allowed.here: static
AnnotationTypeElementModifiers.java:24:16: compiler.err.mod.not.allowed.here: static
AnnotationTypeElementModifiers.java:26:15: compiler.err.mod.not.allowed.here: final
AnnotationTypeElementModifiers.java:27:15: compiler.err.mod.not.allowed.here: final
AnnotationTypeElementModifiers.java:29:22: compiler.err.mod.not.allowed.here: synchronized
AnnotationTypeElementModifiers.java:30:22: compiler.err.mod.not.allowed.here: synchronized
AnnotationTypeElementModifiers.java:32:18: compiler.err.mod.not.allowed.here: volatile
AnnotationTypeElementModifiers.java:33:18: compiler.err.mod.not.allowed.here: volatile
AnnotationTypeElementModifiers.java:35:19: compiler.err.mod.not.allowed.here: transient
AnnotationTypeElementModifiers.java:36:19: compiler.err.mod.not.allowed.here: transient
AnnotationTypeElementModifiers.java:38:16: compiler.err.mod.not.allowed.here: native
AnnotationTypeElementModifiers.java:39:16: compiler.err.mod.not.allowed.here: native
AnnotationTypeElementModifiers.java:41:20: compiler.err.mod.not.allowed.here: strictfp
AnnotationTypeElementModifiers.java:42:20: compiler.err.mod.not.allowed.here: strictfp
AnnotationTypeElementModifiers.java:44:17: compiler.err.mod.not.allowed.here: default
AnnotationTypeElementModifiers.java:45:17: compiler.err.mod.not.allowed.here: default
20 errors
/* @test /nodynamiccopyright/
* @bug 8026374
* @summary Cannot use void as a variable type
* @compile/fail/ref=MethodVoidParameter.out -XDrawDiagnostics MethodVoidParameter.java
*/
public class MethodVoidParameter {
void method(void v) { }
void method(void... v) { }
}
MethodVoidParameter.java:7:17: compiler.err.void.not.allowed.here
MethodVoidParameter.java:8:17: compiler.err.void.not.allowed.here
2 errors
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package base;
public class Base extends PackagePrivate { }
class PackagePrivate {
protected int refTobaseBase() {
return 0;
}
protected int refTotestOtherPackageTest() {
return 0;
}
protected int refTotestTarget11() {
return 0;
}
protected int refTotestCurPackagePrivateExt11() {
return 0;
}
protected int refTobaseBase;
protected int refTotestOtherPackageTest;
protected int refTotestTarget11;
protected int refTotestCurPackagePrivateExt11;
}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8027789
* @summary check that the direct superclass is used as the site when calling
* a superclass' method
* @compile Base.java NonDirectSuper.java
* @compile -source 1.2 -target 1.1 Target11.java
* @run main test.NonDirectSuper
*/
package test;
import java.io.File;
import com.sun.tools.classfile.Attribute;
import com.sun.tools.classfile.ClassFile;
import com.sun.tools.classfile.Code_attribute;
import com.sun.tools.classfile.ConstantPool.CPRefInfo;
import com.sun.tools.classfile.Instruction;
import com.sun.tools.classfile.Method;
import com.sun.tools.classfile.Opcode;
public class NonDirectSuper {
public static void main(String... args) {
new NonDirectSuper().run();
}
void run() {
String workDir = System.getProperty("test.classes");
File testPackage = new File(workDir, "test");
for (File clazz : testPackage.listFiles()) {
if ("NonDirectSuper.class".equals(clazz.getName())) continue;
verifyInvokeSpecialRefToObject(clazz);
}
}
void verifyInvokeSpecialRefToObject(File clazz) {
try {
final ClassFile cf = ClassFile.read(clazz);
for (Method m : cf.methods) {
Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code);
for (Instruction instr : codeAttr.getInstructions()) {
if (instr.getOpcode() == Opcode.INVOKESPECIAL ||
instr.getOpcode() == Opcode.INVOKEVIRTUAL) {
int pc_index = instr.getShort(1);
CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index);
String className = ref.getClassName();
String methodName = ref.getNameAndTypeInfo().getName();
if (methodName.equals("toString")) {
if (!className.equals("java/lang/Object"))
throw new IllegalStateException("Must directly refer to j.l.Object");
} else if (methodName.startsWith("refTo")) {
String expectedClass = methodName.substring("refTo".length());
if (!className.replace("/", "").equals(expectedClass)) {
throw new IllegalStateException("Unexpected reference to: " +
className + ", should be " + expectedClass);
}
}
}
if (instr.getOpcode() == Opcode.GETFIELD ||
instr.getOpcode() == Opcode.PUTFIELD) {
int pc_index = instr.getShort(1);
CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index);
String className = ref.getClassName();
String fieldName = ref.getNameAndTypeInfo().getName();
if (fieldName.startsWith("refTo")) {
String expectedClass = fieldName.substring("refTo".length());
if (!className.replace("/", "").equals(expectedClass)) {
throw new IllegalStateException("Unexpected reference to: " +
className + ", should be " + expectedClass);
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
throw new Error("error reading " + clazz +": " + e);
}
}
}
class OtherPackageTest extends base.Base {
void run() {
new Runnable() {
public void run() {
OtherPackageTest.super.refTobaseBase();
OtherPackageTest.super.refTobaseBase = OtherPackageTest.super.refTobaseBase + 1;
OtherPackageTest.super.toString();
refTotestOtherPackageTest();
refTotestOtherPackageTest = refTotestOtherPackageTest + 1;
OtherPackageTest.this.refTotestOtherPackageTest();
OtherPackageTest.this.refTotestOtherPackageTest =
OtherPackageTest.this.refTotestOtherPackageTest + 1;
}
}.run();
super.refTobaseBase();
super.refTobaseBase = super.refTobaseBase + 1;
super.toString();
OtherPackageTest.super.refTobaseBase();
OtherPackageTest.super.refTobaseBase = OtherPackageTest.super.refTobaseBase + 1;
OtherPackageTest.super.toString();
refTotestOtherPackageTest();
refTotestOtherPackageTest = refTotestOtherPackageTest + 1;
}
static class InnerBase {
private void refTotestOtherPackageTest$InnerBase() { }
}
static class InnerTest extends InnerBase {
void run() {
new Runnable() {
public void run() {
InnerTest.super.refTotestOtherPackageTest$InnerBase();
}
}.run();
super.refTotestOtherPackageTest$InnerBase();
InnerTest.super.refTotestOtherPackageTest$InnerBase();
}
}
}
class CurPackagePrivateBase {
void refTotestCurPackagePrivateExt() { }
void refTotestCurPackagePrivateTest() { }
int refTotestCurPackagePrivateExt;
int refTotestCurPackagePrivateTest;
}
class CurPackagePrivateExt extends CurPackagePrivateBase {
}
class CurPackagePrivateTest extends CurPackagePrivateExt {
void run() {
new Runnable() {
public void run() {
CurPackagePrivateTest.super.refTotestCurPackagePrivateExt();
CurPackagePrivateTest.super.refTotestCurPackagePrivateExt =
CurPackagePrivateTest.super.refTotestCurPackagePrivateExt + 1;
CurPackagePrivateTest.this.refTotestCurPackagePrivateTest();
CurPackagePrivateTest.this.refTotestCurPackagePrivateTest =
CurPackagePrivateTest.this.refTotestCurPackagePrivateTest + 1;
refTotestCurPackagePrivateTest();
refTotestCurPackagePrivateTest = refTotestCurPackagePrivateTest + 1;
}
}.run();
super.refTotestCurPackagePrivateExt();
super.refTotestCurPackagePrivateExt = super.refTotestCurPackagePrivateExt + 1;
CurPackagePrivateTest.super.refTotestCurPackagePrivateExt();
CurPackagePrivateTest.super.refTotestCurPackagePrivateExt =
CurPackagePrivateTest.super.refTotestCurPackagePrivateExt + 1;
refTotestCurPackagePrivateTest();
refTotestCurPackagePrivateTest = refTotestCurPackagePrivateTest + 1;
}
}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test;
class Target11 extends CurPackagePrivateExt11 {
void run() {
new Runnable() {
public void run() {
Target11.super.refTotestCurPackagePrivateBase11();
Target11.super.refTotestCurPackagePrivateBase11 =
Target11.super.refTotestCurPackagePrivateBase11 + 1;
Target11.super.refTotestCurPackagePrivateExt11();
Target11.super.refTotestCurPackagePrivateExt11 =
Target11.super.refTotestCurPackagePrivateExt11 + 1;
Target11.super.toString();
refTotestCurPackagePrivateBase11();
refTotestCurPackagePrivateBase11 =
refTotestCurPackagePrivateBase11 + 1;
refTotestTarget11();
refTotestTarget11 = refTotestTarget11 + 1;
Target11.this.refTotestCurPackagePrivateBase11();
Target11.this.refTotestCurPackagePrivateBase11 =
Target11.this.refTotestCurPackagePrivateBase11 + 1;
Target11.this.refTotestTarget11();
Target11.this.refTotestTarget11 =
Target11.this.refTotestTarget11 + 1;
}
}.run();
super.refTotestCurPackagePrivateBase11();
super.refTotestCurPackagePrivateBase11 =
super.refTotestCurPackagePrivateBase11 + 1;
super.refTotestCurPackagePrivateExt11();
super.refTotestCurPackagePrivateExt11 =
super.refTotestCurPackagePrivateExt11 + 1;
super.toString();
Target11.super.refTotestCurPackagePrivateBase11();
Target11.super.refTotestCurPackagePrivateBase11 =
Target11.super.refTotestCurPackagePrivateBase11 + 1;
Target11.super.refTotestCurPackagePrivateExt11();
Target11.super.refTotestCurPackagePrivateExt11 =
Target11.super.refTotestCurPackagePrivateExt11 + 1;
refTotestCurPackagePrivateBase11();
refTotestCurPackagePrivateBase11 = refTotestCurPackagePrivateBase11 + 1;
refTotestTarget11 = refTotestTarget11 + 1;
}
}
class CurPackagePrivateBase11 extends base.Base {
protected void refTotestCurPackagePrivateBase11() {}
protected int refTotestCurPackagePrivateBase11;
}
class CurPackagePrivateExt11 extends CurPackagePrivateBase11 { }
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8028739
* @summary javac generates incorrect descriptor for MethodHandle::invoke
* @run testng MethodReferenceTestMethodHandle
*/
import java.lang.invoke.*;
import java.util.*;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
@Test
public class MethodReferenceTestMethodHandle {
MethodHandles.Lookup lookup = MethodHandles.lookup();
interface ReplaceItf {
Object apply(String a, char b, char c) throws Throwable;
}
interface FormatItf {
Object apply(String a, Object... args) throws Throwable;
}
interface AddItf {
void apply(List st, int idx, Object v) throws Throwable;
}
public void testVirtual() throws Throwable {
MethodType mt = MethodType.methodType(String.class, char.class, char.class);
MethodHandle ms = lookup.findVirtual(String.class, "replace", mt);
// --- String.replace(String, char, char) ---
assertEquals("oome otring to oearch", ms.invoke("some string to search", 's', 'o'));
ReplaceItf f1 = (a, b, c) -> ms.invoke(a,b,c);
assertEquals("oome otring to oearch", f1.apply("some string to search", 's', 'o'));
ReplaceItf f2 = ms::invoke;
assertEquals("oome otring to oearch", f2.apply("some string to search", 's', 'o'));
assertEquals("oome otring to oearch", f2.apply("some string to search", new Character('s'), 'o'));
assertEquals("oome otring to oearch", ((ReplaceItf) ms::invoke).apply("some string to search", 's', 'o'));
}
public void testStatic() throws Throwable {
MethodType fmt = MethodType.methodType(String.class, String.class, (new Object[1]).getClass());
MethodHandle fms = lookup.findStatic(String.class, "format", fmt);
// --- String.format(String, Object...) ---
assertEquals("Testing One 2 3", fms.invoke("Testing %s %d %x", "One", new Integer(2), 3));
FormatItf ff2 = fms::invoke;
assertEquals("Testing One 2 3", ff2.apply("Testing %s %d %x", "One", new Integer(2), 3));
assertEquals("Testing One 2 3", ((FormatItf) fms::invoke).apply("Testing %s %d %x", "One", new Integer(2), 3));
assertEquals("Testing One 2 3 four", ff2.apply("Testing %s %d %x %s", "One", new Integer(2), 3, "four"));
}
public void testVoid() throws Throwable {
MethodType pmt = MethodType.methodType(void.class, int.class, Object.class);
MethodHandle pms = lookup.findVirtual(List.class, "add", pmt);
List<String> list = new ArrayList<>();
// --- List.add(int,String) ---
pms.invoke(list, 0, "Hi");
AddItf pf2 = pms::invoke;
pf2.apply(list, 1, "there");
AddItf pf3 = pms::invokeExact;
pf3.apply(list, 2, "you");
assertEquals("Hi", list.get(0));
assertEquals("there", list.get(1));
assertEquals("you", list.get(2));
}
}
......@@ -31,26 +31,27 @@
*/
import com.sun.source.util.*;
import com.sun.tools.javac.api.*;
import com.sun.tools.javac.file.*;
import com.sun.tools.javac.util.Assert;
import javax.annotation.processing.*;
import javax.lang.model.SourceVersion;
import javax.lang.model.type.*;
import javax.lang.model.util.ElementFilter;
import javax.lang.model.element.*;
import javax.tools.*;
import java.util.*;
import java.io.*;
import javax.lang.model.util.Types;
public class IntersectionPropertiesTest {
private int errors = 0;
private static final String Intersection_name = "IntersectionTest.java";
private static final String Intersection_contents =
"import java.util.AbstractList;\n" +
"import java.util.List;\n" +
"import java.io.Serializable;\t" +
"public class IntersectionTest<S extends List & Serializable> {\n" +
" void method(S s) { }\n" +
"public class IntersectionTest<S extends List & Serializable, One extends AbstractList & Runnable & Serializable, Two extends AbstractList & Serializable & Runnable> {\n" +
" void method(S s, One o, Two t) { }\n" +
" public static abstract class SubType extends AbstractList implements Runnable, Serializable { } \n" +
"}";
private static final File classesdir = new File("intersectionproperties");
......@@ -116,7 +117,8 @@ public class IntersectionPropertiesTest {
TypeParameterElement typeParameterElement = ((TypeParameterElement) typeVariable.asElement());
final List<? extends TypeMirror> bounds = typeParameterElement.getBounds();
final HashSet<TypeMirror> actual = new HashSet<TypeMirror>(processingEnv.getTypeUtils().directSupertypes(upperBound));
Types types = processingEnv.getTypeUtils();
final HashSet<TypeMirror> actual = new HashSet<TypeMirror>(types.directSupertypes(upperBound));
final HashSet<TypeMirror> expected = new HashSet<TypeMirror>(bounds);
if (!expected.equals(actual)) {
System.err.println("Mismatched expected and actual bounds.");
......@@ -128,6 +130,40 @@ public class IntersectionPropertiesTest {
System.err.println(" " + tm);
errors++;
}
TypeVariable oneTypeVariable = (TypeVariable) method.getParameters().get(1).asType();
TypeMirror oneUpperBound = oneTypeVariable.getUpperBound();
TypeVariable twoTypeVariable = (TypeVariable) method.getParameters().get(2).asType();
TypeMirror twoUpperBound = twoTypeVariable.getUpperBound();
TypeElement oneUpperBoundElement = (TypeElement) types.asElement(oneUpperBound);
Assert.checkNonNull(oneUpperBoundElement);
Assert.check("java.util.AbstractList".equals(oneUpperBoundElement.getSuperclass().toString()),
oneUpperBoundElement.getSuperclass().toString());
List<String> superInterfaces = new java.util.ArrayList<>();
for (TypeMirror tm : oneUpperBoundElement.getInterfaces()) {
superInterfaces.add(tm.toString());
}
Assert.check(java.util.Arrays.asList("java.lang.Runnable",
"java.io.Serializable").equals(superInterfaces),
superInterfaces);
Assert.check(types.isSameType(upperBound, types.capture(upperBound)));
Assert.check(types.isSameType(types.erasure(typeVariable), types.erasure(upperBound)));
TypeElement subTypeClass = processingEnv.getElementUtils().getTypeElement("IntersectionTest.SubType");
Assert.checkNonNull(subTypeClass);
Assert.check(types.isAssignable(subTypeClass.asType(), oneUpperBound));
Assert.check(types.isSameType(oneUpperBound, twoUpperBound));
Assert.check(!types.isSameType(upperBound, twoUpperBound));
Assert.check(types.isSubtype(subTypeClass.asType(), oneUpperBound));
Assert.check(types.isSubtype(oneUpperBound, upperBound));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册