--- a/langtools/src/share/classes/com/sun/javadoc/ClassDoc.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/javadoc/ClassDoc.java Wed Apr 09 09:20:35 2014 -0700
@@ -75,15 +75,6 @@
boolean isExternalizable();
/**
- * Return true if this class can be used as a target type of a lambda expression
- * or method reference.
- *
- * @return true if this class can be used as a target type of a lambda expression
- * or method reference.
- */
- boolean isFunctionalInterface();
-
- /**
* Return the serialization methods for this class or
* interface.
*
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
import com.sun.javadoc.*;
import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.javadoc.RootDocImpl;
import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.builders.*;
@@ -528,7 +529,7 @@
* {@inheritDoc}
*/
public void addFunctionalInterfaceInfo (Content classInfoTree) {
- if (classDoc.isFunctionalInterface()) {
+ if (isFunctionalInterface()) {
Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
Content dl = HtmlTree.DL(dt);
Content dd = new HtmlTree(HtmlTag.DD);
@@ -538,6 +539,19 @@
}
}
+ public boolean isFunctionalInterface() {
+ if (configuration.root instanceof RootDocImpl) {
+ RootDocImpl root = (RootDocImpl) configuration.root;
+ AnnotationDesc[] annotationDescList = classDoc.annotations();
+ for (AnnotationDesc annoDesc : annotationDescList) {
+ if (root.isFunctionalInterface(annoDesc)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
/**
* {@inheritDoc}
*/
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1443,7 +1443,8 @@
}
}
if (configuration.currentcd != containing) {
- refMemName = containing.name() + "." + refMemName;
+ refMemName = (refMem instanceof ConstructorDoc) ?
+ refMemName : containing.name() + "." + refMemName;
}
if (refMem instanceof ExecutableMemberDoc) {
if (refMemName.indexOf('(') < 0) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
package com.sun.tools.doclets.formats.html;
import java.io.*;
+import java.util.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.tools.doclets.internal.toolkit.*;
@@ -45,6 +46,8 @@
public class SerializedFormWriterImpl extends SubWriterHolderWriter
implements SerializedFormWriter {
+ List<ClassDoc> visibleClasses;
+
/**
* @param configuration the configuration data for the doclet
* @throws IOException
@@ -53,6 +56,7 @@
public SerializedFormWriterImpl(ConfigurationImpl configuration)
throws IOException {
super(configuration, DocPaths.SERIALIZED_FORM);
+ visibleClasses = Arrays.asList(configuration.root.classes());
}
/**
@@ -121,13 +125,23 @@
}
/**
+ * Checks if a class is generated and is visible.
+ *
+ * @param classDoc the class being processed.
+ * @return true if the class, that is being processed, is generated and is visible.
+ */
+ public boolean isVisibleClass(ClassDoc classDoc) {
+ return visibleClasses.contains(classDoc) && configuration.isGeneratedDoc(classDoc);
+ }
+
+ /**
* Get the serializable class heading.
*
* @param classDoc the class being processed
* @return a content tree for the class header
*/
public Content getClassHeader(ClassDoc classDoc) {
- Content classLink = (classDoc.isPublic() || classDoc.isProtected()) ?
+ Content classLink = (isVisibleClass(classDoc)) ?
getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, classDoc)
.label(configuration.getClassName(classDoc))) :
new StringContent(classDoc.qualifiedName());
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java Wed Apr 09 09:20:35 2014 -0700
@@ -141,6 +141,7 @@
* access this attribute.
*/
public final List<Pair<MethodSymbol,Attribute>> values;
+ public TypeAnnotationPosition position;
private boolean synthesized = false;
@@ -154,10 +155,67 @@
}
public Compound(Type type,
- List<Pair<MethodSymbol,Attribute>> values) {
+ List<Pair<MethodSymbol,Attribute>> values,
+ TypeAnnotationPosition position) {
super(type);
this.values = values;
+ this.position = position;
}
+
+ public Compound(Type type,
+ List<Pair<MethodSymbol,Attribute>> values) {
+ this(type, values, null);
+ }
+
+ @Override
+ public TypeAnnotationPosition getPosition() {
+ if (hasUnknownPosition()) {
+ if (values.size() != 0) {
+ Name valueName = values.head.fst.name.table.names.value;
+ Pair<MethodSymbol, Attribute> res = getElemPair(valueName);
+ position = res == null ? null : res.snd.getPosition();
+ }
+ }
+ return position;
+ }
+
+ public boolean isContainerTypeCompound() {
+ if (isSynthesized() && values.size() == 1)
+ return getFirstEmbeddedTC() != null;
+ return false;
+ }
+
+ private Compound getFirstEmbeddedTC() {
+ if (values.size() == 1) {
+ Pair<MethodSymbol, Attribute> val = values.get(0);
+ if (val.fst.getSimpleName().contentEquals("value")
+ && val.snd instanceof Array) {
+ Array arr = (Array) val.snd;
+ if (arr.values.length != 0
+ && arr.values[0] instanceof Attribute.TypeCompound)
+ return (Attribute.TypeCompound) arr.values[0];
+ }
+ }
+ return null;
+ }
+
+ public boolean tryFixPosition() {
+ if (!isContainerTypeCompound())
+ return false;
+
+ Compound from = getFirstEmbeddedTC();
+ if (from != null && from.position != null &&
+ from.position.type != TargetType.UNKNOWN) {
+ position = from.position;
+ return true;
+ }
+ return false;
+ }
+
+ public boolean hasUnknownPosition() {
+ return position.type == TargetType.UNKNOWN;
+ }
+
public void accept(Visitor v) { v.visitCompound(this); }
/**
@@ -215,16 +273,6 @@
return (DeclaredType) type;
}
- @Override
- public TypeAnnotationPosition getPosition() {
- if (values.size() != 0) {
- Name valueName = values.head.fst.name.table.names.value;
- Pair<MethodSymbol, Attribute> res = getElemPair(valueName);
- return res == null ? null : res.snd.getPosition();
- }
- return null;
- }
-
public Map<MethodSymbol, Attribute> getElementValues() {
Map<MethodSymbol, Attribute> valmap = new LinkedHashMap<>();
for (Pair<MethodSymbol, Attribute> value : values)
@@ -234,62 +282,15 @@
}
public static class TypeCompound extends Compound {
- public TypeAnnotationPosition position;
-
public TypeCompound(Compound compound,
- TypeAnnotationPosition position) {
- this(compound.type, compound.values, position);
- }
- public TypeCompound(Type type,
- List<Pair<MethodSymbol, Attribute>> values,
- TypeAnnotationPosition position) {
- super(type, values);
- this.position = position;
- }
-
- @Override
- public TypeAnnotationPosition getPosition() {
- if (hasUnknownPosition()) {
- position = super.getPosition();
- }
- return position;
- }
-
- public boolean hasUnknownPosition() {
- return position.type == TargetType.UNKNOWN;
+ TypeAnnotationPosition position) {
+ super(compound.type, compound.values, position);
}
- public boolean isContainerTypeCompound() {
- if (isSynthesized() && values.size() == 1)
- return getFirstEmbeddedTC() != null;
- return false;
- }
-
- private TypeCompound getFirstEmbeddedTC() {
- if (values.size() == 1) {
- Pair<MethodSymbol, Attribute> val = values.get(0);
- if (val.fst.getSimpleName().contentEquals("value")
- && val.snd instanceof Array) {
- Array arr = (Array) val.snd;
- if (arr.values.length != 0
- && arr.values[0] instanceof Attribute.TypeCompound)
- return (Attribute.TypeCompound) arr.values[0];
- }
- }
- return null;
- }
-
- public boolean tryFixPosition() {
- if (!isContainerTypeCompound())
- return false;
-
- TypeCompound from = getFirstEmbeddedTC();
- if (from != null && from.position != null &&
- from.position.type != TargetType.UNKNOWN) {
- position = from.position;
- return true;
- }
- return false;
+ public TypeCompound(Type type,
+ List<Pair<MethodSymbol,Attribute>> values,
+ TypeAnnotationPosition position) {
+ super(type, values, position);
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Wed Apr 09 09:20:35 2014 -0700
@@ -219,6 +219,9 @@
public boolean allowTypeAnnotations() {
return compareTo(JDK1_8) >= 0;
}
+ public boolean allowAnnotationsAfterTypeParams() {
+ return compareTo(JDK1_8) >= 0;
+ }
public boolean allowRepeatedAnnotations() {
return compareTo(JDK1_8) >= 0;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Apr 09 09:20:35 2014 -0700
@@ -2112,10 +2112,8 @@
//
// This expression is then *transformed* as follows:
//
- // (1) add a STATIC flag to the class definition
- // if the current environment is static
- // (2) add an extends or implements clause
- // (3) add a constructor.
+ // (1) add an extends or implements clause
+ // (2) add a constructor.
//
// For instance, if C is a class, and ET is the type of E,
// the expression
@@ -2132,7 +2130,6 @@
// }
// ...
// }
- if (Resolve.isStatic(env)) cdef.mods.flags |= STATIC;
if (clazztype.tsym.isInterface()) {
cdef.implementing = List.of(clazz);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Apr 09 09:20:35 2014 -0700
@@ -1072,9 +1072,6 @@
if (sym.isLocal()) {
mask = LocalClassFlags;
if (sym.name.isEmpty()) { // Anonymous class
- // Anonymous classes in static methods are themselves static;
- // that's why we admit STATIC here.
- mask |= STATIC;
// JLS: Anonymous classes are final.
implicit |= FINAL;
}
@@ -1625,7 +1622,7 @@
protection(m.flags()) > protection(other.flags())) {
log.error(TreeInfo.diagnosticPositionFor(m, tree), "override.weaker.access",
cannotOverride(m, other),
- other.flags() == 0 ?
+ (other.flags() & AccessFlags) == 0 ?
"package" :
asFlagSet(other.flags() & AccessFlags));
m.flags_field |= BAD_OVERRIDE;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Wed Apr 09 09:20:35 2014 -0700
@@ -2919,15 +2919,65 @@
// constant propagation would require that we take care to
// preserve possible side-effects in the condition expression.
+ // One common case is equality expressions involving a constant and null.
+ // Since null is not a constant expression (because null cannot be
+ // represented in the constant pool), equality checks involving null are
+ // not captured by Flow.isTrue/isFalse.
+ // Equality checks involving a constant and null, e.g.
+ // "" == null
+ // are safe to simplify as no side-effects can occur.
+
+ private boolean isTrue(JCTree exp) {
+ if (exp.type.isTrue())
+ return true;
+ Boolean b = expValue(exp);
+ return b == null ? false : b;
+ }
+ private boolean isFalse(JCTree exp) {
+ if (exp.type.isFalse())
+ return true;
+ Boolean b = expValue(exp);
+ return b == null ? false : !b;
+ }
+ /* look for (in)equality relations involving null.
+ * return true - if expression is always true
+ * false - if expression is always false
+ * null - if expression cannot be eliminated
+ */
+ private Boolean expValue(JCTree exp) {
+ while (exp.hasTag(PARENS))
+ exp = ((JCParens)exp).expr;
+
+ boolean eq;
+ switch (exp.getTag()) {
+ case EQ: eq = true; break;
+ case NE: eq = false; break;
+ default:
+ return null;
+ }
+
+ // we have a JCBinary(EQ|NE)
+ // check if we have two literals (constants or null)
+ JCBinary b = (JCBinary)exp;
+ if (b.lhs.type.hasTag(BOT)) return expValueIsNull(eq, b.rhs);
+ if (b.rhs.type.hasTag(BOT)) return expValueIsNull(eq, b.lhs);
+ return null;
+ }
+ private Boolean expValueIsNull(boolean eq, JCTree t) {
+ if (t.type.hasTag(BOT)) return Boolean.valueOf(eq);
+ if (t.hasTag(LITERAL)) return Boolean.valueOf(!eq);
+ return null;
+ }
+
/** Visitor method for conditional expressions.
*/
@Override
public void visitConditional(JCConditional tree) {
JCTree cond = tree.cond = translate(tree.cond, syms.booleanType);
- if (cond.type.isTrue()) {
+ if (isTrue(cond)) {
result = convert(translate(tree.truepart, tree.type), tree.type);
addPrunedInfo(cond);
- } else if (cond.type.isFalse()) {
+ } else if (isFalse(cond)) {
result = convert(translate(tree.falsepart, tree.type), tree.type);
addPrunedInfo(cond);
} else {
@@ -2951,10 +3001,10 @@
*/
public void visitIf(JCIf tree) {
JCTree cond = tree.cond = translate(tree.cond, syms.booleanType);
- if (cond.type.isTrue()) {
+ if (isTrue(cond)) {
result = translate(tree.thenpart);
addPrunedInfo(cond);
- } else if (cond.type.isFalse()) {
+ } else if (isFalse(cond)) {
if (tree.elsepart != null) {
result = translate(tree.elsepart);
} else {
@@ -3333,21 +3383,21 @@
JCTree lhs = tree.lhs = translate(tree.lhs, formals.head);
switch (tree.getTag()) {
case OR:
- if (lhs.type.isTrue()) {
+ if (isTrue(lhs)) {
result = lhs;
return;
}
- if (lhs.type.isFalse()) {
+ if (isFalse(lhs)) {
result = translate(tree.rhs, formals.tail.head);
return;
}
break;
case AND:
- if (lhs.type.isFalse()) {
+ if (isFalse(lhs)) {
result = lhs;
return;
}
- if (lhs.type.isTrue()) {
+ if (isTrue(lhs)) {
result = translate(tree.rhs, formals.tail.head);
return;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Wed Apr 09 09:20:35 2014 -0700
@@ -2501,6 +2501,8 @@
return;
} catch (IOException ex) {
throw badClassFile("unable.to.access.file", ex.getMessage());
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ throw badClassFile("bad.class.file", c.flatname);
} finally {
currentClassFile = previousClassFile;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -506,6 +506,11 @@
}
}
+ if (options.get(XSTDOUT) != null) {
+ // Stdout reassigned - ask compiler to close it when it is done
+ comp.closeables = comp.closeables.prepend(log.getWriter(WriterKind.NOTICE));
+ }
+
fileManager = context.get(JavaFileManager.class);
if (!files.isEmpty()) {
--- a/langtools/src/share/classes/com/sun/tools/javac/main/Option.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Option.java Wed Apr 09 09:20:35 2014 -0700
@@ -399,7 +399,6 @@
public boolean process(OptionHelper helper, String option, String arg) {
try {
Log log = helper.getLog();
- // TODO: this file should be closed at the end of compilation
log.setWriters(new PrintWriter(new FileWriter(arg), true));
} catch (java.io.IOException e) {
helper.error("err.error.writing.file", arg, e);
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Apr 09 09:20:35 2014 -0700
@@ -161,6 +161,7 @@
this.allowStaticInterfaceMethods = source.allowStaticInterfaceMethods();
this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast();
this.allowTypeAnnotations = source.allowTypeAnnotations();
+ this.allowAnnotationsAfterTypeParams = source.allowAnnotationsAfterTypeParams();
this.keepDocComments = keepDocComments;
docComments = newDocCommentTable(keepDocComments, fac);
this.keepLineMap = keepLineMap;
@@ -254,6 +255,10 @@
*/
boolean allowTypeAnnotations;
+ /** Switch: should we allow annotations after the method type parameters?
+ */
+ boolean allowAnnotationsAfterTypeParams;
+
/** Switch: is "this" allowed as an identifier?
* This is needed to parse receiver types.
*/
@@ -2026,7 +2031,7 @@
/** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
*/
JCExpression creator(int newpos, List<JCExpression> typeArgs) {
- List<JCAnnotation> newAnnotations = annotationsOpt(Tag.ANNOTATION);
+ List<JCAnnotation> newAnnotations = typeAnnotationsOpt();
switch (token.kind) {
case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT:
@@ -3355,7 +3360,7 @@
? arguments() : List.<JCExpression>nil();
JCClassDecl body = null;
if (token.kind == LBRACE) {
- JCModifiers mods1 = F.at(Position.NOPOS).Modifiers(Flags.ENUM | Flags.STATIC);
+ JCModifiers mods1 = F.at(Position.NOPOS).Modifiers(Flags.ENUM);
List<JCTree> defs = classOrInterfaceBody(names.empty, false);
body = toP(F.at(identPos).AnonymousClassDef(mods1, defs));
}
@@ -3464,6 +3469,7 @@
nextToken();
} else {
if (annosAfterParams.nonEmpty()) {
+ checkAnnotationsAfterTypeParams(annosAfterParams.head.pos);
mods.annotations = mods.annotations.appendList(annosAfterParams);
if (mods.pos == Position.NOPOS)
mods.pos = mods.annotations.head.pos;
@@ -4063,6 +4069,12 @@
allowTypeAnnotations = true;
}
}
+ void checkAnnotationsAfterTypeParams(int pos) {
+ if (!allowAnnotationsAfterTypeParams) {
+ log.error(pos, "annotations.after.type.params.not.supported.in.source", source.name);
+ allowAnnotationsAfterTypeParams = true;
+ }
+ }
/*
* a functional source tree and end position mappings
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Wed Apr 09 09:20:35 2014 -0700
@@ -761,14 +761,14 @@
public Set<TypeElement> visitType(TypeElement e, Set<TypeElement> p) {
// Type parameters are not considered to be enclosed by a type
scan(e.getTypeParameters(), p);
- return scan(e.getEnclosedElements(), p);
+ return super.visitType(e, p);
}
@Override
public Set<TypeElement> visitExecutable(ExecutableElement e, Set<TypeElement> p) {
// Type parameters are not considered to be enclosed by an executable
scan(e.getTypeParameters(), p);
- return scan(e.getEnclosedElements(), p);
+ return super.visitExecutable(e, p);
}
void addAnnotations(Element e, Set<TypeElement> p) {
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java Wed Apr 09 09:20:35 2014 -0700
@@ -137,14 +137,14 @@
public Set<Element> visitType(TypeElement e, TypeElement p) {
// Type parameters are not considered to be enclosed by a type
scan(e.getTypeParameters(), p);
- return scan(e.getEnclosedElements(), p);
+ return super.visitType(e, p);
}
@Override
public Set<Element> visitExecutable(ExecutableElement e, TypeElement p) {
// Type parameters are not considered to be enclosed by an executable
scan(e.getTypeParameters(), p);
- return scan(e.getEnclosedElements(), p);
+ return super.visitExecutable(e, p);
}
@Override
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Apr 09 09:20:35 2014 -0700
@@ -1709,6 +1709,10 @@
cannot access {0}\n\
{1}
+# 0: class name
+compiler.misc.bad.class.file=\
+ class file is invalid for class {0}
+
# 0: file name, 1: message segment
compiler.misc.bad.class.file.header=\
bad class file: {0}\n\
@@ -2321,6 +2325,11 @@
(use -source 8 or higher to enable type annotations)
# 0: string
+compiler.err.annotations.after.type.params.not.supported.in.source=\
+ annotations after method type parameters are not supported in -source {0}\n\
+(use -source 8 or higher to enable annotations after method type parameters)
+
+# 0: string
compiler.err.repeatable.annotations.not.supported.in.source=\
repeated annotations are not supported in -source {0}\n\
(use -source 8 or higher to enable repeated annotations)
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Wed Apr 09 09:20:35 2014 -0700
@@ -288,10 +288,6 @@
return false;
}
- public boolean isFunctionalInterface() {
- return env.types.isFunctionalInterface(tsym) && env.source.allowLambda();
- }
-
/**
* Return the package that this class is contained in.
*/
--- a/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -381,6 +381,11 @@
env.initDoclint(opts, customTagNames);
}
+ public boolean isFunctionalInterface(AnnotationDesc annotationDesc) {
+ return annotationDesc.annotationType().qualifiedName().equals(
+ env.syms.functionalInterfaceType.toString()) && env.source.allowLambda();
+ }
+
public boolean showTagMessages() {
return env.showTagMessages();
}
--- a/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -398,7 +398,8 @@
private MemberDoc findExecutableMember(String memName, String[] paramarr,
ClassDoc referencedClass) {
- if (memName.equals(referencedClass.name())) {
+ String className = referencedClass.name();
+ if (memName.equals(className.substring(className.lastIndexOf(".") + 1))) {
return ((ClassDocImpl)referencedClass).findConstructor(memName,
paramarr);
} else { // it's a method.
--- a/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Wed Apr 09 09:20:35 2014 -0700
@@ -202,7 +202,6 @@
if (options.verbose) {
println();
indent(+1);
- attrWriter.write(cf, cf.attributes, constant_pool);
println("minor version: " + cf.minor_version);
println("major version: " + cf.major_version);
writeList("flags: ", flags.getClassFlags(), "\n");
@@ -218,6 +217,10 @@
writeMethods();
indent(-1);
println("}");
+
+ if (options.verbose) {
+ attrWriter.write(cf, cf.attributes, constant_pool);
+ }
}
// where
class JavaTypePrinter implements Type.Visitor<StringBuilder,StringBuilder> {
--- a/langtools/src/share/classes/javax/lang/model/util/Types.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/src/share/classes/javax/lang/model/util/Types.java Wed Apr 09 09:20:35 2014 -0700
@@ -132,12 +132,15 @@
boolean isSubsignature(ExecutableType m1, ExecutableType m2);
/**
- * Returns the direct supertypes of a type. The interface types, if any,
- * will appear last in the list.
+ * Returns the direct supertypes of a type. The interface types, if any,
+ * will appear last in the list. For an interface type with no direct
+ * super-interfaces, a type mirror representing {@code java.lang.Object}
+ * is returned.
*
* @param t the type being examined
* @return the direct supertypes, or an empty list if none
* @throws IllegalArgumentException if given an executable or package type
+ * @jls 4.10 Subtyping
*/
List<? extends TypeMirror> directSupertypes(TypeMirror t);
--- a/langtools/test/com/sun/javadoc/testConstructors/TestConstructors.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/com/sun/javadoc/testConstructors/TestConstructors.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8025524
+ * @bug 8025524 8031625
* @summary Test for constructor name which should be a non-qualified name.
* @author Bhavesh Patel
* @library ../lib/
@@ -38,6 +38,21 @@
//Input for string search tests.
private static final String[][] TEST = {
{BUG_ID + FS + "pkg1" + FS + "Outer.html",
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>" + NL +
+ "<dd><a href=\"../pkg1/Outer.Inner.html#Inner--\"><code>Inner()</code></a>, " + NL +
+ "<a href=\"../pkg1/Outer.Inner.html#Inner-int-\"><code>Inner(int)</code></a>, " + NL +
+ "<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner--\"><code>NestedInner()</code></a>, " + NL +
+ "<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner-int-\"><code>NestedInner(int)</code></a>, " + NL +
+ "<a href=\"../pkg1/Outer.html#Outer--\"><code>Outer()</code></a>, " + NL +
+ "<a href=\"../pkg1/Outer.html#Outer-int-\"><code>Outer(int)</code></a>"
+ },
+ {BUG_ID + FS + "pkg1" + FS + "Outer.html",
+ "Link: <a href=\"../pkg1/Outer.Inner.html#Inner--\"><code>Inner()</code></a>, " +
+ "<a href=\"../pkg1/Outer.html#Outer-int-\"><code>Outer(int)</code></a>, " +
+ "<a href=\"../pkg1/Outer.Inner.NestedInner.html#NestedInner-int-\"><code>" +
+ "NestedInner(int)</code></a>"
+ },
+ {BUG_ID + FS + "pkg1" + FS + "Outer.html",
"<a href=\"../pkg1/Outer.html#Outer--\">Outer</a></span>()"
},
{BUG_ID + FS + "pkg1" + FS + "Outer.html",
@@ -87,6 +102,18 @@
},
{BUG_ID + FS + "pkg1" + FS + "Outer.Inner.NestedInner.html",
"Outer.Inner.NestedInner-int-"
+ },
+ {BUG_ID + FS + "pkg1" + FS + "Outer.html",
+ "<a href=\"../pkg1/Outer.Inner.html#Outer.Inner--\"><code>Outer.Inner()</code></a>"
+ },
+ {BUG_ID + FS + "pkg1" + FS + "Outer.html",
+ "<a href=\"../pkg1/Outer.Inner.html#Outer.Inner-int-\"><code>Outer.Inner(int)</code></a>"
+ },
+ {BUG_ID + FS + "pkg1" + FS + "Outer.html",
+ "<a href=\"../pkg1/Outer.Inner.NestedInner.html#Outer.Inner.NestedInner--\"><code>Outer.Inner.NestedInner()</code></a>"
+ },
+ {BUG_ID + FS + "pkg1" + FS + "Outer.html",
+ "<a href=\"../pkg1/Outer.Inner.NestedInner.html#Outer.Inner.NestedInner-int-\"><code>Outer.Inner.NestedInner(int)</code></a>"
}
};
--- a/langtools/test/com/sun/javadoc/testConstructors/pkg1/Outer.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/com/sun/javadoc/testConstructors/pkg1/Outer.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,17 @@
package pkg1;
+/**
+ * Test link tag.
+ * Link: {@link pkg1.Outer.Inner#Inner()}, {@link pkg1.Outer#Outer(int)}, {@link pkg1.Outer.Inner.NestedInner#NestedInner(int)}
+ *
+ * @see Outer.Inner#Inner()
+ * @see Outer.Inner#Inner(int)
+ * @see Outer.Inner.NestedInner#NestedInner()
+ * @see Outer.Inner.NestedInner#NestedInner(int)
+ * @see Outer#Outer()
+ * @see Outer#Outer(int)
+ */
public class Outer {
/**
--- a/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8004893 8022738
+ * @bug 8004893 8022738 8029143
* @summary Make sure that the lambda feature changes work fine in
* javadoc.
* @author bpatel
@@ -87,6 +87,11 @@
"<pre>default default void defaultMethod()</pre>"},
{BUG_ID + FS + "pkg" + FS + "B.html",
"<td class=\"colFirst\"><code>default void</code></td>"},
+ {BUG_ID + FS + "pkg1" + FS + "NotAFuncInf.html",
+ "<dl>" + NL + "<dt>Functional Interface:</dt>" + NL +
+ "<dd>This is a functional interface and can therefore be used as " +
+ "the assignment target for a lambda expression or method " +
+ "reference.</dd>" + NL + "</dl>"},
{BUG_ID + FS + "pkg" + FS + "B.html",
"<dl>" + NL + "<dt>Functional Interface:</dt>"}
};
--- a/langtools/test/com/sun/javadoc/testLambdaFeature/pkg/A.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/com/sun/javadoc/testLambdaFeature/pkg/A.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
package pkg;
+@FunctionalInterface
public interface A {
public void method1();
--- a/langtools/test/com/sun/javadoc/testLambdaFeature/pkg1/FuncInf.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/com/sun/javadoc/testLambdaFeature/pkg1/FuncInf.java Wed Apr 09 09:20:35 2014 -0700
@@ -23,6 +23,7 @@
package pkg1;
+@FunctionalInterface
public interface FuncInf<V> {
V call() throws Exception;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testLambdaFeature/pkg1/NotAFuncInf.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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;
+
+public interface NotAFuncInf<V> {
+
+ V call() throws Exception;
+}
--- a/langtools/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
/*
* @test
- * @bug 4341304 4485668 4966728
+ * @bug 4341304 4485668 4966728 8032066
* @summary Test that methods readResolve and writeReplace show
* up in serialized-form.html the same way that readObject and writeObject do.
* If the doclet includes readResolve and writeReplace in the serialized-form
@@ -54,12 +54,70 @@
"protected java.lang.Object readObjectNoData()"},
{BUG_ID + FS + "serialized-form.html",
"See Also"},
+ {BUG_ID + "/serialized-form.html",
+ "<h3>Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " +
+ "extends java.lang.Object implements Serializable</h3>"},
+ {BUG_ID + "/serialized-form.html",
+ "<h3>Class pkg1.PrivateIncludeInnerClass.PriInnerClass extends " +
+ "java.lang.Object implements Serializable</h3>"},
+ {BUG_ID + "/serialized-form.html",
+ "<h3>Class pkg1.ProtectedInnerClass.ProInnerClass extends " +
+ "java.lang.Object implements Serializable</h3>"}
+ };
+
+ private static final String[][] TEST_PRIVATE = {
+ {BUG_ID + "-1/serialized-form.html",
+ "<h3>Class <a href=\"pkg1/NestedInnerClass.InnerClass.ProNestedInnerClass.html\" " +
+ "title=\"class in pkg1\">pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass</a> " +
+ "extends java.lang.Object implements Serializable</h3>"},
+ {BUG_ID + "-1/serialized-form.html",
+ "<h3>Class <a href=\"pkg1/PrivateIncludeInnerClass.PriInnerClass.html\" title=\"class in pkg1\">" +
+ "pkg1.PrivateIncludeInnerClass.PriInnerClass</a> extends java.lang.Object implements Serializable</h3>"},
+ {BUG_ID + "-1/serialized-form.html",
+ "<h3>Class <a href=\"pkg1/ProtectedInnerClass.ProInnerClass.html\" title=\"class in pkg1\">" +
+ "pkg1.ProtectedInnerClass.ProInnerClass</a> extends java.lang.Object implements Serializable</h3>"}
};
- private static final String[][] NEGATED_TEST = NO_TEST;
+ private static final String[][] NEGATED_TEST = {
+ {BUG_ID + "/serialized-form.html",
+ "<h3>Class <a href=\"pkg1/NestedInnerClass.InnerClass.ProNestedInnerClass.html\" " +
+ "title=\"class in pkg1\">pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass</a> " +
+ "extends java.lang.Object implements Serializable</h3>"},
+ {BUG_ID + "/serialized-form.html",
+ "<h3>Class <a href=\"pkg1/PrivateInnerClass.PriInnerClass.html\" title=\"class in pkg1\">" +
+ "pkg1.PrivateInnerClass.PriInnerClass</a> extends java.lang.Object implements Serializable</h3>"},
+ {BUG_ID + "/serialized-form.html",
+ "<h3>Class <a href=\"pkg1/ProtectedInnerClass.ProInnerClass.html\" title=\"class in pkg1\">" +
+ "pkg1.ProtectedInnerClass.ProInnerClass</a> extends java.lang.Object implements Serializable</h3>"},
+ {BUG_ID + "/serialized-form.html",
+ "<h3>Class pkg1.PublicExcludeInnerClass.PubInnerClass extends java.lang.Object implements " +
+ "Serializable</h3>"}
+ };
+
+ private static final String[][] NEGATED_TEST_PRIVATE = {
+ {BUG_ID + "-1/serialized-form.html",
+ "<h3>Class pkg1.NestedInnerClass.InnerClass.ProNestedInnerClass " +
+ "extends java.lang.Object implements Serializable</h3>"},
+ {BUG_ID + "-1/serialized-form.html",
+ "<h3>Class pkg1.PrivateInnerClass.PriInnerClass extends " +
+ "java.lang.Object implements Serializable</h3>"},
+ {BUG_ID + "-1/serialized-form.html",
+ "<h3>Class pkg1.ProtectedInnerClass.ProInnerClass extends " +
+ "java.lang.Object implements Serializable</h3>"},
+ {BUG_ID + "-1/serialized-form.html",
+ "<h3>Class <a href=\"pkg1/PublicExcludeInnerClass.PubInnerClass.html\" " +
+ "title=\"class in pkg1\">pkg1.PublicExcludeInnerClass.PubInnerClass</a> " +
+ "extends java.lang.Object implements Serializable</h3>"}
+ };
+
private static final String[] ARGS = new String[] {
"-d", BUG_ID, "-sourcepath", SRC_DIR,
- SRC_DIR + FS + "TestSerializedForm.java"
+ SRC_DIR + "/TestSerializedForm.java", "pkg1"
+ };
+
+ private static final String[] ARGS_PRIVATE = new String[] {
+ "-private", "-d", BUG_ID + "-1", "-sourcepath", SRC_DIR,
+ SRC_DIR + "/TestSerializedForm.java", "pkg1"
};
/**
@@ -74,7 +132,8 @@
*/
public static void main(String[] args) {
TestSerializedForm tester = new TestSerializedForm();
- int actualExitCode = run(tester, ARGS, TEST, NEGATED_TEST);
+ run(tester, ARGS, TEST, NEGATED_TEST);
+ run(tester, ARGS_PRIVATE, TEST_PRIVATE, NEGATED_TEST_PRIVATE);
tester.printSummary();
}
@@ -93,34 +152,39 @@
}
/**
+ * @param s ObjectInputStream.
* @throws IOException when there is an I/O error.
* @serial
*/
- private void readObject(ObjectInputStream s) {}
+ private void readObject(ObjectInputStream s) throws IOException {}
/**
+ * @param s ObjectOutputStream.
* @throws IOException when there is an I/O error.
* @serial
*/
- private void writeObject(ObjectOutputStream s) {}
+ private void writeObject(ObjectOutputStream s) throws IOException {}
/**
* @throws IOException when there is an I/O error.
* @serialData This is a serial data comment.
+ * @return an object.
*/
- protected Object readResolve(){return null;}
+ protected Object readResolve() throws IOException {return null;}
/**
* @throws IOException when there is an I/O error.
* @serialData This is a serial data comment.
+ * @return an object.
*/
- protected Object writeReplace(){return null;}
+ protected Object writeReplace() throws IOException {return null;}
/**
* @throws IOException when there is an I/O error.
* @serialData This is a serial data comment.
+ * @return an object.
*/
- protected Object readObjectNoData() {
+ protected Object readObjectNoData() throws IOException {
return null;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testSerializedForm/pkg1/NestedInnerClass.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+import java.io.*;
+
+/**
+ * A test class where the outer class is package private and the inner class is private
+ * and a nested inner class is protected.
+ *
+ * @author Bhavesh Patel
+ */
+
+class NestedInnerClass {
+
+ private static class InnerClass {
+
+ protected static class ProNestedInnerClass implements java.io.Serializable {
+
+ public final int SERIALIZABLE_CONSTANT = 1;
+
+ /**
+ * @param s ObjectInputStream.
+ * @throws IOException when there is an I/O error.
+ * @serial
+ */
+ private void readObject(ObjectInputStream s) throws IOException {
+ }
+
+ /**
+ * @param s ObjectOutputStream.
+ * @throws IOException when there is an I/O error.
+ * @serial
+ */
+ private void writeObject(ObjectOutputStream s) throws IOException {
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testSerializedForm/pkg1/PrivateIncludeInnerClass.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+import java.io.*;
+
+/**
+ * A test class where the outer class is package private and inner class
+ * is private which is included using the tag.
+ *
+ * @author Bhavesh Patel
+ */
+
+class PrivateIncludeInnerClass {
+
+ /**
+ * @serial include
+ */
+ private static class PriInnerClass implements java.io.Serializable {
+
+ public final int SERIALIZABLE_CONSTANT = 1;
+
+ /**
+ * @param s ObjectInputStream.
+ * @throws IOException when there is an I/O error.
+ * @serial
+ */
+ private void readObject(ObjectInputStream s) throws IOException {
+ }
+
+ /**
+ * @param s ObjectOutputStream.
+ * @throws IOException when there is an I/O error.
+ * @serial
+ */
+ private void writeObject(ObjectOutputStream s) throws IOException {
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testSerializedForm/pkg1/ProtectedInnerClass.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+import java.io.*;
+
+/**
+ * A test class where outer class is package private and the inner class is
+ * protected.
+ *
+ * @author Bhavesh Patel
+ */
+
+class ProtectedInnerClass {
+
+ protected static class ProInnerClass implements java.io.Serializable {
+
+ public final int SERIALIZABLE_CONSTANT = 1;
+
+ /**
+ * @param s ObjectInputStream.
+ * @throws IOException when there is an I/O error.
+ * @serial
+ */
+ private void readObject(ObjectInputStream s) throws IOException {
+ }
+
+ /**
+ * @param s ObjectOutputStream.
+ * @throws IOException when there is an I/O error.
+ * @serial
+ */
+ private void writeObject(ObjectOutputStream s) throws IOException {
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/com/sun/javadoc/testSerializedForm/pkg1/PublicExcludeInnerClass.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg1;
+
+import java.io.*;
+
+/**
+ * A test class where the outer class is package private and inner class
+ * is public which is excluded using the tag.
+ *
+ * @author Bhavesh Patel
+ */
+
+class PublicExcludeInnerClass {
+
+ /**
+ * @serial exclude
+ */
+ public static class PubInnerClass implements java.io.Serializable {
+
+ public final int SERIALIZABLE_CONSTANT = 1;
+
+ /**
+ * @param s ObjectInputStream.
+ * @throws IOException when there is an I/O error.
+ * @serial
+ */
+ private void readObject(ObjectInputStream s) throws IOException {
+ }
+
+ /**
+ * @param s ObjectOutputStream.
+ * @throws IOException when there is an I/O error.
+ * @serial
+ */
+ private void writeObject(ObjectOutputStream s) throws IOException {
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/ConstFoldTest.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 8025505
+ * @summary Constant folding deficiency
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ConstFoldTest
+ */
+
+import java.net.URL;
+import java.util.List;
+
+public class ConstFoldTest {
+ public static void main(String... args) throws Exception {
+ new ConstFoldTest().run();
+ }
+
+ // This is the test case. This class should end up
+ // as straight-line code with no conditionals
+ class CFTest {
+ void m() {
+ int x;
+ if (1 != 2) x=1; else x=0;
+ if (1 == 2) x=1; else x=0;
+ if ("" != null) x=1; else x=0;
+ if ("" == null) x=1; else x=0;
+ if (null == null) x=1; else x=0;
+ if (null != null) x=1; else x=0;
+
+ x = 1 != 2 ? 1 : 0;
+ x = 1 == 2 ? 1 : 0;
+ x = "" != null ? 1 : 0;
+ x = "" == null ? 1 : 0;
+ x = null == null ? 1 : 0;
+ x = null != null ? 1 : 0;
+
+ boolean b;
+ b = 1 != 2 && true;
+ b = 1 == 2 || true;
+ b = ("" != null) && true;
+ b = ("" == null) || true;
+ b = (null == null) && true;
+ b = (null != null) || true;
+ }
+ }
+
+ // All of the conditionals above should be eliminated.
+ // these if* bytecodes should not be seen
+ final String regex = "\\sif(?:null|nonnull|eq|ne){1}\\s";
+
+ void run() throws Exception {
+ URL url = ConstFoldTest.class.getResource("ConstFoldTest$CFTest.class");
+ String result = ToolBox.javap(new ToolBox.JavaToolArgs().setAllArgs("-c", url.getFile()));
+ System.out.println(result);
+
+ List<String> bad_codes = ToolBox.grep(regex, result, "\n");
+ if (!bad_codes.isEmpty()) {
+ for (String code : bad_codes)
+ System.out.println("Bad OpCode Found: " + code);
+ throw new Exception("constant folding failed");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/OverrideChecks/IncompleteMessageOverride.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8035956
+ * @summary javac, incomplete error message
+ * @author kizune
+ *
+ * @run compile/fail/ref=IncompleteMessageOverride.out -XDrawDiagnostics IncompleteMessageOverride.java
+ */
+
+class Super {
+ static void m() {}
+}
+
+class Sub extends Super {
+ private static void m() {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/OverrideChecks/IncompleteMessageOverride.out Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,2 @@
+IncompleteMessageOverride.java:15:25: compiler.err.override.weaker.access: (compiler.misc.cant.override: m(), Sub, m(), Super), package
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/StdoutCloseTest.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 7118295
+ * @summary javac does not explicitly close -Xstdout file
+ * @run main StdoutCloseTest
+ */
+
+
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.main.Main;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public class StdoutCloseTest {
+
+ public static void main(String[] args) throws Exception {
+ new StdoutCloseTest().test();
+ }
+
+ static final String program = "public class Test {\n" +
+ " public boolean test() {\n" +
+ " int i;\n" +
+ " if (i > 0) return true;\n" +
+ " return false;\n" +
+ " }\n" +
+ "}\n";
+
+ public void test() throws Exception {
+ final String sourceName = "Test.java";
+ final String outName = "Test.out";
+ File source = new File(sourceName);
+ PrintWriter pw = new PrintWriter(source);
+ pw.write(program);
+ pw.flush();
+ pw.close();
+
+ PrintWriter log = compileClass(sourceName, outName);
+
+ File outFile = new File(outName);
+ if (!outFile.exists()) {
+ throw new Exception("Output file was not created!");
+ }
+ if (!log.checkError()) { // will return true if the stream is still open
+ log.close(); // Close output PrintWriter manually
+ throw new Exception("Output file was still open!");
+ }
+ }
+
+ public PrintWriter compileClass(String src, String out) {
+ List<String> options = new ArrayList<>();
+ options.add("-Xstdout");
+ options.add(out);
+ options.add(src);
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ Main compiler = new Main("javac", pw);
+ compiler.compile(options.toArray(new String[options.size()]));
+ pw.flush();
+ if (sw.getBuffer().length() > 0) {
+ System.err.println(sw.toString());
+ }
+ return compiler.log.getWriter(Log.WriterKind.NOTICE);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8034044.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 8034044
+ * @summary An anonymous class should not be static
+ */
+
+import static java.lang.reflect.Modifier.*;
+
+public class T8034044 {
+ enum En {
+ V() {}
+ }
+
+ static class InnStat {
+ static Object o = new Object() {};
+ }
+
+ public static void main(String[] args)
+ throws Throwable {
+ Object o = new Object() {};
+ test(o.getClass());
+ test(En.V.getClass());
+ test(InnStat.o.getClass());
+ new T8034044().f();
+ }
+
+ public void f() {
+ Object o = new Object() {};
+ test(o.getClass());
+ }
+
+ static void test(Class clazz) {
+ if ((clazz.getModifiers() & STATIC) != 0)
+ throw new AssertionError(clazz.toString() +
+ " should not be static");
+ }
+}
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.out Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.out Wed Apr 09 09:20:35 2014 -0700
@@ -6,6 +6,7 @@
CantAnnotateScoping.java:56:37: compiler.err.cant.type.annotate.scoping: @TA,@TA2
CantAnnotateScoping.java:40:14: compiler.err.cant.type.annotate.scoping.1: @TA
CantAnnotateScoping.java:42:34: compiler.err.cant.type.annotate.scoping: @TA,@DA,@TA2
+CantAnnotateScoping.java:42:25: compiler.err.annotation.type.not.applicable
CantAnnotateScoping.java:44:38: compiler.err.cant.type.annotate.scoping: @TA,@DA
CantAnnotateScoping.java:44:34: compiler.err.annotation.type.not.applicable
-10 errors
\ No newline at end of file
+11 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CheckErrorsForSource7.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 8035890
+ * @summary Verify that the parser correctly checks for source level 8 on the new places where
+ * annotations can appear in 8.
+ * @run main CheckErrorsForSource7 CheckErrorsForSource7.java
+ */
+import java.io.File;
+import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import com.sun.source.tree.AnnotationTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.Tree.Kind;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.file.JavacFileManager;
+
+/**For each place where an annotation can syntactically appear with -source 8, but not with
+ * -source 7, this test verifies that an error is correctly emitted from the parser for
+ * the annotation for -source 7. This test first gathers the occurrences of @TA from
+ * the CheckErrorsForSource7Data class below, and then repeatedly removes all these annotations
+ * except one and checks the parser reports an expected error. This is needed as as the parser
+ * typically produces only one 'insufficient source level' error for each new feature used.
+ */
+public class CheckErrorsForSource7 {
+ public static void main(String... args) throws IOException, URISyntaxException {
+ new CheckErrorsForSource7().run(args);
+ }
+
+ private void run(String... args) throws IOException, URISyntaxException {
+ //the first and only parameter must be the name of the file to be analyzed:
+ if (args.length != 1) throw new IllegalStateException("Must provide source file!");
+ File testSrc = new File(System.getProperty("test.src"));
+ File testFile = new File(testSrc, args[0]);
+ if (!testFile.canRead()) throw new IllegalStateException("Cannot read the test source");
+ JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
+
+ //gather spans of the @TA annotations into typeAnnotationSpans:
+ JavacTask task = JavacTool.create().getTask(null,
+ fm,
+ null,
+ Collections.<String>emptyList(),
+ null,
+ fm.getJavaFileObjects(testFile));
+ final Trees trees = Trees.instance(task);
+ final CompilationUnitTree cut = task.parse().iterator().next();
+ final List<int[]> typeAnnotationSpans = new ArrayList<>();
+
+ new TreePathScanner<Void, Void>() {
+ @Override
+ public Void visitAnnotation(AnnotationTree node, Void p) {
+ if (node.getAnnotationType().getKind() == Kind.IDENTIFIER &&
+ ((IdentifierTree) node.getAnnotationType()).getName().contentEquals("TA")) {
+ int start = (int) trees.getSourcePositions().getStartPosition(cut, node);
+ int end = (int) trees.getSourcePositions().getEndPosition(cut, node);
+ typeAnnotationSpans.add(new int[] {start, end});
+ }
+ return null;
+ }
+ }.scan(cut, null);
+
+ //sort the spans in the reverse order, to simplify removing them from the source:
+ Collections.sort(typeAnnotationSpans, new Comparator<int[]>() {
+ @Override
+ public int compare(int[] o1, int[] o2) {
+ return o2[0] - o1[0];
+ }
+ });
+
+ //verify the errors are produce correctly:
+ String originalSource = cut.getSourceFile().getCharContent(false).toString();
+
+ for (int[] toKeep : typeAnnotationSpans) {
+ //prepare updated source code by removing all the annotations except the toKeep one:
+ String updated = originalSource;
+
+ for (int[] span : typeAnnotationSpans) {
+ if (span == toKeep) continue;
+
+ updated = updated.substring(0, span[0]) + updated.substring(span[1]);
+ }
+
+ //parse and verify:
+ JavaFileObject updatedFile = new TestFO(cut.getSourceFile().toUri(), updated);
+ DiagnosticCollector<JavaFileObject> errors = new DiagnosticCollector<>();
+ JavacTask task2 = JavacTool.create().getTask(null,
+ fm,
+ errors,
+ Arrays.asList("-source", "7"),
+ null,
+ Arrays.asList(updatedFile));
+ task2.parse();
+
+ boolean found = false;
+
+ for (Diagnostic<? extends JavaFileObject> d : errors.getDiagnostics()) {
+ if (d.getKind() == Diagnostic.Kind.ERROR && EXPECTED_ERRORS.contains(d.getCode())) {
+ if (found) {
+ throw new IllegalStateException("More than one expected error found.");
+ }
+ found = true;
+ }
+ }
+
+ if (!found)
+ throw new IllegalStateException("Did not produce proper errors for: " + updated);
+ }
+ }
+
+ static final Set<String> EXPECTED_ERRORS = new HashSet<>(Arrays.asList(
+ "compiler.err.type.annotations.not.supported.in.source",
+ "compiler.err.annotations.after.type.params.not.supported.in.source"
+ ));
+
+ class TestFO extends SimpleJavaFileObject {
+ private final String content;
+ public TestFO(URI uri, String content) {
+ super(uri, Kind.SOURCE);
+ this.content = content;
+ }
+
+ @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+ return content;
+ }
+
+ @Override public boolean isNameCompatible(String simpleName, Kind kind) {
+ return true;
+ }
+ }
+}
+
+//data on which the source level check is verified:
+class CheckErrorsForSource7Data {
+ @Target(ElementType.TYPE_USE)
+ @interface TA { }
+
+ Object n1 = new @TA ArrayList<@TA String>();
+ Object n2 = new @TA Object() {};
+ Object [] @TA [] arr @TA[];
+ <T> @TA int @TA[] ret(Object obj) @TA[] throws @TA Exception {
+ this.<@TA String>ret(null);
+ Object c1 = new @TA String[1];
+
+ int val = obj instanceof @TA String ? ((@TA String) obj).length() : 0;
+ List<@TA ?> l;
+ return null;
+ }
+ void vararg(String @TA ... args) { }
+
+ abstract class C<@TA T extends @TA Number & @TA Runnable>
+ extends @TA ArrayList<@TA String>
+ implements java.util. @TA Comparator<@TA T> { }
+
+ interface I extends java.util. @TA Comparator<@TA String> { }
+
+}
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
+DeclarationAnnotation.java:13:21: compiler.err.annotation.type.not.applicable
DeclarationAnnotation.java:10:21: compiler.err.annotation.type.not.applicable
DeclarationAnnotation.java:11:21: compiler.err.annotation.type.not.applicable
DeclarationAnnotation.java:12:21: compiler.err.annotation.type.not.applicable
-DeclarationAnnotation.java:13:21: compiler.err.annotation.type.not.applicable
4 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/classreader/BadClass.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 6898851
+ * @summary Compiling against this corrupt class file causes a stacktrace from javac
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.StringWriter;
+import java.io.PrintWriter;
+import java.io.IOException;
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ClassWriter;
+import com.sun.tools.javac.Main;
+
+public class BadClass {
+ // Create and compile file containing body; return compiler output
+ static String makeClass(String dir, String filename, String body) throws IOException {
+ File file = new File(dir, filename);
+ try (FileWriter fw = new FileWriter(file)) {
+ fw.write(body);
+ }
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String args[] = { "-cp", dir, "-d", dir, "-XDrawDiagnostics", file.getPath() };
+ Main.compile(args, pw);
+ pw.close();
+ return sw.toString();
+ }
+
+ public static void main(String... args) throws Exception {
+ new File("d1").mkdir();
+ new File("d2").mkdir();
+
+ // Step 1. build an empty class with an interface
+ makeClass("d1", "Empty.java", "abstract class Empty implements Readable {}");
+
+ // Step 2. Modify classfile to have invalid constant pool index
+ ClassFile cf = ClassFile.read(new File("d1","Empty.class"));
+ cf.interfaces[0] = cf.constant_pool.size() + 10;
+ ClassWriter cw = new ClassWriter();
+ cw.write(cf, new File("d2","Empty.class"));
+
+ // Step 3. Compile use of invalid class
+ String result = makeClass("d2", "EmptyUse.java", "class EmptyUse { Empty e; }");
+ if (!result.contains("compiler.misc.bad.class.file")) {
+ System.out.println(result);
+ throw new Exception("test failed");
+ }
+ }
+}
--- a/langtools/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
* @bug 8005166
* @summary Add support for static interface methods
* Smoke test for static interface method hiding
+ * @run main/timeout=600 InterfaceMethodHidingTest
*/
import com.sun.source.util.JavacTask;
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt Wed Apr 09 09:20:35 2014 -0700
@@ -111,3 +111,4 @@
compiler.warn.unknown.enum.constant.reason # in bad class file
compiler.warn.override.equals.but.not.hashcode # when a class overrides equals but not hashCode method from Object
compiler.warn.file.from.future # warning for future modification times on files
+compiler.misc.bad.class.file # class file is malformed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/AnnotationsAfterTypeParamsNotSupportedInSource.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.annotations.after.type.params.not.supported.in.source
+// key: compiler.warn.source.no.bootclasspath
+// options: -source 7
+
+@interface Anno { }
+
+class AnnotationsAfterTypeParamsNotSupportedInSource {
+ <T> @Anno int m() {
+ return 0;
+ }
+}
--- a/langtools/test/tools/javac/lambda/FunctionalInterfaceConversionTest.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/tools/javac/lambda/FunctionalInterfaceConversionTest.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
* @author Maurizio Cimadamore
* @library ../lib
* @build JavacTestingAbstractThreadedTest
- * @run main/othervm FunctionalInterfaceConversionTest
+ * @run main/timeout=600/othervm FunctionalInterfaceConversionTest
*/
// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/environment/ProcessingEnvAnnoDiscovery.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 8038080
+ * @summary make sure that all declaration annotations are discovered
+ * by the processing environment
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor ProcessingEnvAnnoDiscovery
+ * @compile/process -processor ProcessingEnvAnnoDiscovery ProcessingEnvAnnoDiscovery.java
+ */
+
+import java.lang.annotation.*;
+import java.util.Set;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+
+import com.sun.tools.javac.util.*;
+
+@ProcessingEnvAnnoDiscovery.Anno1
+public class ProcessingEnvAnnoDiscovery<@ProcessingEnvAnnoDiscovery.Anno4 T>
+ extends JavacTestingAbstractProcessor {
+ private int round = 0;
+
+ public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
+ if (round++ == 0) {
+ System.out.println(annos);
+ Assert.check(annos.contains(eltUtils.getTypeElement("java.lang.annotation.Target")));
+ Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno1")));
+ Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno2")));
+ Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno3")));
+ Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno4")));
+ Assert.check(annos.contains(eltUtils.getTypeElement("ProcessingEnvAnnoDiscovery.Anno5")));
+ Assert.check(annos.size() == 6, "Found extra annotations"); //Anno1-5 + @Target
+ }
+
+ return true;
+ }
+
+ @Anno2
+ public <@Anno5 K> K m(@Anno3 long foo) {
+ return null;
+ }
+
+ @interface Anno1 {}
+
+ @interface Anno2 {}
+
+ @interface Anno3 {}
+
+ @Target(ElementType.TYPE_PARAMETER)
+ @interface Anno4 {}
+
+ @Target(ElementType.TYPE_PARAMETER)
+ @interface Anno5 {}
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/environment/round/Anno.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+import java.lang.annotation.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+@Retention(RUNTIME)
+public @interface Anno {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/environment/round/ParameterAnnotations.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * Class to hold annotations for ElementsAnnotatedWithTest.
+ */
+
+@AnnotatedElementInfo(annotationName="Anno",
+ expectedSize=1,
+ names={"annotatedParameter"})
+public class ParameterAnnotations {
+ private void foo(@Anno Object annotatedParameter) {}
+}
--- a/langtools/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java Wed Apr 09 09:20:35 2014 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049
+ * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049 8038080
* @summary Tests that getElementsAnnotatedWith works properly.
* @author Joseph D. Darcy
* @library /tools/javac/lib
@@ -31,12 +31,14 @@
* @compile TestElementsAnnotatedWith.java
* @compile InheritedAnnotation.java
* @compile TpAnno.java
+ * @compile Anno.java
* @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only BuriedAnnotations.java
* @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java
* @compile -processor TestElementsAnnotatedWith -proc:only C2.java
* @compile -processor TestElementsAnnotatedWith -proc:only Foo.java
* @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java
+ * @compile -processor TestElementsAnnotatedWith -proc:only ParameterAnnotations.java
* @compile/fail/ref=ErroneousAnnotations.out -processor TestElementsAnnotatedWith -proc:only -XDrawDiagnostics ErroneousAnnotations.java
* @compile Foo.java
* @compile/process -processor TestElementsAnnotatedWith -proc:only Foo
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/util/DirectSuperOfInt.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 8034933
+ * @summary Types.directSupertypes should return Object as the super type of interfaces
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor DirectSuperOfInt
+ * @compile -processor DirectSuperOfInt -proc:only DirectSuperOfInt.java
+ */
+
+import java.util.Set;
+import java.util.List;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.lang.model.type.*;
+import javax.lang.model.util.*;
+import static javax.lang.model.util.ElementFilter.*;
+
+public class DirectSuperOfInt extends JavacTestingAbstractProcessor {
+ public boolean process(Set<? extends TypeElement> tes,
+ RoundEnvironment round) {
+ if (round.processingOver())
+ return true;
+
+ boolean tested = false;
+ for (TypeElement te : typesIn(round.getRootElements())) {
+ if (!te.getSimpleName().contentEquals("DirectSuperOfIntI"))
+ continue;
+
+ tested = true;
+ List<? extends TypeMirror> supers = types.directSupertypes(te.asType());
+ if (supers.size() != 1)
+ throw new AssertionError("test failed");
+
+ if (!elements.getTypeElement("java.lang.Object").asType().equals((supers.get(0))))
+ throw new AssertionError("test failed");
+ }
+ if (!tested)
+ throw new AssertionError("test failed");
+ return true;
+ }
+}
+
+interface DirectSuperOfIntI {}
--- a/langtools/test/tools/javap/T4975569.java Wed Apr 02 22:00:13 2014 -0700
+++ b/langtools/test/tools/javap/T4975569.java Wed Apr 09 09:20:35 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,10 +40,10 @@
verify("T4975569$Anno", "flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION");
verify("T4975569$E", "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM");
verify("T4975569$S", "flags: ACC_BRIDGE, ACC_SYNTHETIC",
- "InnerClasses:\n static");
+ "InnerClasses:\n static");
verify("T4975569$V", "void m(java.lang.String...)",
"flags: ACC_VARARGS");
- verify("T4975569$Prot", "InnerClasses:\n protected");
+ verify("T4975569$Prot", "InnerClasses:\n protected");
//verify("T4975569$Priv", "InnerClasses");
if (errors > 0)
throw new Error(errors + " found.");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/T8035104.java Wed Apr 09 09:20:35 2014 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 8035104
+ * @summary reorder class file attributes in javap listing
+ */
+
+import java.io.*;
+
+public class T8035104 {
+ public static void main(String[] args) throws Exception {
+ new T8035104().run();
+ }
+
+ public void run() throws Exception {
+ String[] lines = javap("-v", T8035104.class.getName()).split("[\r\n]+");
+ int minor = -1;
+ int SourceFile = -1;
+ for (int i = 0; i < lines.length; i++) {
+ String line = lines[i];
+ if (line.matches(" *minor version: [0-9.]+"))
+ minor = i;
+ if (line.matches(" *SourceFile: .+"))
+ SourceFile = i;
+ }
+ if (minor == -1)
+ throw new Exception("minor version not found");
+ if (SourceFile == -1)
+ throw new Exception("SourceFile not found");
+ if (SourceFile < minor)
+ throw new Exception("unexpected order of output");
+
+ System.out.println("output OK");
+ }
+
+ String javap(String... args) {
+ StringWriter sw = new StringWriter();
+ PrintWriter out = new PrintWriter(sw);
+ int rc = com.sun.tools.javap.Main.run(args, out);
+ out.close();
+ System.out.println(sw.toString());
+ System.out.println("javap exited, rc=" + rc);
+ return sw.toString();
+ }
+}