提交 76ac5ed2 编写于 作者: L lana

Merge

......@@ -153,6 +153,7 @@ javah.tests = \
javap.includes = \
com/sun/tools/classfile/ \
com/sun/tools/javap/ \
com/sun/tools/jdeps/ \
sun/tools/javap/
javap.tests = \
......
......@@ -75,6 +75,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/javah/resources/version.properties
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
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 \
......@@ -85,6 +86,9 @@ $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d : $(PROPSOURCES) $(BUILD_TOOLS)
java.util.ListResourceBundle \
-compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \
$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \
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
echo PROPS_ARE_CREATED=yes > $@
......
......@@ -52,6 +52,12 @@ public interface AnnotationDesc {
*/
ElementValuePair[] elementValues();
/**
* Check for the synthesized bit on the annotation.
*
* @return true if the annotation is synthesized.
*/
boolean isSynthesized();
/**
* Represents an association between an annotation type element
......
/*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
......@@ -51,6 +51,7 @@ public abstract class Attribute {
public static final String LineNumberTable = "LineNumberTable";
public static final String LocalVariableTable = "LocalVariableTable";
public static final String LocalVariableTypeTable = "LocalVariableTypeTable";
public static final String MethodParameters = "MethodParameters";
public static final String RuntimeVisibleAnnotations = "RuntimeVisibleAnnotations";
public static final String RuntimeInvisibleAnnotations = "RuntimeInvisibleAnnotations";
public static final String RuntimeVisibleParameterAnnotations = "RuntimeVisibleParameterAnnotations";
......@@ -113,6 +114,7 @@ public abstract class Attribute {
standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class);
if (!compat) { // old javap does not recognize recent attributes
standardAttributes.put(MethodParameters, MethodParameters_attribute.class);
standardAttributes.put(CompilationID, CompilationID_attribute.class);
standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
......@@ -171,6 +173,7 @@ public abstract class Attribute {
R visitLineNumberTable(LineNumberTable_attribute attr, P p);
R visitLocalVariableTable(LocalVariableTable_attribute attr, P p);
R visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, P p);
R visitMethodParameters(MethodParameters_attribute attr, P p);
R visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, P p);
R visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, P p);
R visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, P p);
......
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
......@@ -479,6 +479,15 @@ public class ClassWriter {
out.writeShort(entry.index);
}
public Void visitMethodParameters(MethodParameters_attribute attr, ClassOutputStream out) {
out.writeByte(attr.method_parameter_table.length);
for (MethodParameters_attribute.Entry e : attr.method_parameter_table) {
out.writeShort(e.name_index);
out.writeInt(e.flags);
}
return null;
}
public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, ClassOutputStream out) {
annotationWriter.write(attr.annotations, out);
return null;
......
......@@ -141,6 +141,15 @@ public class Dependencies {
return new APIDependencyFinder(access);
}
/**
* Get a finder to do class dependency analysis.
*
* @return a Class dependency finder
*/
public static Finder getClassDependencyFinder() {
return new ClassDependencyFinder();
}
/**
* Get the finder used to locate the dependencies for a class.
* @return the finder
......@@ -246,8 +255,6 @@ public class Dependencies {
return results;
}
/**
* Find the dependencies of a class, using the current
* {@link Dependencies#getFinder finder} and
......@@ -306,38 +313,44 @@ public class Dependencies {
* A location identifying a class.
*/
static class SimpleLocation implements Location {
public SimpleLocation(String className) {
this.className = className;
public SimpleLocation(String name) {
this.name = name;
this.className = name.replace('/', '.').replace('$', '.');
}
public String getName() {
return name;
}
/**
* Get the name of the class being depended on. This name will be used to
* locate the class file for transitive dependency analysis.
* @return the name of the class being depended on
*/
public String getClassName() {
return className;
}
public String getPackageName() {
int i = name.lastIndexOf('/');
return (i > 0) ? name.substring(0, i).replace('/', '.') : "";
}
@Override
public boolean equals(Object other) {
if (this == other)
return true;
if (!(other instanceof SimpleLocation))
return false;
return (className.equals(((SimpleLocation) other).className));
return (name.equals(((SimpleLocation) other).name));
}
@Override
public int hashCode() {
return className.hashCode();
return name.hashCode();
}
@Override
public String toString() {
return className;
return name;
}
private String name;
private String className;
}
......@@ -431,9 +444,7 @@ public class Dependencies {
}
public boolean accepts(Dependency dependency) {
String cn = dependency.getTarget().getClassName();
int lastSep = cn.lastIndexOf("/");
String pn = (lastSep == -1 ? "" : cn.substring(0, lastSep));
String pn = dependency.getTarget().getPackageName();
if (packageNames.contains(pn))
return true;
......@@ -451,8 +462,6 @@ public class Dependencies {
private final boolean matchSubpackages;
}
/**
* This class identifies class names directly or indirectly in the constant pool.
*/
......@@ -462,6 +471,26 @@ public class Dependencies {
for (CPInfo cpInfo: classfile.constant_pool.entries()) {
v.scan(cpInfo);
}
try {
v.addClass(classfile.super_class);
v.addClasses(classfile.interfaces);
v.scan(classfile.attributes);
for (Field f : classfile.fields) {
v.scan(f.descriptor, f.attributes);
}
for (Method m : classfile.methods) {
v.scan(m.descriptor, m.attributes);
Exceptions_attribute e =
(Exceptions_attribute)m.attributes.get(Attribute.Exceptions);
if (e != null) {
v.addClasses(e.exception_index_table);
}
}
} catch (ConstantPoolException e) {
throw new ClassFileError(e);
}
return v.deps;
}
}
......@@ -558,9 +587,7 @@ public class Dependencies {
void scan(Descriptor d, Attributes attrs) {
try {
scan(new Signature(d.index).getType(constant_pool));
Signature_attribute sa = (Signature_attribute) attrs.get(Attribute.Signature);
if (sa != null)
scan(new Signature(sa.signature_index).getType(constant_pool));
scan(attrs);
} catch (ConstantPoolException e) {
throw new ClassFileError(e);
}
......@@ -574,6 +601,43 @@ public class Dependencies {
t.accept(this, null);
}
void scan(Attributes attrs) {
try {
Signature_attribute sa = (Signature_attribute)attrs.get(Attribute.Signature);
if (sa != null)
scan(sa.getParsedSignature().getType(constant_pool));
scan((RuntimeVisibleAnnotations_attribute)
attrs.get(Attribute.RuntimeVisibleAnnotations));
scan((RuntimeVisibleParameterAnnotations_attribute)
attrs.get(Attribute.RuntimeVisibleParameterAnnotations));
} catch (ConstantPoolException e) {
throw new ClassFileError(e);
}
}
private void scan(RuntimeAnnotations_attribute attr) throws ConstantPoolException {
if (attr == null) {
return;
}
for (int i = 0; i < attr.annotations.length; i++) {
int index = attr.annotations[i].type_index;
scan(new Signature(index).getType(constant_pool));
}
}
private void scan(RuntimeParameterAnnotations_attribute attr) throws ConstantPoolException {
if (attr == null) {
return;
}
for (int param = 0; param < attr.parameter_annotations.length; param++) {
for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
int index = attr.parameter_annotations[param][i].type_index;
scan(new Signature(index).getType(constant_pool));
}
}
}
void addClass(int index) throws ConstantPoolException {
if (index != 0) {
String name = constant_pool.getClassInfo(index).getBaseName();
......@@ -698,6 +762,7 @@ public class Dependencies {
findDependencies(type.paramTypes);
findDependencies(type.returnType);
findDependencies(type.throwsTypes);
findDependencies(type.typeParamTypes);
return null;
}
......@@ -709,7 +774,7 @@ public class Dependencies {
public Void visitClassType(ClassType type, Void p) {
findDependencies(type.outerType);
addDependency(type.name);
addDependency(type.getBinaryName());
findDependencies(type.typeArgs);
return null;
}
......
......@@ -71,7 +71,19 @@ public interface Dependency {
* dependency analysis.
* @return the name of the class containing the location.
*/
String getName();
/**
* Get the fully-qualified name of the class containing the location.
* @return the fully-qualified name of the class containing the location.
*/
String getClassName();
/**
* Get the package name of the class containing the location.
* @return the package name of the class containing the location.
*/
String getPackageName();
}
......
/*
* 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.
*/
package com.sun.tools.classfile;
import java.io.IOException;
/**
* See JVMS, section 4.8.13.
*
* <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 MethodParameters_attribute extends Attribute {
public final int method_parameter_table_length;
public final Entry[] method_parameter_table;
MethodParameters_attribute(ClassReader cr,
int name_index,
int length)
throws IOException {
super(name_index, length);
method_parameter_table_length = cr.readUnsignedByte();
method_parameter_table = new Entry[method_parameter_table_length];
for (int i = 0; i < method_parameter_table_length; i++)
method_parameter_table[i] = new Entry(cr);
}
public MethodParameters_attribute(ConstantPool constant_pool,
Entry[] method_parameter_table)
throws ConstantPoolException {
this(constant_pool.getUTF8Index(Attribute.MethodParameters),
method_parameter_table);
}
public MethodParameters_attribute(int name_index,
Entry[] method_parameter_table) {
super(name_index, 1 + method_parameter_table.length * Entry.length());
this.method_parameter_table_length = method_parameter_table.length;
this.method_parameter_table = method_parameter_table;
}
public <R, D> R accept(Visitor<R, D> visitor, D data) {
return visitor.visitMethodParameters(this, data);
}
public static class Entry {
Entry(ClassReader cr) throws IOException {
name_index = cr.readUnsignedShort();
flags = cr.readInt();
}
public static int length() {
return 6;
}
public final int name_index;
public final int flags;
}
}
......@@ -321,7 +321,8 @@ public abstract class AbstractMemberWriter {
code.addContent(" ");
}
if (member.isMethod()) {
if (((MethodDoc)member).isAbstract()) {
if (!(member.containingClass().isInterface()) &&
((MethodDoc)member).isAbstract()) {
code.addContent("abstract ");
}
// This check for isDefault() and the default modifier needs to be
......@@ -329,7 +330,7 @@ public abstract class AbstractMemberWriter {
// method summary section. Once the default modifier is added
// to the Modifier list on DocEnv and once it is updated to use the
// javax.lang.model.element.Modifier, we will need to remove this.
else if (((MethodDoc)member).isDefault()) {
if (((MethodDoc)member).isDefault()) {
code.addContent("default ");
}
}
......@@ -561,11 +562,14 @@ public abstract class AbstractMemberWriter {
if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) {
int methodType = (member.isStatic()) ? MethodTypes.STATIC.value() :
MethodTypes.INSTANCE.value();
methodType = (classdoc.isInterface() || ((MethodDoc)member).isAbstract()) ?
methodType | MethodTypes.ABSTRACT.value() :
methodType | MethodTypes.CONCRETE.value();
if (((MethodDoc)member).isDefault()) {
methodType = methodType | MethodTypes.DEFAULT.value();
if (member.containingClass().isInterface()) {
methodType = (((MethodDoc) member).isAbstract())
? methodType | MethodTypes.ABSTRACT.value()
: methodType | MethodTypes.DEFAULT.value();
} else {
methodType = (((MethodDoc) member).isAbstract())
? methodType | MethodTypes.ABSTRACT.value()
: methodType | MethodTypes.CONCRETE.value();
}
if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) {
methodType = methodType | MethodTypes.DEPRECATED.value();
......
......@@ -89,6 +89,16 @@ public class HtmlDocletWriter extends HtmlDocWriter {
*/
protected boolean printedAnnotationHeading = false;
/**
* To check whether the repeated annotations is documented or not.
*/
private boolean isAnnotationDocumented = false;
/**
* To check whether the container annotations is documented or not.
*/
private boolean isContainerDocumented = false;
/**
* Constructor to construct the HtmlStandardWriter object.
*
......@@ -1793,50 +1803,66 @@ public class HtmlDocletWriter extends HtmlDocWriter {
StringBuilder annotation;
for (int i = 0; i < descList.length; i++) {
AnnotationTypeDoc annotationDoc = descList[i].annotationType();
if (! Util.isDocumentedAnnotation(annotationDoc)){
// If an annotation is not documented, do not add it to the list. If
// the annotation is of a repeatable type, and if it is not documented
// and also if its container annotation is not documented, do not add it
// to the list. If an annotation of a repeatable type is not documented
// but its container is documented, it will be added to the list.
if (! Util.isDocumentedAnnotation(annotationDoc) &&
(!isAnnotationDocumented && !isContainerDocumented)) {
continue;
}
annotation = new StringBuilder();
isAnnotationDocumented = false;
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc);
linkInfo.label = "@" + annotationDoc.name();
annotation.append(getLink(linkInfo));
AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues();
if (pairs.length > 0) {
annotation.append('(');
// If the annotation is synthesized, do not print the container.
if (descList[i].isSynthesized()) {
for (int j = 0; j < pairs.length; j++) {
if (j > 0) {
annotation.append(",");
if (linkBreak) {
annotation.append(DocletConstants.NL);
int spaces = annotationDoc.name().length() + 2;
for (int k = 0; k < (spaces + indent); k++) {
annotation.append(' ');
}
}
}
annotation.append(getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION,
pairs[j].element(), pairs[j].element().name(), false));
annotation.append('=');
AnnotationValue annotationValue = pairs[j].value();
List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
if (annotationValue.value() instanceof AnnotationValue[]) {
AnnotationValue[] annotationArray =
(AnnotationValue[]) annotationValue.value();
for (int k = 0; k < annotationArray.length; k++) {
annotationTypeValues.add(annotationArray[k]);
}
(AnnotationValue[]) annotationValue.value();
annotationTypeValues.addAll(Arrays.asList(annotationArray));
} else {
annotationTypeValues.add(annotationValue);
}
annotation.append(annotationTypeValues.size() == 1 ? "" : "{");
for (Iterator<AnnotationValue> iter = annotationTypeValues.iterator(); iter.hasNext(); ) {
annotation.append(annotationValueToString(iter.next()));
annotation.append(iter.hasNext() ? "," : "");
String sep = "";
for (AnnotationValue av : annotationTypeValues) {
annotation.append(sep);
annotation.append(annotationValueToString(av));
sep = " ";
}
annotation.append(annotationTypeValues.size() == 1 ? "" : "}");
}
annotation.append(")");
}
else if (isAnnotationArray(pairs)) {
// If the container has 1 or more value defined and if the
// repeatable type annotation is not documented, do not print
// the container.
if (pairs.length == 1 && isAnnotationDocumented) {
AnnotationValue[] annotationArray =
(AnnotationValue[]) (pairs[0].value()).value();
List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
annotationTypeValues.addAll(Arrays.asList(annotationArray));
String sep = "";
for (AnnotationValue av : annotationTypeValues) {
annotation.append(sep);
annotation.append(annotationValueToString(av));
sep = " ";
}
}
// If the container has 1 or more value defined and if the
// repeatable type annotation is not documented, print the container.
else {
addAnnotations(annotationDoc, linkInfo, annotation, pairs,
indent, false);
}
}
else {
addAnnotations(annotationDoc, linkInfo, annotation, pairs,
indent, linkBreak);
}
annotation.append(linkBreak ? DocletConstants.NL : "");
results.add(annotation.toString());
......@@ -1844,6 +1870,91 @@ public class HtmlDocletWriter extends HtmlDocWriter {
return results;
}
/**
* Add annotation to the annotation string.
*
* @param annotationDoc the annotation being documented
* @param linkInfo the information about the link
* @param annotation the annotation string to which the annotation will be added
* @param pairs annotation type element and value pairs
* @param indent the number of extra spaces to indent the annotations.
* @param linkBreak if true, add new line between each member value
*/
private void addAnnotations(AnnotationTypeDoc annotationDoc, LinkInfoImpl linkInfo,
StringBuilder annotation, AnnotationDesc.ElementValuePair[] pairs,
int indent, boolean linkBreak) {
linkInfo.label = "@" + annotationDoc.name();
annotation.append(getLink(linkInfo));
if (pairs.length > 0) {
annotation.append('(');
for (int j = 0; j < pairs.length; j++) {
if (j > 0) {
annotation.append(",");
if (linkBreak) {
annotation.append(DocletConstants.NL);
int spaces = annotationDoc.name().length() + 2;
for (int k = 0; k < (spaces + indent); k++) {
annotation.append(' ');
}
}
}
annotation.append(getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION,
pairs[j].element(), pairs[j].element().name(), false));
annotation.append('=');
AnnotationValue annotationValue = pairs[j].value();
List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
if (annotationValue.value() instanceof AnnotationValue[]) {
AnnotationValue[] annotationArray =
(AnnotationValue[]) annotationValue.value();
annotationTypeValues.addAll(Arrays.asList(annotationArray));
} else {
annotationTypeValues.add(annotationValue);
}
annotation.append(annotationTypeValues.size() == 1 ? "" : "{");
String sep = "";
for (AnnotationValue av : annotationTypeValues) {
annotation.append(sep);
annotation.append(annotationValueToString(av));
sep = ",";
}
annotation.append(annotationTypeValues.size() == 1 ? "" : "}");
isContainerDocumented = false;
}
annotation.append(")");
}
}
/**
* Check if the annotation contains an array of annotation as a value. This
* check is to verify if a repeatable type annotation is present or not.
*
* @param pairs annotation type element and value pairs
*
* @return true if the annotation contains an array of annotation as a value.
*/
private boolean isAnnotationArray(AnnotationDesc.ElementValuePair[] pairs) {
AnnotationValue annotationValue;
for (int j = 0; j < pairs.length; j++) {
annotationValue = pairs[j].value();
if (annotationValue.value() instanceof AnnotationValue[]) {
AnnotationValue[] annotationArray =
(AnnotationValue[]) annotationValue.value();
if (annotationArray.length > 1) {
if (annotationArray[0].value() instanceof AnnotationDesc) {
AnnotationTypeDoc annotationDoc =
((AnnotationDesc) annotationArray[0].value()).annotationType();
isContainerDocumented = true;
if (Util.isDocumentedAnnotation(annotationDoc)) {
isAnnotationDocumented = true;
}
return true;
}
}
}
}
return false;
}
private String annotationValueToString(AnnotationValue annotationValue) {
if (annotationValue.value() instanceof Type) {
Type type = (Type) annotationValue.value();
......
......@@ -1283,8 +1283,9 @@ public abstract class Symbol implements Element {
List<Name> paramNames = savedParameterNames;
savedParameterNames = null;
// discard the provided names if the list of names is the wrong size.
if (paramNames == null || paramNames.size() != type.getParameterTypes().size())
if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
paramNames = List.nil();
}
ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
List<Name> remaining = paramNames;
// assert: remaining and paramNames are both empty or both
......
......@@ -38,6 +38,7 @@ import com.sun.tools.javac.tree.JCTree.*;
import javax.tools.JavaFileObject;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Queue;
......@@ -177,29 +178,19 @@ public class DeferredAttr extends JCTree.Visitor {
* attribution round must follow one or more speculative rounds.
*/
Type check(ResultInfo resultInfo) {
return check(resultInfo, stuckVars(tree, env, resultInfo), basicCompleter);
}
Type check(ResultInfo resultInfo, List<Type> stuckVars, DeferredTypeCompleter deferredTypeCompleter) {
DeferredAttrContext deferredAttrContext =
resultInfo.checkContext.deferredAttrContext();
Assert.check(deferredAttrContext != emptyDeferredAttrContext);
List<Type> stuckVars = stuckVars(tree, env, resultInfo);
if (stuckVars.nonEmpty()) {
deferredAttrContext.addDeferredAttrNode(this, resultInfo, stuckVars);
return Type.noType;
} else {
try {
switch (deferredAttrContext.mode) {
case SPECULATIVE:
Assert.check(mode == null ||
(mode == AttrMode.SPECULATIVE &&
speculativeType(deferredAttrContext.msym, deferredAttrContext.phase).hasTag(NONE)));
JCTree speculativeTree = attribSpeculative(tree, env, resultInfo);
speculativeCache.put(deferredAttrContext.msym, speculativeTree, deferredAttrContext.phase);
return speculativeTree.type;
case CHECK:
Assert.check(mode == AttrMode.SPECULATIVE);
return attr.attribTree(tree, env, resultInfo);
}
Assert.error();
return null;
return deferredTypeCompleter.complete(this, resultInfo, deferredAttrContext);
} finally {
mode = deferredAttrContext.mode;
}
......@@ -207,6 +198,43 @@ public class DeferredAttr extends JCTree.Visitor {
}
}
/**
* A completer for deferred types. Defines an entry point for type-checking
* a deferred type.
*/
interface DeferredTypeCompleter {
/**
* Entry point for type-checking a deferred type. Depending on the
* circumstances, type-checking could amount to full attribution
* or partial structural check (aka potential applicability).
*/
Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext);
}
/**
* A basic completer for deferred types. This completer type-checks a deferred type
* using attribution; depending on the attribution mode, this could be either standard
* or speculative attribution.
*/
DeferredTypeCompleter basicCompleter = new DeferredTypeCompleter() {
public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
switch (deferredAttrContext.mode) {
case SPECULATIVE:
Assert.check(dt.mode == null ||
(dt.mode == AttrMode.SPECULATIVE &&
dt.speculativeType(deferredAttrContext.msym, deferredAttrContext.phase).hasTag(NONE)));
JCTree speculativeTree = attribSpeculative(dt.tree, dt.env, resultInfo);
dt.speculativeCache.put(deferredAttrContext.msym, speculativeTree, deferredAttrContext.phase);
return speculativeTree.type;
case CHECK:
Assert.check(dt.mode == AttrMode.SPECULATIVE);
return attr.attribTree(dt.tree, dt.env, resultInfo);
}
Assert.error();
return null;
}
};
/**
* The 'mode' in which the deferred type is to be type-checked
*/
......@@ -498,95 +526,114 @@ public class DeferredAttr extends JCTree.Visitor {
if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) {
return List.nil();
} else {
StuckChecker sc = new StuckChecker(resultInfo, env);
return stuckVarsInternal(tree, resultInfo.pt, resultInfo.checkContext.inferenceContext());
}
}
//where
private List<Type> stuckVarsInternal(JCTree tree, Type pt, Infer.InferenceContext inferenceContext) {
StuckChecker sc = new StuckChecker(pt, inferenceContext);
sc.scan(tree);
return List.from(sc.stuckVars);
}
}
/**
* This visitor is used to check that structural expressions conform
* to their target - this step is required as inference could end up
* inferring types that make some of the nested expressions incompatible
* with their corresponding instantiated target
* A special tree scanner that would only visit portions of a given tree.
* The set of nodes visited by the scanner can be customized at construction-time.
*/
class StuckChecker extends TreeScanner {
abstract static class FilterScanner extends TreeScanner {
Type pt;
Filter<JCTree> treeFilter;
Infer.InferenceContext inferenceContext;
Set<Type> stuckVars = new LinkedHashSet<Type>();
Env<AttrContext> env;
final Filter<JCTree> treeFilter;
final Filter<JCTree> argsFilter = new Filter<JCTree>() {
public boolean accepts(JCTree t) {
switch (t.getTag()) {
case CONDEXPR:
case LAMBDA:
case PARENS:
case REFERENCE:
return true;
default:
return false;
FilterScanner(final Set<JCTree.Tag> validTags) {
this.treeFilter = new Filter<JCTree>() {
public boolean accepts(JCTree t) {
return validTags.contains(t.getTag());
}
}
};
};
}
final Filter<JCTree> lambdaBodyFilter = new Filter<JCTree>() {
public boolean accepts(JCTree t) {
switch (t.getTag()) {
case BLOCK: case CASE: case CATCH: case DOLOOP:
case FOREACHLOOP: case FORLOOP: case RETURN:
case SYNCHRONIZED: case SWITCH: case TRY: case WHILELOOP:
return true;
default:
return false;
@Override
public void scan(JCTree tree) {
if (tree != null) {
if (treeFilter.accepts(tree)) {
super.scan(tree);
} else {
skip(tree);
}
}
};
}
/**
* handler that is executed when a node has been discarded
*/
abstract void skip(JCTree tree);
}
/**
* A tree scanner suitable for visiting the target-type dependent nodes of
* a given argument expression.
*/
static class PolyScanner extends FilterScanner {
StuckChecker(ResultInfo resultInfo, Env<AttrContext> env) {
this.pt = resultInfo.pt;
this.inferenceContext = resultInfo.checkContext.inferenceContext();
this.treeFilter = argsFilter;
this.env = env;
PolyScanner() {
super(EnumSet.of(CONDEXPR, PARENS, LAMBDA, REFERENCE));
}
@Override
public void scan(JCTree tree) {
if (tree != null && treeFilter.accepts(tree)) {
super.scan(tree);
}
void skip(JCTree tree) {
//do nothing
}
}
/**
* A tree scanner suitable for visiting the target-type dependent nodes nested
* within a lambda expression body.
*/
static class LambdaReturnScanner extends FilterScanner {
LambdaReturnScanner() {
super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP,
FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
}
@Override
void skip(JCTree tree) {
//do nothing
}
}
/**
* This visitor is used to check that structural expressions conform
* to their target - this step is required as inference could end up
* inferring types that make some of the nested expressions incompatible
* with their corresponding instantiated target
*/
class StuckChecker extends PolyScanner {
Type pt;
Infer.InferenceContext inferenceContext;
Set<Type> stuckVars = new LinkedHashSet<Type>();
StuckChecker(Type pt, Infer.InferenceContext inferenceContext) {
this.pt = pt;
this.inferenceContext = inferenceContext;
}
@Override
public void visitLambda(JCLambda tree) {
Type prevPt = pt;
Filter<JCTree> prevFilter = treeFilter;
try {
if (inferenceContext.inferenceVars().contains(pt)) {
stuckVars.add(pt);
}
if (!types.isFunctionalInterface(pt.tsym)) {
return;
}
Type descType = types.findDescriptorType(pt);
List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes());
if (!TreeInfo.isExplicitLambda(tree) &&
freeArgVars.nonEmpty()) {
stuckVars.addAll(freeArgVars);
}
pt = descType.getReturnType();
if (tree.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) {
scan(tree.getBody());
} else {
treeFilter = lambdaBodyFilter;
super.visitLambda(tree);
}
} finally {
pt = prevPt;
treeFilter = prevFilter;
if (inferenceContext.inferenceVars().contains(pt)) {
stuckVars.add(pt);
}
if (!types.isFunctionalInterface(pt.tsym)) {
return;
}
Type descType = types.findDescriptorType(pt);
List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes());
if (!TreeInfo.isExplicitLambda(tree) &&
freeArgVars.nonEmpty()) {
stuckVars.addAll(freeArgVars);
}
scanLambdaBody(tree, descType.getReturnType());
}
@Override
......@@ -605,16 +652,19 @@ public class DeferredAttr extends JCTree.Visitor {
stuckVars.addAll(freeArgVars);
}
@Override
public void visitReturn(JCReturn tree) {
Filter<JCTree> prevFilter = treeFilter;
try {
treeFilter = argsFilter;
if (tree.expr != null) {
scan(tree.expr);
}
} finally {
treeFilter = prevFilter;
void scanLambdaBody(JCLambda lambda, final Type pt) {
if (lambda.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) {
stuckVars.addAll(stuckVarsInternal(lambda.body, pt, inferenceContext));
} else {
LambdaReturnScanner lambdaScanner = new LambdaReturnScanner() {
@Override
public void visitReturn(JCReturn tree) {
if (tree.expr != null) {
stuckVars.addAll(stuckVarsInternal(tree.expr, pt, inferenceContext));
}
}
};
lambdaScanner.scan(lambda.body);
}
}
}
......
......@@ -114,7 +114,7 @@ public class Infer {
}
}
private final InferenceException inferenceException;
final InferenceException inferenceException;
/***************************************************************************
* Mini/Maximization of UndetVars
......@@ -271,15 +271,19 @@ public class Infer {
boolean allowBoxing,
boolean useVarargs,
Resolve.MethodResolutionContext resolveContext,
Resolve.MethodCheck methodCheck,
Warner warn) throws InferenceException {
//-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
final InferenceContext inferenceContext = new InferenceContext(tvars, this, true);
inferenceException.clear();
DeferredAttr.DeferredAttrContext deferredAttrContext =
resolveContext.deferredAttrContext(msym, inferenceContext);
try {
rs.checkRawArgumentsAcceptable(env, msym, resolveContext.attrMode(), inferenceContext,
argtypes, mt.getParameterTypes(), allowBoxing, useVarargs, warn,
new InferenceCheckHandler(inferenceContext));
methodCheck.argumentsAcceptable(env, deferredAttrContext, argtypes, mt.getParameterTypes(), warn);
deferredAttrContext.complete();
// minimize as yet undetermined type variables
for (Type t : inferenceContext.undetvars) {
......@@ -309,32 +313,6 @@ public class Infer {
inferenceContext.notifyChange(types);
}
}
//where
/** inference check handler **/
class InferenceCheckHandler implements Resolve.MethodCheckHandler {
InferenceContext inferenceContext;
public InferenceCheckHandler(InferenceContext inferenceContext) {
this.inferenceContext = inferenceContext;
}
public InapplicableMethodException arityMismatch() {
return inferenceException.setMessage("infer.arg.length.mismatch", inferenceContext.inferenceVars());
}
public InapplicableMethodException argumentMismatch(boolean varargs, JCDiagnostic details) {
String key = varargs ?
"infer.varargs.argument.mismatch" :
"infer.no.conforming.assignment.exists";
return inferenceException.setMessage(key,
inferenceContext.inferenceVars(), details);
}
public InapplicableMethodException inaccessibleVarargs(Symbol location, Type expected) {
return inferenceException.setMessage("inaccessible.varargs.type",
expected, Kinds.kindName(location), location);
}
}
/** check that type parameters are within their bounds.
*/
......
......@@ -217,6 +217,13 @@ public class ClassReader implements Completer {
*/
boolean haveParameterNameIndices;
/** Set this to false every time we start reading a method
* and are saving parameter names. Set it to true when we see
* MethodParameters, if it's set when we see a LocalVariableTable,
* then we ignore the parameter names from the LVT.
*/
boolean sawMethodParameters;
/**
* The set of attribute names for which warnings have been generated for the current class
*/
......@@ -984,7 +991,7 @@ public class ClassReader implements Completer {
new AttributeReader(names.LocalVariableTable, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) {
protected void read(Symbol sym, int attrLen) {
int newbp = bp + attrLen;
if (saveParameterNames) {
if (saveParameterNames && !sawMethodParameters) {
// Pick up parameter names from the variable table.
// Parameter names are not explicitly identified as such,
// but all parameter name entries in the LocalVariableTable
......@@ -1017,6 +1024,25 @@ public class ClassReader implements Completer {
}
},
new AttributeReader(names.MethodParameters, V52, MEMBER_ATTRIBUTE) {
protected void read(Symbol sym, int attrlen) {
int newbp = bp + attrlen;
if (saveParameterNames) {
sawMethodParameters = true;
int numEntries = nextByte();
parameterNameIndices = new int[numEntries];
haveParameterNameIndices = true;
for (int i = 0; i < numEntries; i++) {
int nameIndex = nextChar();
int flags = nextInt();
parameterNameIndices[i] = nameIndex;
}
}
bp = newbp;
}
},
new AttributeReader(names.SourceFile, V45_3, CLASS_ATTRIBUTE) {
protected void read(Symbol sym, int attrLen) {
ClassSymbol c = (ClassSymbol) sym;
......@@ -1826,6 +1852,7 @@ public class ClassReader implements Completer {
} else
Arrays.fill(parameterNameIndices, 0);
haveParameterNameIndices = false;
sawMethodParameters = false;
}
/**
......@@ -1845,12 +1872,16 @@ public class ClassReader implements Completer {
// if no names were found in the class file, there's nothing more to do
if (!haveParameterNameIndices)
return;
int firstParam = ((sym.flags() & STATIC) == 0) ? 1 : 0;
// the code in readMethod may have skipped the first parameter when
// setting up the MethodType. If so, we make a corresponding allowance
// here for the position of the first parameter. Note that this
// assumes the skipped parameter has a width of 1 -- i.e. it is not
// If we get parameter names from MethodParameters, then we
// don't need to skip.
int firstParam = 0;
if (!sawMethodParameters) {
firstParam = ((sym.flags() & STATIC) == 0) ? 1 : 0;
// the code in readMethod may have skipped the first
// parameter when setting up the MethodType. If so, we
// make a corresponding allowance here for the position of
// the first parameter. Note that this assumes the
// skipped parameter has a width of 1 -- i.e. it is not
// a double width type (long or double.)
if (sym.name == names.init && currentOwner.hasOuterInstance()) {
// Sometimes anonymous classes don't have an outer
......@@ -1861,17 +1892,20 @@ public class ClassReader implements Completer {
}
if (sym.type != jvmType) {
// reading the method attributes has caused the symbol's type to
// be changed. (i.e. the Signature attribute.) This may happen if
// there are hidden (synthetic) parameters in the descriptor, but
// not in the Signature. The position of these hidden parameters
// is unspecified; for now, assume they are at the beginning, and
// so skip over them. The primary case for this is two hidden
// parameters passed into Enum constructors.
// reading the method attributes has caused the
// symbol's type to be changed. (i.e. the Signature
// attribute.) This may happen if there are hidden
// (synthetic) parameters in the descriptor, but not
// in the Signature. The position of these hidden
// parameters is unspecified; for now, assume they are
// at the beginning, and so skip over them. The
// primary case for this is two hidden parameters
// passed into Enum constructors.
int skip = Code.width(jvmType.getParameterTypes())
- Code.width(sym.type.getParameterTypes());
firstParam += skip;
}
}
List<Name> paramNames = List.nil();
int index = firstParam;
for (Type t: sym.type.getParameterTypes()) {
......
......@@ -725,6 +725,28 @@ public class ClassWriter extends ClassFile {
return acount;
}
/**
* Write method parameter names attribute.
*/
int writeMethodParametersAttr(MethodSymbol m) {
if (m.params != null && 0 != m.params.length()) {
int attrIndex = writeAttr(names.MethodParameters);
databuf.appendByte(m.params.length());
for (VarSymbol s : m.params) {
// TODO: expand to cover synthesized, once we figure out
// how to represent that.
final int flags = (int) s.flags() & (FINAL | SYNTHETIC);
// output parameter info
databuf.appendChar(pool.put(s.name));
databuf.appendInt(flags);
}
endAttr(attrIndex);
return 1;
} else
return 0;
}
/** Write method parameter annotations;
* return number of attributes written.
*/
......@@ -1034,6 +1056,8 @@ public class ClassWriter extends ClassFile {
endAttr(alenIdx);
acount++;
}
if (options.isSet(PARAMETERS))
acount += writeMethodParametersAttr(m);
acount += writeMemberAttrs(m);
acount += writeParameterAttrs(m);
endAttrs(acountIdx, acount);
......
/*
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -176,6 +176,8 @@ public enum Option {
PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC),
D("-d", "opt.arg.directory", "opt.d", STANDARD, FILEMANAGER),
S("-s", "opt.arg.directory", "opt.sourceDest", STANDARD, FILEMANAGER),
......@@ -309,7 +311,7 @@ public enum Option {
// This option exists only for the purpose of documenting itself.
// It's actually implemented by the launcher.
J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO) {
J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, true) {
@Override
public boolean process(OptionHelper helper, String option) {
throw new AssertionError
......@@ -414,7 +416,7 @@ public enum Option {
// This option exists only for the purpose of documenting itself.
// It's actually implemented by the CommandLine class.
AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO) {
AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, true) {
@Override
public boolean process(OptionHelper helper, String option) {
throw new AssertionError("the @ flag should be caught by CommandLine.");
......
......@@ -55,6 +55,8 @@ javac.opt.processorpath=\
Specify where to find annotation processors
javac.opt.processor=\
Names of the annotation processors to run; bypasses default discovery process
javac.opt.parameters=\
Generate metadata for reflection on method parameters
javac.opt.proc.none.only=\
Control whether annotation processing and/or compilation is done.
javac.opt.d=\
......
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -154,12 +154,13 @@ public class Pretty extends JCTree.Visitor {
}
//we need to (i) replace all line terminators with a space and (ii) remove
//occurrences of 'missing' in the Pretty output (generated when types are missing)
String res = s.toString().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", "");
String res = s.toString().trim().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", "");
if (res.length() < maxLength) {
return res;
} else {
int split = (maxLength - trimSequence.length()) * 2 / 3;
return res.substring(0, split) + trimSequence + res.substring(split);
int head = (maxLength - trimSequence.length()) * 2 / 3;
int tail = maxLength - trimSequence.length() - head;
return res.substring(0, head) + trimSequence + res.substring(res.length() - tail);
}
}
......
......@@ -132,6 +132,7 @@ public class Names {
public final Name LineNumberTable;
public final Name LocalVariableTable;
public final Name LocalVariableTypeTable;
public final Name MethodParameters;
public final Name RuntimeInvisibleAnnotations;
public final Name RuntimeInvisibleParameterAnnotations;
public final Name RuntimeInvisibleTypeAnnotations;
......@@ -265,6 +266,7 @@ public class Names {
LineNumberTable = fromString("LineNumberTable");
LocalVariableTable = fromString("LocalVariableTable");
LocalVariableTypeTable = fromString("LocalVariableTypeTable");
MethodParameters = fromString("MethodParameters");
RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
......
......@@ -88,6 +88,15 @@ public class AnnotationDescImpl implements AnnotationDesc {
return res;
}
/**
* Check for the synthesized bit on the annotation.
*
* @return true if the annotation is synthesized.
*/
public boolean isSynthesized() {
return annotation.isSynthesized();
}
/**
* Returns a string representation of this annotation.
* String is of one of the forms:
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -133,16 +133,6 @@ public class Messager extends Log implements DocErrorReporter {
this.programName = programName;
}
@Override
protected int getDefaultMaxErrors() {
return Integer.MAX_VALUE;
}
@Override
protected int getDefaultMaxWarnings() {
return Integer.MAX_VALUE;
}
public void setLocale(Locale locale) {
this.locale = locale;
}
......
......@@ -86,16 +86,7 @@ public class MethodDocImpl
* Return true if this method is abstract
*/
public boolean isAbstract() {
//### This is dubious, but old 'javadoc' apparently does it.
//### I regard this as a bug and an obstacle to treating the
//### doclet API as a proper compile-time reflection facility.
//### (maddox 09/26/2000)
if (containingClass().isInterface()) {
//### Don't force creation of ClassDocImpl for super here.
// Abstract modifier is implicit. Strip/canonicalize it.
return false;
}
return Modifier.isAbstract(getModifiers());
return (Modifier.isAbstract(getModifiers()) && !isDefault());
}
/**
......
/*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
......@@ -46,6 +46,7 @@ import com.sun.tools.classfile.InnerClasses_attribute;
import com.sun.tools.classfile.LineNumberTable_attribute;
import com.sun.tools.classfile.LocalVariableTable_attribute;
import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
import com.sun.tools.classfile.MethodParameters_attribute;
import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
......@@ -386,6 +387,28 @@ public class AttributeWriter extends BasicWriter
return null;
}
private static final String format = "%-31s%s";
public Void visitMethodParameters(MethodParameters_attribute attr,
Void ignore) {
final String header = String.format(format, "Name", "Flags");
println("MethodParameters:");
indent(+1);
println(header);
for (MethodParameters_attribute.Entry entry :
attr.method_parameter_table) {
String flagstr =
(0 != (entry.flags & ACC_FINAL) ? " final" : "") +
(0 != (entry.flags & ACC_SYNTHETIC) ? " synthetic" : "");
println(String.format(format,
constantWriter.stringValue(entry.name_index),
flagstr));
}
indent(-1);
return null;
}
public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) {
println("RuntimeVisibleAnnotations:");
indent(+1);
......
/*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -206,7 +206,7 @@ public class ClassWriter extends BasicWriter {
println("minor version: " + cf.minor_version);
println("major version: " + cf.major_version);
if (!options.compat)
writeList("flags: ", flags.getClassFlags(), NEWLINE);
writeList("flags: ", flags.getClassFlags(), "\n");
indent(-1);
constantWriter.writeConstantPool();
} else {
......@@ -383,7 +383,7 @@ public class ClassWriter extends BasicWriter {
println("Signature: " + getValue(f.descriptor));
if (options.verbose && !options.compat)
writeList("flags: ", flags.getFieldFlags(), NEWLINE);
writeList("flags: ", flags.getFieldFlags(), "\n");
if (options.showAllAttrs) {
for (Attribute attr: f.attributes)
......@@ -480,7 +480,7 @@ public class ClassWriter extends BasicWriter {
}
if (options.verbose && !options.compat) {
writeList("flags: ", flags.getMethodFlags(), NEWLINE);
writeList("flags: ", flags.getMethodFlags(), "\n");
}
Code_attribute code = null;
......@@ -749,5 +749,4 @@ public class ClassWriter extends BasicWriter {
private int size;
private ConstantPool constant_pool;
private Method method;
private static final String NEWLINE = System.getProperty("line.separator", "\n");
}
/*
* 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.
*/
package com.sun.tools.jdeps;
import com.sun.tools.classfile.Dependency;
import com.sun.tools.classfile.Dependency.Location;
import java.io.File;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
/**
* Represents the source of the class files.
*/
public class Archive {
private static Map<String,Archive> archiveForClass = new HashMap<String,Archive>();
public static Archive find(Location loc) {
return archiveForClass.get(loc.getName());
}
private final File file;
private final String filename;
private final DependencyRecorder recorder;
private final ClassFileReader reader;
public Archive(String name) {
this.file = null;
this.filename = name;
this.recorder = new DependencyRecorder();
this.reader = null;
}
public Archive(File f, ClassFileReader reader) {
this.file = f;
this.filename = f.getName();
this.recorder = new DependencyRecorder();
this.reader = reader;
}
public ClassFileReader reader() {
return reader;
}
public String getFileName() {
return filename;
}
public void addClass(String classFileName) {
Archive a = archiveForClass.get(classFileName);
assert(a == null || a == this); // ## issue warning?
if (!archiveForClass.containsKey(classFileName)) {
archiveForClass.put(classFileName, this);
}
}
public void addDependency(Dependency d) {
recorder.addDependency(d);
}
/**
* Returns a sorted map of a class to its dependencies.
*/
public SortedMap<Location, SortedSet<Location>> getDependencies() {
DependencyRecorder.Filter filter = new DependencyRecorder.Filter() {
public boolean accept(Location origin, Location target) {
return (archiveForClass.get(origin.getName()) !=
archiveForClass.get(target.getName()));
}};
SortedMap<Location, SortedSet<Location>> result =
new TreeMap<Location, SortedSet<Location>>(locationComparator);
for (Map.Entry<Location, Set<Location>> e : recorder.dependencies().entrySet()) {
Location o = e.getKey();
for (Location t : e.getValue()) {
if (filter.accept(o, t)) {
SortedSet<Location> odeps = result.get(o);
if (odeps == null) {
odeps = new TreeSet<Location>(locationComparator);
result.put(o, odeps);
}
odeps.add(t);
}
}
}
return result;
}
/**
* Returns the set of archives this archive requires.
*/
public Set<Archive> getRequiredArchives() {
SortedSet<Archive> deps = new TreeSet<Archive>(new Comparator<Archive>() {
public int compare(Archive a1, Archive a2) {
return a1.toString().compareTo(a2.toString());
}
});
for (Map.Entry<Location, Set<Location>> e : recorder.dependencies().entrySet()) {
Location o = e.getKey();
Archive origin = Archive.find(o);
for (Location t : e.getValue()) {
Archive target = Archive.find(t);
assert(origin != null && target != null);
if (origin != target) {
if (!deps.contains(target)) {
deps.add(target);
}
}
}
}
return deps;
}
public String toString() {
return file != null ? file.getPath() : filename;
}
private static class DependencyRecorder {
static interface Filter {
boolean accept(Location origin, Location target);
}
public void addDependency(Dependency d) {
Set<Location> odeps = map.get(d.getOrigin());
if (odeps == null) {
odeps = new HashSet<Location>();
map.put(d.getOrigin(), odeps);
}
odeps.add(d.getTarget());
}
public Map<Location, Set<Location>> dependencies() {
return map;
}
private final Map<Location, Set<Location>> map =
new HashMap<Location, Set<Location>>();
}
private static Comparator<Location> locationComparator =
new Comparator<Location>() {
public int compare(Location o1, Location o2) {
return o1.toString().compareTo(o2.toString());
}
};
}
/*
* 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.
*/
package com.sun.tools.jdeps;
import com.sun.tools.classfile.ClassFile;
import com.sun.tools.classfile.ConstantPoolException;
import com.sun.tools.classfile.Dependencies.ClassFileError;
import java.io.*;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
/**
* ClassFileReader reads ClassFile(s) of a given path that can be
* a .class file, a directory, or a JAR file.
*/
public class ClassFileReader {
/**
* Returns a ClassFileReader instance of a given path.
*/
public static ClassFileReader newInstance(File path) throws IOException {
if (!path.exists()) {
throw new FileNotFoundException(path.getAbsolutePath());
}
if (path.isDirectory()) {
return new DirectoryReader(path.toPath());
} else if (path.getName().endsWith(".jar")) {
return new JarFileReader(path.toPath());
} else {
return new ClassFileReader(path.toPath());
}
}
protected final Path path;
protected final String baseFileName;
private ClassFileReader(Path path) {
this.path = path;
this.baseFileName = path.getFileName() != null
? path.getFileName().toString()
: path.toString();
}
public String getFileName() {
return baseFileName;
}
/**
* Returns the ClassFile matching the given binary name
* or a fully-qualified class name.
*/
public ClassFile getClassFile(String name) throws IOException {
if (name.indexOf('.') > 0) {
int i = name.lastIndexOf('.');
String pathname = name.replace('.', File.separatorChar) + ".class";
if (baseFileName.equals(pathname) ||
baseFileName.equals(pathname.substring(0, i) + "$" +
pathname.substring(i+1, pathname.length()))) {
return readClassFile(path);
}
} else {
if (baseFileName.equals(name.replace('/', File.separatorChar) + ".class")) {
return readClassFile(path);
}
}
return null;
}
public Iterable<ClassFile> getClassFiles() throws IOException {
return new Iterable<ClassFile>() {
public Iterator<ClassFile> iterator() {
return new FileIterator();
}
};
}
protected ClassFile readClassFile(Path p) throws IOException {
InputStream is = null;
try {
is = Files.newInputStream(p);
return ClassFile.read(is);
} catch (ConstantPoolException e) {
throw new ClassFileError(e);
} finally {
if (is != null) {
is.close();
}
}
}
class FileIterator implements Iterator<ClassFile> {
int count;
FileIterator() {
this.count = 0;
}
public boolean hasNext() {
return count == 0 && baseFileName.endsWith(".class");
}
public ClassFile next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
try {
ClassFile cf = readClassFile(path);
count++;
return cf;
} catch (IOException e) {
throw new ClassFileError(e);
}
}
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
public String toString() {
return path.toString();
}
private static class DirectoryReader extends ClassFileReader {
DirectoryReader(Path path) throws IOException {
super(path);
}
public ClassFile getClassFile(String name) throws IOException {
if (name.indexOf('.') > 0) {
int i = name.lastIndexOf('.');
String pathname = name.replace('.', File.separatorChar) + ".class";
Path p = path.resolve(pathname);
if (!p.toFile().exists()) {
p = path.resolve(pathname.substring(0, i) + "$" +
pathname.substring(i+1, pathname.length()));
}
if (p.toFile().exists()) {
return readClassFile(p);
}
} else {
Path p = path.resolve(name + ".class");
if (p.toFile().exists()) {
return readClassFile(p);
}
}
return null;
}
public Iterable<ClassFile> getClassFiles() throws IOException {
final Iterator<ClassFile> iter = new DirectoryIterator();
return new Iterable<ClassFile>() {
public Iterator<ClassFile> iterator() {
return iter;
}
};
}
private List<Path> walkTree(Path dir) throws IOException {
final List<Path> files = new ArrayList<Path>();
Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
throws IOException {
if (file.toFile().getName().endsWith(".class")) {
files.add(file);
}
return FileVisitResult.CONTINUE;
}
});
return files;
}
class DirectoryIterator implements Iterator<ClassFile> {
private List<Path> entries;
private int index = 0;
DirectoryIterator() throws IOException {
entries = walkTree(path);
index = 0;
}
public boolean hasNext() {
return index != entries.size();
}
public ClassFile next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
Path path = entries.get(index++);
try {
return readClassFile(path);
} catch (IOException e) {
throw new ClassFileError(e);
}
}
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
}
private static class JarFileReader extends ClassFileReader {
final JarFile jarfile;
JarFileReader(Path path) throws IOException {
super(path);
this.jarfile = new JarFile(path.toFile());
}
public ClassFile getClassFile(String name) throws IOException {
if (name.indexOf('.') > 0) {
int i = name.lastIndexOf('.');
String entryName = name.replace('.', '/') + ".class";
JarEntry e = jarfile.getJarEntry(entryName);
if (e == null) {
e = jarfile.getJarEntry(entryName.substring(0, i) + "$"
+ entryName.substring(i + 1, entryName.length()));
}
if (e != null) {
return readClassFile(e);
}
} else {
JarEntry e = jarfile.getJarEntry(name + ".class");
if (e != null) {
return readClassFile(e);
}
}
return null;
}
private ClassFile readClassFile(JarEntry e) throws IOException {
InputStream is = null;
try {
is = jarfile.getInputStream(e);
return ClassFile.read(is);
} catch (ConstantPoolException ex) {
throw new ClassFileError(ex);
} finally {
if (is != null)
is.close();
}
}
public Iterable<ClassFile> getClassFiles() throws IOException {
final Iterator<ClassFile> iter = new JarFileIterator();
return new Iterable<ClassFile>() {
public Iterator<ClassFile> iterator() {
return iter;
}
};
}
class JarFileIterator implements Iterator<ClassFile> {
private Enumeration<JarEntry> entries;
private JarEntry nextEntry;
JarFileIterator() {
this.entries = jarfile.entries();
while (entries.hasMoreElements()) {
JarEntry e = entries.nextElement();
String name = e.getName();
if (name.endsWith(".class")) {
this.nextEntry = e;
break;
}
}
}
public boolean hasNext() {
return nextEntry != null;
}
public ClassFile next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
ClassFile cf;
try {
cf = readClassFile(nextEntry);
} catch (IOException ex) {
throw new ClassFileError(ex);
}
JarEntry entry = nextEntry;
nextEntry = null;
while (entries.hasMoreElements()) {
JarEntry e = entries.nextElement();
String name = e.getName();
if (name.endsWith(".class")) {
nextEntry = e;
break;
}
}
return cf;
}
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
}
}
此差异已折叠。
/*
* 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.
*/
package com.sun.tools.jdeps;
import java.io.*;
/**
*
* Usage:
* jdeps [options] files ...
* where options include:
* -p package-name restrict analysis to classes in this package
* (may be given multiple times)
* -e regex restrict analysis to packages matching pattern
* (-p and -e are exclusive)
* -v show class-level dependencies
* default: package-level dependencies
* -r --recursive transitive dependencies analysis
* -classpath paths Classpath to locate class files
* -all process all class files in the given classpath
*/
public class Main {
public static void main(String... args) throws Exception {
JdepsTask t = new JdepsTask();
int rc = t.run(args);
System.exit(rc);
}
/**
* Entry point that does <i>not</i> call System.exit.
*
* @param args command line arguments
* @param out output stream
* @return an exit code. 0 means success, non-zero means an error occurred.
*/
public static int run(String[] args, PrintWriter out) {
JdepsTask t = new JdepsTask();
t.setLog(out);
return t.run(args);
}
}
/*
* 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.
*/
package com.sun.tools.jdeps;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
/**
* ClassPath for Java SE and JDK
*/
class PlatformClassPath {
/*
* Profiles for Java SE
*
* This is a temporary workaround until a common API is defined for langtools
* to determine which profile a given classname belongs to. The list of
* packages and profile names are hardcoded in jdk.properties and
* split packages are not supported.
*/
static class Profile {
final String name;
final Set<String> packages;
Profile(String name) {
this.name = name;
this.packages = new HashSet<String>();
}
}
private final static String JAVAFX = "javafx";
private final static Map<String,Profile> map = getProfilePackages();
static String getProfileName(String packageName) {
Profile profile = map.get(packageName);
if (packageName.startsWith(JAVAFX + ".")) {
profile = map.get(JAVAFX);
}
return profile != null ? profile.name : "";
}
private final static List<Archive> javaHomeArchives = init();
static List<Archive> getArchives() {
return javaHomeArchives;
}
static boolean contains(Archive archive) {
return javaHomeArchives.contains(archive);
}
private static List<Archive> init() {
List<Archive> result = new ArrayList<Archive>();
String javaHome = System.getProperty("java.home");
List<File> files = new ArrayList<File>();
File jre = new File(javaHome, "jre");
File lib = new File(javaHome, "lib");
try {
if (jre.exists() && jre.isDirectory()) {
result.addAll(addJarFiles(new File(jre, "lib")));
result.addAll(addJarFiles(lib));
} else if (lib.exists() && lib.isDirectory()) {
// either a JRE or a jdk build image
File classes = new File(javaHome, "classes");
if (classes.exists() && classes.isDirectory()) {
// jdk build outputdir
result.add(new Archive(classes, ClassFileReader.newInstance(classes)));
}
// add other JAR files
result.addAll(addJarFiles(lib));
} else {
throw new RuntimeException("\"" + javaHome + "\" not a JDK home");
}
} catch (IOException e) {
throw new RuntimeException(e);
}
// add a JavaFX profile if there is jfxrt.jar
for (Archive archive : result) {
if (archive.getFileName().equals("jfxrt.jar")) {
map.put(JAVAFX, new Profile("jfxrt.jar"));
}
}
return result;
}
private static List<Archive> addJarFiles(File f) throws IOException {
final List<Archive> result = new ArrayList<Archive>();
final Path root = f.toPath();
final Path ext = root.resolve("ext");
Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
throws IOException
{
if (dir.equals(root) || dir.equals(ext)) {
return FileVisitResult.CONTINUE;
} else {
// skip other cobundled JAR files
return FileVisitResult.SKIP_SUBTREE;
}
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
throws IOException
{
File f = file.toFile();
String fn = f.getName();
if (fn.endsWith(".jar") && !fn.equals("alt-rt.jar")) {
result.add(new Archive(f, ClassFileReader.newInstance(f)));
}
return FileVisitResult.CONTINUE;
}
});
return result;
}
private static Map<String,Profile> getProfilePackages() {
Map<String,Profile> map = new HashMap<String,Profile>();
// read the properties as a ResourceBundle as the build compiles
// the properties file into Java class. Another alternative is
// to load it as Properties and fix the build to exclude this file.
ResourceBundle profileBundle =
ResourceBundle.getBundle("com.sun.tools.jdeps.resources.jdk");
int i=1;
String key;
while (profileBundle.containsKey((key = "profile." + i + ".name"))) {
Profile profile = new Profile(profileBundle.getString(key));
String n = profileBundle.getString("profile." + i + ".packages");
String[] pkgs = n.split("\\s+");
for (String p : pkgs) {
if (p.isEmpty()) continue;
assert(map.containsKey(p) == false);
profile.packages.add(p);
map.put(p, profile);
}
i++;
}
return map;
}
}
main.usage.summary=\
Usage: {0} <options> <classes...>\n\
use -h, -? or --help for a list of possible options
main.usage=\
Usage: {0} <options> <classes...>\n\
where <classes> can be a pathname to a .class file, a directory, a JAR file,\n\
or a fully-qualified classname or wildcard "*". Possible options include:
error.prefix=Error:
warn.prefix=Warning:
main.opt.h=\
\ -h -? --help Print this usage message
main.opt.version=\
\ --version Version information
main.opt.V=\
\ -V <level> --verbose-level=<level> Print package-level or class-level dependencies\n\
\ Valid levels are: "package" and "class"
main.opt.v=\
\ -v --verbose Print additional information
main.opt.s=\
\ -s --summary Print dependency summary only
main.opt.p=\
\ -p <pkg name> --package=<pkg name> Restrict analysis to classes in this package\n\
\ (may be given multiple times)
main.opt.e=\
\ -e <regex> --regex=<regex> Restrict analysis to packages matching pattern\n\
\ (-p and -e are exclusive)
main.opt.P=\
\ -P --profile Show profile or the file containing a package
main.opt.c=\
\ -c <path> --classpath=<path> Specify where to find class files
main.opt.R=\
\ -R --recursive Recursively traverse all dependencies
main.opt.d=\
\ -d <depth> --depth=<depth> Specify the depth of the transitive dependency analysis
err.unknown.option=unknown option: {0}
err.missing.arg=no value given for {0}
err.internal.error=internal error: {0} {1} {2}
err.invalid.arg.for.option=invalid argument for option: {0}
err.option.after.class=option must be specified before classes: {0}
warn.invalid.arg=Invalid classname or pathname not exist: {0}
warn.split.package=package {0} defined in {1} {2}
artifact.not.found=not found
# This properties file does not need localization.
profile.1.name = compact1
profile.1.packages = \
java.io \
java.lang \
java.lang.annotation \
java.lang.invoke \
java.lang.ref \
java.lang.reflect \
java.math \
java.net \
java.nio \
java.nio.channels \
java.nio.channels.spi \
java.nio.charset \
java.nio.charset.spi \
java.nio.file \
java.nio.file.attribute \
java.nio.file.spi \
java.security \
java.security.cert \
java.security.interfaces \
java.security.spec \
java.text \
java.text.spi \
java.util \
java.util.concurrent \
java.util.concurrent.atomic \
java.util.concurrent.locks \
java.util.jar \
java.util.logging \
java.util.regex \
java.util.spi \
java.util.zip \
javax.crypto \
javax.crypto.interfaces \
javax.crypto.spec \
javax.security.auth \
javax.security.auth.callback \
javax.security.auth.login \
javax.security.auth.spi \
javax.security.auth.x500 \
javax.net \
javax.net.ssl \
javax.security.cert \
\
com.sun.net.ssl \
com.sun.nio.file \
com.sun.nio.sctp \
com.sun.security.auth \
com.sun.security.auth.login
profile.2.name = compact2
profile.2.packages = \
java.sql \
javax.sql \
javax.xml \
javax.xml.datatype \
javax.xml.namespace \
javax.xml.parsers \
javax.xml.stream \
javax.xml.stream.events \
javax.xml.stream.util \
javax.xml.transform \
javax.xml.transform.dom \
javax.xml.transform.sax \
javax.xml.transform.stax \
javax.xml.transform.stream \
javax.xml.validation \
javax.xml.xpath \
org.w3c.dom \
org.w3c.dom.bootstrap \
org.w3c.dom.events \
org.w3c.dom.ls \
org.xml.sax \
org.xml.sax.ext \
org.xml.sax.helpers \
java.rmi \
java.rmi.activation \
java.rmi.dgc \
java.rmi.registry \
java.rmi.server \
javax.rmi.ssl \
javax.transaction \
javax.transaction.xa \
\
com.sun.net.httpserver \
com.sun.net.httpserver.spi
profile.3.name = compact3
profile.3.packages = \
java.lang.instrument \
java.lang.management \
java.security.acl \
java.util.prefs \
javax.management \
javax.management.loading \
javax.management.modelmbean \
javax.management.monitor \
javax.management.openmbean \
javax.management.relation \
javax.management.remote \
javax.management.remote.rmi \
javax.management.timer \
javax.naming \
javax.naming.directory \
javax.naming.event \
javax.naming.ldap \
javax.naming.spi \
javax.sql.rowset \
javax.sql.rowset.serial \
javax.sql.rowset.spi \
javax.security.auth.kerberos \
javax.security.sasl \
javax.script \
javax.smartcardio \
javax.xml.crypto \
javax.xml.crypto.dom \
javax.xml.crypto.dsig \
javax.xml.crypto.dsig.dom \
javax.xml.crypto.dsig.keyinfo \
javax.xml.crypto.dsig.spec \
javax.annotation.processing \
javax.lang.model \
javax.lang.model.element \
javax.lang.model.type \
javax.lang.model.util \
javax.tools \
javax.tools.annotation \
org.ietf.jgss \
\
com.sun.management \
com.sun.security.auth.callback \
com.sun.security.auth.module \
com.sun.security.jgss
profile.4.name = Full JRE
profile.4.packages = \
java.applet \
java.awt \
java.awt.color \
java.awt.datatransfer \
java.awt.dnd \
java.awt.dnd.peer \
java.awt.event \
java.awt.font \
java.awt.geom \
java.awt.im \
java.awt.im.spi \
java.awt.image \
java.awt.image.renderable \
java.awt.peer \
java.awt.print \
java.beans \
java.beans.beancontext \
javax.accessibility \
javax.imageio \
javax.imageio.event \
javax.imageio.metadata \
javax.imageio.plugins.bmp \
javax.imageio.plugins.jpeg \
javax.imageio.spi \
javax.imageio.stream \
javax.print \
javax.print.attribute \
javax.print.attribute.standard \
javax.print.event \
javax.sound.midi \
javax.sound.midi.spi \
javax.sound.sampled \
javax.sound.sampled.spi \
javax.swing \
javax.swing.border \
javax.swing.colorchooser \
javax.swing.event \
javax.swing.filechooser \
javax.swing.plaf \
javax.swing.plaf.basic \
javax.swing.plaf.metal \
javax.swing.plaf.multi \
javax.swing.plaf.nimbus \
javax.swing.plaf.synth \
javax.swing.table \
javax.swing.text \
javax.swing.text.html \
javax.swing.text.html.parser \
javax.swing.text.rtf \
javax.swing.tree \
javax.swing.undo \
javax.activation \
javax.jws \
javax.jws.soap \
javax.rmi \
javax.rmi.CORBA \
javax.xml.bind \
javax.xml.bind.annotation \
javax.xml.bind.annotation.adapters \
javax.xml.bind.attachment \
javax.xml.bind.helpers \
javax.xml.bind.util \
javax.xml.soap \
javax.xml.ws \
javax.xml.ws.handler \
javax.xml.ws.handler.soap \
javax.xml.ws.http \
javax.xml.ws.soap \
javax.xml.ws.spi \
javax.xml.ws.spi.http \
javax.xml.ws.wsaddressing \
javax.annotation \
org.omg.CORBA \
org.omg.CORBA.DynAnyPackage \
org.omg.CORBA.ORBPackage \
org.omg.CORBA.TypeCodePackage \
org.omg.CORBA.portable \
org.omg.CORBA_2_3 \
org.omg.CORBA_2_3.portable \
org.omg.CosNaming \
org.omg.CosNaming.NamingContextExtPackage \
org.omg.CosNaming.NamingContextPackage \
org.omg.Dynamic \
org.omg.DynamicAny \
org.omg.DynamicAny.DynAnyFactoryPackage \
org.omg.DynamicAny.DynAnyPackage \
org.omg.IOP \
org.omg.IOP.CodecFactoryPackage \
org.omg.IOP.CodecPackage \
org.omg.Messaging \
org.omg.PortableInterceptor \
org.omg.PortableInterceptor.ORBInitInfoPackage \
org.omg.PortableServer \
org.omg.PortableServer.CurrentPackage \
org.omg.PortableServer.POAManagerPackage \
org.omg.PortableServer.POAPackage \
org.omg.PortableServer.ServantLocatorPackage \
org.omg.PortableServer.portable \
org.omg.SendingContext \
org.omg.stub.java.rmi \
org.omg.stub.javax.management.remote.rmi
# Remaining JDK supported API
profile.5.name = JDK tools
profile.5.packages = \
com.sun.jdi \
com.sun.jdi.connect \
com.sun.jdi.connect.spi \
com.sun.jdi.event \
com.sun.jdi.request \
com.sun.javadoc \
com.sun.tools.doclets \
com.sun.tools.doctree \
com.sun.source.tree \
com.sun.source.util \
com.sun.tools.attach \
com.sun.tools.attach.spi \
com.sun.tools.jconsole \
com.sun.tools.javac \
com.sun.tools.javah \
com.sun.tools.javap \
com.sun.tools.javadoc \
com.sun.servicetag
#
# 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.
#
jdk=$(JDK_VERSION)
full=$(FULL_VERSION)
release=$(RELEASE)
......@@ -179,6 +179,10 @@ public interface Element {
* instance initializer}, an empty name is returned.
*
* @return the simple name of this element
* @see PackageElement#getSimpleName
* @see ExecutableElement#getSimpleName
* @see TypeElement#getSimpleName
* @see VariableElement#getSimpleName
*/
Name getSimpleName();
......@@ -202,6 +206,11 @@ public interface Element {
* {@linkplain TypeParameterElement#getGenericElement the
* generic element} of the type parameter is returned.
*
* <li> If this is a {@linkplain
* VariableElement#getEnclosingElement method or constructor
* parameter}, {@linkplain ExecutableElement the executable
* element} which declares the parameter is returned.
*
* </ul>
*
* @return the enclosing element, or {@code null} if there is none
......
......@@ -62,4 +62,29 @@ public interface VariableElement extends Element {
* @jls 4.12.4 final Variables
*/
Object getConstantValue();
/**
* Returns the simple name of this variable element.
*
* <p>For method and constructor parameters, the name of each
* parameter must be distinct from the names of all other
* parameters of the same executable. If the original source
* names are not available, an implementation may synthesize names
* subject to the distinctness requirement above.
*
* @return the simple name of this variable element
*/
@Override
Name getSimpleName();
/**
* Returns the enclosing element of this variable.
*
* The enclosing element of a method or constructor parameter is
* the executable declaring the parameter.
*
* @return the enclosing element of this variable
*/
@Override
Element getEnclosingElement();
}
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
......@@ -48,9 +48,12 @@
* {@linkplain java.lang.annotation.RetentionPolicy#SOURCE source}
* {@linkplain java.lang.annotation.Retention retention} cannot be
* recovered from class files and class files might not be able to
* provide source position information. The {@linkplain
* javax.lang.model.element.Modifier modifiers} on an element may
* differ in some cases including
* provide source position information.
*
* Names of parameters may not be recoverable from class files.
*
* The {@linkplain javax.lang.model.element.Modifier modifiers} on an
* element may differ in some cases including:
*
* <ul>
* <li> {@code strictfp} on a class or interface
......
......@@ -229,7 +229,7 @@ JCK_RUNTIME_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jck-runtime-Xcompile
all: $(JPRT_CLEAN) jtreg-tests jck-compiler-tests jck-runtime-tests $(JPRT_ARCHIVE_BUNDLE) all-summary
@echo "Testing completed successfully"
jtreg apt javac javadoc javah javap: $(JPRT_CLEAN) jtreg-tests $(JPRT_ARCHIVE_BUNDLE) jtreg-summary
jtreg apt javac javadoc javah javap jdeps: $(JPRT_CLEAN) jtreg-tests $(JPRT_ARCHIVE_BUNDLE) jtreg-summary
@echo "Testing completed successfully"
jck-compiler: $(JPRT_CLEAN) jck-compiler-tests $(JPRT_ARCHIVE_BUNDLE) jck-compiler-summary
......@@ -246,6 +246,7 @@ javac: JTREG_TESTDIRS = tools/javac
javadoc: JTREG_TESTDIRS = tools/javadoc com/sun/javadoc
javah: JTREG_TESTDIRS = tools/javah
javap: JTREG_TESTDIRS = tools/javap
jdeps: JTREG_TESTDIRS = tools/jdeps
# Run jtreg tests
#
......@@ -426,7 +427,7 @@ FRC:
# Phony targets (e.g. these are not filenames)
.PHONY: all clean \
jtreg javac javadoc javah javap jtreg-tests jtreg-summary check-jtreg \
jtreg javac javadoc javah javap jdeps jtreg-tests jtreg-summary check-jtreg \
jck-compiler jck-compiler-tests jck-compiler-summary \
jck-runtime jck-runtime-tests jck-runtime-summary check-jck
......
/*
* 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.
*
* 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 8004891
* @summary Make sure that the abstract method is identified correctly
* if the abstract modifier is present explicitly or implicitly.
* @author bpatel
* @library ../lib/
* @build JavadocTester TestAbstractMethod
* @run main TestAbstractMethod
*/
public class TestAbstractMethod extends JavadocTester {
//Test information.
private static final String BUG_ID = "8004891";
//Javadoc arguments.
private static final String[] ARGS = new String[] {
"-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
};
//Input for string search tests.
private static final String[][] TEST = {
{BUG_ID + FS + "pkg" + FS + "A.html",
"<td class=\"colFirst\"><code>default void</code></td>"},
{BUG_ID + FS + "pkg" + FS + "A.html",
"<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
"All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t2\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" " +
"class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
"Abstract Methods</a></span><span class=\"tabEnd\">&nbsp;</span>" +
"</span><span id=\"t5\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(16);\">Default Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span></caption>"},
{BUG_ID + FS + "pkg" + FS + "B.html",
"<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
"All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t2\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span><span id=\"t3\" " +
"class=\"tableTab\"><span><a href=\"javascript:show(4);\">Abstract " +
"Methods</a></span><span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t4\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(8);\">Concrete Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span></caption>"},
{BUG_ID + FS + "pkg" + FS + "B.html",
"<td class=\"colFirst\"><code>abstract void</code></td>"},
{BUG_ID + FS + "pkg" + FS + "C.html",
"<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
"All Methods</span><span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t2\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span>" +
"<span id=\"t5\" class=\"tableTab\"><span>" +
"<a href=\"javascript:show(16);\">Default Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span></span></caption>"},
{BUG_ID + FS + "pkg" + FS + "C.html",
"<td class=\"colFirst\"><code>default void</code></td>"}
};
private static final String[][] NEGATED_TEST = {
{BUG_ID + FS + "pkg" + FS + "A.html",
"<td class=\"colFirst\"><code>abstract void</code></td>"},
{BUG_ID + FS + "pkg" + FS + "B.html",
"<span><a href=\"javascript:show(16);\">Default Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span>"},
{BUG_ID + FS + "pkg" + FS + "B.html",
"<td class=\"colFirst\"><code>default void</code></td>"},
{BUG_ID + FS + "pkg" + FS + "C.html",
"<span><a href=\"javascript:show(4);\">Abstract Methods</a></span>" +
"<span class=\"tabEnd\">&nbsp;</span>"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestAbstractMethod tester = new TestAbstractMethod();
run(tester, ARGS, TEST, NEGATED_TEST);
tester.printSummary();
}
/**
* {@inheritDoc}
*/
public String getBugId() {
return BUG_ID;
}
/**
* {@inheritDoc}
*/
public String getBugName() {
return getClass().getName();
}
}
/*
* 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.
*
* 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 interface A {
public void method1();
public default void defaultMethod() { }
}
/*
* 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.
*
* 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 abstract class B {
public abstract void method1();
public void method2() { }
}
/*
* 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.
*
* 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 interface C {
public default void onlyMethod() { }
}
/*
* 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.
*
* 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 8005092
* @summary Test repeated annotations output.
* @author bpatel
* @library ../lib/
* @build JavadocTester TestRepeatedAnnotations
* @run main TestRepeatedAnnotations
*/
public class TestRepeatedAnnotations extends JavadocTester {
//Test information.
private static final String BUG_ID = "8005092";
//Javadoc arguments.
private static final String[] ARGS = new String[] {
"-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg", "pkg1"
};
//Input for string search tests.
private static final String[][] TEST = {
{BUG_ID + FS + "pkg" + FS + "C.html",
"<a href=\"../pkg/ContaineeSynthDoc.html\" " +
"title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
"<a href=\"../pkg/ContaineeSynthDoc.html\" " +
"title=\"annotation in pkg\">@ContaineeSynthDoc</a>"},
{BUG_ID + FS + "pkg" + FS + "C.html",
"<a href=\"../pkg/ContaineeRegDoc.html\" " +
"title=\"annotation in pkg\">@ContaineeRegDoc</a> " +
"<a href=\"../pkg/ContaineeRegDoc.html\" " +
"title=\"annotation in pkg\">@ContaineeRegDoc</a>"},
{BUG_ID + FS + "pkg" + FS + "C.html",
"<a href=\"../pkg/RegContainerDoc.html\" " +
"title=\"annotation in pkg\">@RegContainerDoc</a>" +
"(<a href=\"../pkg/RegContainerDoc.html#value()\">value</a>={" +
"<a href=\"../pkg/RegContaineeNotDoc.html\" " +
"title=\"annotation in pkg\">@RegContaineeNotDoc</a>," +
"<a href=\"../pkg/RegContaineeNotDoc.html\" " +
"title=\"annotation in pkg\">@RegContaineeNotDoc</a>})"},
{BUG_ID + FS + "pkg" + FS + "C.html",
"<a href=\"../pkg/ContaineeSynthDoc.html\" " +
"title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
"<a href=\"../pkg/ContaineeSynthDoc.html\" " +
"title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
"<a href=\"../pkg/ContaineeSynthDoc.html\" " +
"title=\"annotation in pkg\">@ContaineeSynthDoc</a>"},
{BUG_ID + FS + "pkg" + FS + "C.html",
"<a href=\"../pkg/ContainerSynthDoc.html\" " +
"title=\"annotation in pkg\">@ContainerSynthDoc</a>(" +
"<a href=\"../pkg/ContainerSynthDoc.html#value()\">value</a>=" +
"<a href=\"../pkg/ContaineeSynthDoc.html\" " +
"title=\"annotation in pkg\">@ContaineeSynthDoc</a>)"},
{BUG_ID + FS + "pkg" + FS + "C.html",
"<a href=\"../pkg/ContaineeSynthDoc.html\" " +
"title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
"<a href=\"../pkg/ContaineeSynthDoc.html\" " +
"title=\"annotation in pkg\">@ContaineeSynthDoc</a>"},
{BUG_ID + FS + "pkg" + FS + "D.html",
"<a href=\"../pkg/RegDoc.html\" title=\"annotation in pkg\">@RegDoc</a>" +
"(<a href=\"../pkg/RegDoc.html#x()\">x</a>=1)"},
{BUG_ID + FS + "pkg" + FS + "D.html",
"<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>" +
"(<a href=\"../pkg/RegArryDoc.html#y()\">y</a>=1)"},
{BUG_ID + FS + "pkg" + FS + "D.html",
"<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>" +
"(<a href=\"../pkg/RegArryDoc.html#y()\">y</a>={1,2})"},
{BUG_ID + FS + "pkg" + FS + "D.html",
"<a href=\"../pkg/NonSynthDocContainer.html\" " +
"title=\"annotation in pkg\">@NonSynthDocContainer</a>" +
"(<a href=\"../pkg/NonSynthDocContainer.html#value()\">value</a>=" +
"<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>)"},
{BUG_ID + FS + "pkg1" + FS + "C.html",
"<a href=\"../pkg1/RegContainerValDoc.html\" " +
"title=\"annotation in pkg1\">@RegContainerValDoc</a>" +
"(<a href=\"../pkg1/RegContainerValDoc.html#value()\">value</a>={" +
"<a href=\"../pkg1/RegContaineeNotDoc.html\" " +
"title=\"annotation in pkg1\">@RegContaineeNotDoc</a>," +
"<a href=\"../pkg1/RegContaineeNotDoc.html\" " +
"title=\"annotation in pkg1\">@RegContaineeNotDoc</a>}," +
"<a href=\"../pkg1/RegContainerValDoc.html#y()\">y</a>=3)"},
{BUG_ID + FS + "pkg1" + FS + "C.html",
"<a href=\"../pkg1/ContainerValDoc.html\" " +
"title=\"annotation in pkg1\">@ContainerValDoc</a>" +
"(<a href=\"../pkg1/ContainerValDoc.html#value()\">value</a>={" +
"<a href=\"../pkg1/ContaineeNotDoc.html\" " +
"title=\"annotation in pkg1\">@ContaineeNotDoc</a>," +
"<a href=\"../pkg1/ContaineeNotDoc.html\" " +
"title=\"annotation in pkg1\">@ContaineeNotDoc</a>}," +
"<a href=\"../pkg1/ContainerValDoc.html#x()\">x</a>=1)"}
};
private static final String[][] NEGATED_TEST = {
{BUG_ID + FS + "pkg" + FS + "C.html",
"<a href=\"../pkg/RegContaineeDoc.html\" " +
"title=\"annotation in pkg\">@RegContaineeDoc</a> " +
"<a href=\"../pkg/RegContaineeDoc.html\" " +
"title=\"annotation in pkg\">@RegContaineeDoc</a>"},
{BUG_ID + FS + "pkg" + FS + "C.html",
"<a href=\"../pkg/RegContainerNotDoc.html\" " +
"title=\"annotation in pkg\">@RegContainerNotDoc</a>" +
"(<a href=\"../pkg/RegContainerNotDoc.html#value()\">value</a>={" +
"<a href=\"../pkg/RegContaineeNotDoc.html\" " +
"title=\"annotation in pkg\">@RegContaineeNotDoc</a>," +
"<a href=\"../pkg/RegContaineeNotDoc.html\" " +
"title=\"annotation in pkg\">@RegContaineeNotDoc</a>})"},
{BUG_ID + FS + "pkg1" + FS + "C.html",
"<a href=\"../pkg1/ContaineeSynthDoc.html\" " +
"title=\"annotation in pkg1\">@ContaineeSynthDoc</a> " +
"<a href=\"../pkg1/ContaineeSynthDoc.html\" " +
"title=\"annotation in pkg1\">@ContaineeSynthDoc</a>"},
{BUG_ID + FS + "pkg1" + FS + "C.html",
"<a href=\"../pkg1/RegContainerValNotDoc.html\" " +
"title=\"annotation in pkg1\">@RegContainerValNotDoc</a>" +
"(<a href=\"../pkg1/RegContainerValNotDoc.html#value()\">value</a>={" +
"<a href=\"../pkg1/RegContaineeDoc.html\" " +
"title=\"annotation in pkg1\">@RegContaineeDoc</a>," +
"<a href=\"../pkg1/RegContaineeDoc.html\" " +
"title=\"annotation in pkg1\">@RegContaineeDoc</a>}," +
"<a href=\"../pkg1/RegContainerValNotDoc.html#y()\">y</a>=4)"},
{BUG_ID + FS + "pkg1" + FS + "C.html",
"<a href=\"../pkg1/ContainerValNotDoc.html\" " +
"title=\"annotation in pkg1\">@ContainerValNotDoc</a>" +
"(<a href=\"../pkg1/ContainerValNotDoc.html#value()\">value</a>={" +
"<a href=\"../pkg1/ContaineeNotDoc.html\" " +
"title=\"annotation in pkg1\">@ContaineeNotDoc</a>," +
"<a href=\"../pkg1/ContaineeNotDoc.html\" " +
"title=\"annotation in pkg1\">@ContaineeNotDoc</a>}," +
"<a href=\"../pkg1/ContainerValNotDoc.html#x()\">x</a>=2)"},
{BUG_ID + FS + "pkg1" + FS + "C.html",
"<a href=\"../pkg1/ContainerSynthNotDoc.html\" " +
"title=\"annotation in pkg1\">@ContainerSynthNotDoc</a>(" +
"<a href=\"../pkg1/ContainerSynthNotDoc.html#value()\">value</a>=" +
"<a href=\"../pkg1/ContaineeSynthDoc.html\" " +
"title=\"annotation in pkg1\">@ContaineeSynthDoc</a>)"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestRepeatedAnnotations tester = new TestRepeatedAnnotations();
run(tester, ARGS, TEST, NEGATED_TEST);
tester.printSummary();
}
/**
* {@inheritDoc}
*/
public String getBugId() {
return BUG_ID;
}
/**
* {@inheritDoc}
*/
public String getBugName() {
return getClass().getName();
}
}
/*
* 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.
*
* 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;
@ContainerSynthDoc(value={@ContaineeSynthDoc,@ContaineeSynthDoc})
@ContainerRegDoc(value={@ContaineeRegDoc,@ContaineeRegDoc})
@RegContainerDoc(value={@RegContaineeNotDoc,@RegContaineeNotDoc})
@ContainerRegNotDoc(value={@RegContaineeDoc,@RegContaineeDoc})
@RegContainerNotDoc(value={@RegContaineeNotDoc,@RegContaineeNotDoc})
@ContaineeSynthDoc @ContaineeSynthDoc @ContaineeSynthDoc
public class C {
@ContainerSynthDoc(value={@ContaineeSynthDoc})
public void test1() {}
@ContaineeSynthDoc @ContaineeSynthDoc
public void test2() {}
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a documented annotation contained by ContainerRegDoc.
* It will be used to annotate Class C using a non-synthesized form.
*
* @author Bhavesh Patel
*/
@Documented
public @interface ContaineeRegDoc {
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a documented synthesized annotation contained by ContainerSynthDoc.
* It will be used to annotate Class C and a method in the class using a synthesized form.
*
* @author Bhavesh Patel
*/
@Documented
@ContainedBy(ContainerSynthDoc.class)
public @interface ContaineeSynthDoc {
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a documented annotation container for ContaineeRegDoc.
* It will be used to annotate Class C using a non-synthesized form.
*
* @author Bhavesh Patel
*/
@Documented
public @interface ContainerRegDoc {
ContaineeRegDoc[] value();
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a non-documented annotation container for RegContaineeDoc.
* It will be used to annotate Class C using a non-synthesized form.
*
* @author Bhavesh Patel
*/
public @interface ContainerRegNotDoc {
RegContaineeDoc[] value();
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a documented synthesized annotation container for ContaineeSynthDoc.
* It will be used to annotate Class C and a method in the class using a synthesized form.
*
* @author Bhavesh Patel
*/
@Documented
@ContainerFor(ContaineeSynthDoc.class)
public @interface ContainerSynthDoc {
ContaineeSynthDoc[] value();
}
/*
* 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.
*
* 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;
@RegDoc(x=1)
public class D {
@RegArryDoc(y={1})
public void test1() {}
@RegArryDoc(y={1,2})
public void test2() {}
@NonSynthDocContainer(value={@RegArryDoc})
public void test3() {}
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a documented annotation.
* It will be used to annotate methods in class D.
*
* @author Bhavesh Patel
*/
@Documented
public @interface NonSynthDocContainer {
RegArryDoc[] value();
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a documented annotation.
* It will be used to annotate methods in Class D.
*
* @author Bhavesh Patel
*/
@Documented
public @interface RegArryDoc {
int[] y();
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a documented annotation contained by ContainerRegNotDoc.
* It will be used to annotate Class C using a non-synthesized form.
*
* @author Bhavesh Patel
*/
@Documented
public @interface RegContaineeDoc {
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a non-documented annotation contained by RegContainerNotDoc
* and RegContainerDoc.
* It will be used to annotate Class C using a non-synthesized form.
*
* @author Bhavesh Patel
*/
public @interface RegContaineeNotDoc {
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a documented annotation container for RegContainerDoc.
* It will be used to annotate Class C using a non-synthesized form.
*
* @author Bhavesh Patel
*/
@Documented
public @interface RegContainerDoc {
RegContaineeNotDoc[] value();
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a non-documented annotation container for RegContaineeNotDoc.
* It will be used to annotate Class C using a non-synthesized form.
*
* @author Bhavesh Patel
*/
public @interface RegContainerNotDoc {
RegContaineeNotDoc[] value();
}
/*
* 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.
*
* 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;
import java.lang.annotation.*;
/**
* This annotation is a documented annotation.
* It will be used to annotate Class D.
*
* @author Bhavesh Patel
*/
@Documented
public @interface RegDoc {
int x();
}
/*
* 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.
*
* 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;
@ContainerSynthNotDoc(value={@ContaineeSynthDoc,@ContaineeSynthDoc})
@RegContainerValDoc(value={@RegContaineeNotDoc,@RegContaineeNotDoc},y=3)
@ContainerValDoc(value={@ContaineeNotDoc,@ContaineeNotDoc},x=1)
@RegContainerValNotDoc(value={@RegContaineeDoc,@RegContaineeDoc},y=4)
@ContainerValNotDoc(value={@ContaineeNotDoc,@ContaineeNotDoc},x=2)
public class C {
@ContainerSynthNotDoc(value={@ContaineeSynthDoc})
public void test1() {}
@ContaineeSynthDoc @ContaineeSynthDoc
public void test2() {}
}
/*
* 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.
*
* 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.lang.annotation.*;
/**
* This annotation is a non-documented annotation contained by ContainerValNotDoc
* and ContainerValDoc.
* It will be used to annotate Class C using a non-synthesized form.
*
* @author Bhavesh Patel
*/
public @interface ContaineeNotDoc {
}
/*
* 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.
*
* 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.lang.annotation.*;
/**
* This annotation is a documented synthesized annotation contained by ContainerSynthNotDoc.
* It will be used to annotate Class C and methods in the class using a synthesized form.
*
* @author Bhavesh Patel
*/
@Documented
@ContainedBy(ContainerSynthNotDoc.class)
public @interface ContaineeSynthDoc {
}
/*
* 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.
*
* 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.lang.annotation.*;
/**
* This annotation is a non-documented synthesized annotation container for ContaineeSynthDoc.
* It will be used to annotate Class C and methods in the class using a synthesized form.
*
* @author Bhavesh Patel
*/
@ContainerFor(ContaineeSynthDoc.class)
public @interface ContainerSynthNotDoc {
ContaineeSynthDoc[] value();
}
/*
* 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.
*
* 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.lang.annotation.*;
/**
* This annotation is a documented annotation container for ContaineeNotDoc.
* It will be used to annotate Class C using a non-synthesized form.
*
* @author Bhavesh Patel
*/
@Documented
public @interface ContainerValDoc {
ContaineeNotDoc[] value();
int x();
}
/*
* 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.
*
* 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.lang.annotation.*;
/**
* This annotation is a non-documented annotation container for ContaineeNotDoc.
* It will be used to annotate Class C using a non-synthesized form.
*
* @author Bhavesh Patel
*/
public @interface ContainerValNotDoc {
ContaineeNotDoc[] value();
int x();
}
......@@ -107,7 +107,7 @@ public class DocLintTester {
private static final Pattern dirFileLine = Pattern.compile(
"(?m)" // multi-line mode
+ "^([^: ]+?)" // directory part of file name
+ "^(.*?)" // directory part of file name
+ "([A-Za-z0-9.]+:[0-9]+:)"); // file name and line number
String removeFileNames(String s) {
......
此差异已折叠。
此差异已折叠。
......@@ -25,7 +25,7 @@ class TargetType21 {
<R,A> void call(SAM3<R,A> sam) { }
void test() {
call(x -> { throw new Exception(); }); //ok - resolves to call(SAM1)
call(x -> { throw new Exception(); }); //ambiguous
call(x -> { System.out.println(""); }); //ok - resolves to call(SAM2)
call(x -> { return (Object) null; }); //error - call(SAM3) is not applicable because of cyclic inference
call(x -> { return null; }); ////ok - resolves to call(SAM1)
......
TargetType21.java:28:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, call(TargetType21.SAM2), TargetType21
TargetType21.java:30:9: compiler.err.cant.apply.symbols: kindname.method, call, @755,{(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, <R,A>call(TargetType21.SAM3<R,A>), (compiler.misc.cyclic.inference: A))}
TargetType21.java:30:9: compiler.err.cant.apply.symbols: kindname.method, call, @737,{(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, <R,A>call(TargetType21.SAM3<R,A>), (compiler.misc.cyclic.inference: A))}
2 errors
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册