提交 eb8f9ed0 编写于 作者: C coffeys

Merge

/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -4653,10 +4653,19 @@ public class Attr extends JCTree.Visitor { ...@@ -4653,10 +4653,19 @@ public class Attr extends JCTree.Visitor {
private void initTypeIfNeeded(JCTree that) { private void initTypeIfNeeded(JCTree that) {
if (that.type == null) { if (that.type == null) {
that.type = syms.unknownType; if (that.hasTag(METHODDEF)) {
that.type = dummyMethodType();
} else {
that.type = syms.unknownType;
}
} }
} }
private Type dummyMethodType() {
return new MethodType(List.<Type>nil(), syms.unknownType,
List.<Type>nil(), syms.methodClass);
}
@Override @Override
public void scan(JCTree tree) { public void scan(JCTree tree) {
if (tree == null) return; if (tree == null) return;
...@@ -4712,7 +4721,8 @@ public class Attr extends JCTree.Visitor { ...@@ -4712,7 +4721,8 @@ public class Attr extends JCTree.Visitor {
@Override @Override
public void visitNewClass(JCNewClass that) { public void visitNewClass(JCNewClass that) {
if (that.constructor == null) { if (that.constructor == null) {
that.constructor = new MethodSymbol(0, names.init, syms.unknownType, syms.noSymbol); that.constructor = new MethodSymbol(0, names.init,
dummyMethodType(), syms.noSymbol);
} }
if (that.constructorType == null) { if (that.constructorType == null) {
that.constructorType = syms.unknownType; that.constructorType = syms.unknownType;
...@@ -4722,22 +4732,28 @@ public class Attr extends JCTree.Visitor { ...@@ -4722,22 +4732,28 @@ public class Attr extends JCTree.Visitor {
@Override @Override
public void visitAssignop(JCAssignOp that) { public void visitAssignop(JCAssignOp that) {
if (that.operator == null) if (that.operator == null) {
that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol); that.operator = new OperatorSymbol(names.empty, dummyMethodType(),
-1, syms.noSymbol);
}
super.visitAssignop(that); super.visitAssignop(that);
} }
@Override @Override
public void visitBinary(JCBinary that) { public void visitBinary(JCBinary that) {
if (that.operator == null) if (that.operator == null) {
that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol); that.operator = new OperatorSymbol(names.empty, dummyMethodType(),
-1, syms.noSymbol);
}
super.visitBinary(that); super.visitBinary(that);
} }
@Override @Override
public void visitUnary(JCUnary that) { public void visitUnary(JCUnary that) {
if (that.operator == null) if (that.operator == null) {
that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol); that.operator = new OperatorSymbol(names.empty, dummyMethodType(),
-1, syms.noSymbol);
}
super.visitUnary(that); super.visitUnary(that);
} }
...@@ -4753,7 +4769,8 @@ public class Attr extends JCTree.Visitor { ...@@ -4753,7 +4769,8 @@ public class Attr extends JCTree.Visitor {
public void visitReference(JCMemberReference that) { public void visitReference(JCMemberReference that) {
super.visitReference(that); super.visitReference(that);
if (that.sym == null) { if (that.sym == null) {
that.sym = new MethodSymbol(0, names.empty, syms.unknownType, syms.noSymbol); that.sym = new MethodSymbol(0, names.empty, dummyMethodType(),
syms.noSymbol);
} }
if (that.targets == null) { if (that.targets == null) {
that.targets = List.nil(); that.targets = List.nil();
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -2779,7 +2779,7 @@ public class Check { ...@@ -2779,7 +2779,7 @@ public class Check {
validateDocumented(t.tsym, s, pos); validateDocumented(t.tsym, s, pos);
validateInherited(t.tsym, s, pos); validateInherited(t.tsym, s, pos);
validateTarget(t.tsym, s, pos); validateTarget(t.tsym, s, pos);
validateDefault(t.tsym, s, pos); validateDefault(t.tsym, pos);
} }
private void validateValue(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) { private void validateValue(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) {
...@@ -2898,7 +2898,9 @@ public class Check { ...@@ -2898,7 +2898,9 @@ public class Check {
/** Checks that s is a subset of t, with respect to ElementType /** Checks that s is a subset of t, with respect to ElementType
* semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE} * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE},
* and {TYPE_USE} covers the set {ANNOTATION_TYPE, TYPE, TYPE_USE,
* TYPE_PARAMETER}.
*/ */
private boolean isTargetSubsetOf(Set<Name> s, Set<Name> t) { private boolean isTargetSubsetOf(Set<Name> s, Set<Name> t) {
// Check that all elements in s are present in t // Check that all elements in s are present in t
...@@ -2911,6 +2913,12 @@ public class Check { ...@@ -2911,6 +2913,12 @@ public class Check {
} else if (n1 == names.TYPE && n2 == names.ANNOTATION_TYPE) { } else if (n1 == names.TYPE && n2 == names.ANNOTATION_TYPE) {
currentElementOk = true; currentElementOk = true;
break; break;
} else if (n1 == names.TYPE_USE &&
(n2 == names.TYPE ||
n2 == names.ANNOTATION_TYPE ||
n2 == names.TYPE_PARAMETER)) {
currentElementOk = true;
break;
} }
} }
if (!currentElementOk) if (!currentElementOk)
...@@ -2919,7 +2927,7 @@ public class Check { ...@@ -2919,7 +2927,7 @@ public class Check {
return true; return true;
} }
private void validateDefault(Symbol container, Symbol contained, DiagnosticPosition pos) { private void validateDefault(Symbol container, DiagnosticPosition pos) {
// validate that all other elements of containing type has defaults // validate that all other elements of containing type has defaults
Scope scope = container.members(); Scope scope = container.members();
for(Symbol elm : scope.getElements()) { for(Symbol elm : scope.getElements()) {
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1461,9 +1461,19 @@ public class Flow { ...@@ -1461,9 +1461,19 @@ public class Flow {
this.names = names; this.names = names;
} }
private boolean isInitialConstructor = false;
@Override @Override
protected void markDead(JCTree tree) { protected void markDead(JCTree tree) {
inits.inclRange(returnadr, nextadr); if (!isInitialConstructor) {
inits.inclRange(returnadr, nextadr);
} else {
for (int address = returnadr; address < nextadr; address++) {
if (!(isFinalUninitializedStaticField(vardecls[address].sym))) {
inits.incl(address);
}
}
}
uninits.inclRange(returnadr, nextadr); uninits.inclRange(returnadr, nextadr);
} }
...@@ -1476,8 +1486,17 @@ public class Flow { ...@@ -1476,8 +1486,17 @@ public class Flow {
return return
sym.pos >= startPos && sym.pos >= startPos &&
((sym.owner.kind == MTH || ((sym.owner.kind == MTH ||
((sym.flags() & (FINAL | HASINIT | PARAMETER)) == FINAL && isFinalUninitializedField(sym)));
classDef.sym.isEnclosedBy((ClassSymbol)sym.owner)))); }
boolean isFinalUninitializedField(VarSymbol sym) {
return sym.owner.kind == TYP &&
((sym.flags() & (FINAL | HASINIT | PARAMETER)) == FINAL &&
classDef.sym.isEnclosedBy((ClassSymbol)sym.owner));
}
boolean isFinalUninitializedStaticField(VarSymbol sym) {
return isFinalUninitializedField(sym) && sym.isStatic();
} }
/** Initialize new trackable variable by setting its address field /** Initialize new trackable variable by setting its address field
...@@ -1731,10 +1750,9 @@ public class Flow { ...@@ -1731,10 +1750,9 @@ public class Flow {
int returnadrPrev = returnadr; int returnadrPrev = returnadr;
Assert.check(pendingExits.isEmpty()); Assert.check(pendingExits.isEmpty());
boolean lastInitialConstructor = isInitialConstructor;
try { try {
boolean isInitialConstructor = isInitialConstructor = TreeInfo.isInitialConstructor(tree);
TreeInfo.isInitialConstructor(tree);
if (!isInitialConstructor) { if (!isInitialConstructor) {
firstadr = nextadr; firstadr = nextadr;
...@@ -1789,6 +1807,7 @@ public class Flow { ...@@ -1789,6 +1807,7 @@ public class Flow {
nextadr = nextadrPrev; nextadr = nextadrPrev;
firstadr = firstadrPrev; firstadr = firstadrPrev;
returnadr = returnadrPrev; returnadr = returnadrPrev;
isInitialConstructor = lastInitialConstructor;
} }
} }
......
/* /*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -96,6 +96,9 @@ public class LambdaToMethod extends TreeTranslator { ...@@ -96,6 +96,9 @@ public class LambdaToMethod extends TreeTranslator {
/** dump statistics about lambda code generation */ /** dump statistics about lambda code generation */
private boolean dumpLambdaToMethodStats; private boolean dumpLambdaToMethodStats;
/** force serializable representation, for stress testing **/
private final boolean forceSerializable;
/** Flag for alternate metafactories indicating the lambda object is intended to be serializable */ /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */
public static final int FLAG_SERIALIZABLE = 1 << 0; public static final int FLAG_SERIALIZABLE = 1 << 0;
...@@ -131,6 +134,7 @@ public class LambdaToMethod extends TreeTranslator { ...@@ -131,6 +134,7 @@ public class LambdaToMethod extends TreeTranslator {
Options options = Options.instance(context); Options options = Options.instance(context);
dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats");
attr = Attr.instance(context); attr = Attr.instance(context);
forceSerializable = options.isSet("forceSerializable");
} }
// </editor-fold> // </editor-fold>
...@@ -1694,6 +1698,9 @@ public class LambdaToMethod extends TreeTranslator { ...@@ -1694,6 +1698,9 @@ public class LambdaToMethod extends TreeTranslator {
/** does this functional expression require serialization support? */ /** does this functional expression require serialization support? */
boolean isSerializable() { boolean isSerializable() {
if (forceSerializable) {
return true;
}
for (Type target : tree.targets) { for (Type target : tree.targets) {
if (types.asSuper(target, syms.serializableType.tsym) != null) { if (types.asSuper(target, syms.serializableType.tsym) != null) {
return true; return true;
......
/* /*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,11 +26,8 @@ ...@@ -26,11 +26,8 @@
package com.sun.tools.javac.processing; package com.sun.tools.javac.processing;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import com.sun.tools.javac.tree.JCTree.*;
import javax.annotation.processing.*; import javax.annotation.processing.*;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.*; import javax.lang.model.util.*;
import java.util.*; import java.util.*;
...@@ -114,58 +111,48 @@ public class JavacRoundEnvironment implements RoundEnvironment { ...@@ -114,58 +111,48 @@ public class JavacRoundEnvironment implements RoundEnvironment {
*/ */
public Set<? extends Element> getElementsAnnotatedWith(TypeElement a) { public Set<? extends Element> getElementsAnnotatedWith(TypeElement a) {
Set<Element> result = Collections.emptySet(); Set<Element> result = Collections.emptySet();
Types typeUtil = processingEnv.getTypeUtils();
if (a.getKind() != ElementKind.ANNOTATION_TYPE) if (a.getKind() != ElementKind.ANNOTATION_TYPE)
throw new IllegalArgumentException(NOT_AN_ANNOTATION_TYPE + a); throw new IllegalArgumentException(NOT_AN_ANNOTATION_TYPE + a);
DeclaredType annotationTypeElement; ElementScanner8<Set<Element>, TypeElement> scanner =
TypeMirror tm = a.asType(); new AnnotationSetScanner(result);
if ( tm instanceof DeclaredType )
annotationTypeElement = (DeclaredType) a.asType();
else
throw new AssertionError("Bad implementation type for " + tm);
ElementScanner8<Set<Element>, DeclaredType> scanner =
new AnnotationSetScanner(result, typeUtil);
for (Element element : rootElements) for (Element element : rootElements)
result = scanner.scan(element, annotationTypeElement); result = scanner.scan(element, a);
return result; return result;
} }
// Could be written as a local class inside getElementsAnnotatedWith // Could be written as a local class inside getElementsAnnotatedWith
private class AnnotationSetScanner extends private class AnnotationSetScanner extends
ElementScanner8<Set<Element>, DeclaredType> { ElementScanner8<Set<Element>, TypeElement> {
// Insertion-order preserving set // Insertion-order preserving set
Set<Element> annotatedElements = new LinkedHashSet<Element>(); Set<Element> annotatedElements = new LinkedHashSet<Element>();
Types typeUtil;
AnnotationSetScanner(Set<Element> defaultSet, Types typeUtil) { AnnotationSetScanner(Set<Element> defaultSet) {
super(defaultSet); super(defaultSet);
this.typeUtil = typeUtil;
} }
@Override @Override
public Set<Element> visitType(TypeElement e, DeclaredType p) { public Set<Element> visitType(TypeElement e, TypeElement p) {
// Type parameters are not considered to be enclosed by a type // Type parameters are not considered to be enclosed by a type
scan(e.getTypeParameters(), p); scan(e.getTypeParameters(), p);
return scan(e.getEnclosedElements(), p); return scan(e.getEnclosedElements(), p);
} }
@Override @Override
public Set<Element> visitExecutable(ExecutableElement e, DeclaredType p) { public Set<Element> visitExecutable(ExecutableElement e, TypeElement p) {
// Type parameters are not considered to be enclosed by an executable // Type parameters are not considered to be enclosed by an executable
scan(e.getTypeParameters(), p); scan(e.getTypeParameters(), p);
return scan(e.getEnclosedElements(), p); return scan(e.getEnclosedElements(), p);
} }
@Override @Override
public Set<Element> scan(Element e, DeclaredType p) { public Set<Element> scan(Element e, TypeElement p) {
java.util.List<? extends AnnotationMirror> annotationMirrors = java.util.List<? extends AnnotationMirror> annotationMirrors =
processingEnv.getElementUtils().getAllAnnotationMirrors(e); processingEnv.getElementUtils().getAllAnnotationMirrors(e);
for (AnnotationMirror annotationMirror : annotationMirrors) { for (AnnotationMirror annotationMirror : annotationMirrors) {
if (typeUtil.isSameType(annotationMirror.getAnnotationType(), p)) if (p.equals(annotationMirror.getAnnotationType().asElement()))
annotatedElements.add(e); annotatedElements.add(e);
} }
e.accept(this, p); e.accept(this, p);
......
/*
* @test /nodynamiccopyright/
* @bug 8030816
* @summary javac can't compile program with lambda expression
* @compile/fail/ref=CrashLambdaExpressionWithNonAccessibleIdTest.out -XDrawDiagnostics CrashLambdaExpressionWithNonAccessibleIdTest.java
*/
/* This test must make sure that javac won't crash when compiling lambda
* containing an anonymous innerclass based on an unresolvable type.
*/
public class CrashLambdaExpressionWithNonAccessibleIdTest {
void m() {
m1(()-> {
new A(){
public void m11() {}
};
});
}
void m1(Runnable r) {}
}
CrashLambdaExpressionWithNonAccessibleIdTest.java:15:35: compiler.err.missing.ret.stmt
CrashLambdaExpressionWithNonAccessibleIdTest.java:14:17: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, CrashLambdaExpressionWithNonAccessibleIdTest, null)
2 errors
/*
* 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 8029017
* @summary sanity testing of ElementType validation for repeating annotations
* @compile TypeUseTarget.java
*/
import java.lang.annotation.*;
public class TypeUseTarget {}
// Case 1:
@Target({
ElementType.TYPE_USE,
})
@Repeatable(Case1Container.class)
@interface Case1 {}
@Target({
ElementType.ANNOTATION_TYPE,
ElementType.TYPE,
ElementType.TYPE_USE,
ElementType.TYPE_PARAMETER,
})
@interface Case1Container {
Case1[] value();
}
// Case 2:
@Target({
ElementType.TYPE_USE,
})
@Repeatable(Case2Container.class)
@interface Case2 {}
@Target({
ElementType.ANNOTATION_TYPE,
ElementType.TYPE,
ElementType.TYPE_USE,
})
@interface Case2Container {
Case2[] value();
}
// Case 3:
@Target({
ElementType.TYPE_USE,
})
@Repeatable(Case3Container.class)
@interface Case3 {}
@Target({
ElementType.ANNOTATION_TYPE,
ElementType.TYPE,
})
@interface Case3Container {
Case3[] value();
}
// Case 4:
@Target({
ElementType.TYPE_USE,
})
@Repeatable(Case4Container.class)
@interface Case4 {}
@Target({
ElementType.ANNOTATION_TYPE,
})
@interface Case4Container {
Case4[] value();
}
// Case 5:
@Target({
ElementType.TYPE_USE,
})
@Repeatable(Case5Container.class)
@interface Case5 {}
@Target({
ElementType.TYPE,
})
@interface Case5Container {
Case5[] value();
}
// Case 6:
@Target({
ElementType.TYPE_USE,
})
@Repeatable(Case6Container.class)
@interface Case6 {}
@Target({
ElementType.TYPE_PARAMETER,
})
@interface Case6Container {
Case6[] value();
}
/**
* @test /nodynamiccopyright/
* @bug 8029017
* @summary sanity testing of ElementType validation for repeating annotations
* @compile/fail/ref=TypeUseTargetNeg.out -XDrawDiagnostics TypeUseTargetNeg.java
*/
import java.lang.annotation.*;
public class TypeUseTargetNeg {}
// Case 1:
@Target({
ElementType.TYPE_USE,
})
@Repeatable(FooContainer.class)
@interface Foo {}
@Target({
ElementType.ANNOTATION_TYPE,
ElementType.TYPE,
ElementType.TYPE_USE,
ElementType.TYPE_PARAMETER,
ElementType.FIELD,
})
@interface FooContainer {
Foo[] value();
}
// Case 2:
@Target({
ElementType.TYPE_USE,
})
@Repeatable(BarContainer.class)
@interface Bar {}
@Target({
ElementType.ANNOTATION_TYPE,
ElementType.TYPE,
ElementType.TYPE_USE,
ElementType.METHOD,
})
@interface BarContainer {
Bar[] value();
}
// Case 3:
@Target({
ElementType.TYPE_USE,
})
@Repeatable(BazContainer.class)
@interface Baz {}
@Target({
ElementType.ANNOTATION_TYPE,
ElementType.TYPE,
ElementType.PARAMETER,
})
@interface BazContainer {
Baz[] value();
}
// Case 4:
@Target({
ElementType.TYPE_USE,
})
@Repeatable(QuxContainer.class)
@interface Qux {}
@interface QuxContainer {
Qux[] value();
}
// Case 5:
@Target({})
@Repeatable(QuuxContainer.class)
@interface Quux {}
@Target({
ElementType.TYPE_PARAMETER,
})
@interface QuuxContainer {
Quux[] value();
}
// Case 6:
@Repeatable(QuuuxContainer.class)
@interface Quuux {}
@Target({
ElementType.TYPE_USE,
})
@interface QuuuxContainer {
Quuux[] value();
}
TypeUseTargetNeg.java:16:1: compiler.err.invalid.repeatable.annotation.incompatible.target: FooContainer, Foo
TypeUseTargetNeg.java:36:1: compiler.err.invalid.repeatable.annotation.incompatible.target: BarContainer, Bar
TypeUseTargetNeg.java:54:1: compiler.err.invalid.repeatable.annotation.incompatible.target: BazContainer, Baz
TypeUseTargetNeg.java:71:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuxContainer, Qux
TypeUseTargetNeg.java:81:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuuxContainer, Quux
TypeUseTargetNeg.java:92:1: compiler.err.invalid.repeatable.annotation.incompatible.target: QuuuxContainer, Quuux
6 errors
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 7151010 8006547 8007766 * @bug 7151010 8006547 8007766 8029017
* @summary Default test cases for running combinations for Target values * @summary Default test cases for running combinations for Target values
* @build Helper * @build Helper
* @run main TargetAnnoCombo * @run main TargetAnnoCombo
...@@ -145,11 +145,19 @@ public class TargetAnnoCombo { ...@@ -145,11 +145,19 @@ public class TargetAnnoCombo {
Set<ElementType> tempBaseSet = EnumSet.noneOf(ElementType.class); Set<ElementType> tempBaseSet = EnumSet.noneOf(ElementType.class);
tempBaseSet.addAll(baseAnnotations); tempBaseSet.addAll(baseAnnotations);
// If BaseAnno has TYPE, then ANNOTATION_TYPE is allowed by default. // If BaseAnno has TYPE, then ANNOTATION_TYPE is allowed by default.
if (baseAnnotations.contains(TYPE)) { if (baseAnnotations.contains(TYPE)) {
tempBaseSet.add(ANNOTATION_TYPE); tempBaseSet.add(ANNOTATION_TYPE);
} }
// If BaseAnno has TYPE_USE, then add the extra allowed types
if (baseAnnotations.contains(TYPE_USE)) {
tempBaseSet.add(ANNOTATION_TYPE);
tempBaseSet.add(TYPE);
tempBaseSet.add(TYPE_PARAMETER);
}
// If containerAnno has no @Target, only valid case if baseAnnoTarget has // If containerAnno has no @Target, only valid case if baseAnnoTarget has
// all targets defined else invalid set. // all targets defined else invalid set.
if (containerAnnotations == null) { if (containerAnnotations == null) {
......
/* /*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 4813736 * @bug 4813736 8013256
* @summary Additional functionality test of task and JSR 269 * @summary Additional functionality test of task and JSR 269
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ./lib * @library ./lib
......
/*
* @test /nodynamiccopyright/
* @bug 8030218
* @summary javac, compile time error isn't shown when final static field is not assigned, follow-up
* @compile/fail/ref=CompileTimeErrorForNonAssignedStaticFieldTest.out -XDrawDiagnostics CompileTimeErrorForNonAssignedStaticFieldTest.java
*/
public class CompileTimeErrorForNonAssignedStaticFieldTest {
private final static int i;
public CompileTimeErrorForNonAssignedStaticFieldTest()
throws InstantiationException {
throw new InstantiationException("Can't instantiate");
}
static class Inner {
private final int j;
public Inner(int x)
throws InstantiationException {
if (x == 0) {
throw new InstantiationException("Can't instantiate");
} else {
j = 1;
}
System.out.println(j);
}
}
}
CompileTimeErrorForNonAssignedStaticFieldTest.java:14:5: compiler.err.var.might.not.have.been.initialized: i
1 error
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8003280 * @bug 8003280 8003306
* @summary Add lambda tests * @summary Add lambda tests
* Regression test JDK-8003306 inner class constructor in lambda * Regression test JDK-8003306 inner class constructor in lambda
* @author Robert Field * @author Robert Field
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8002099 * @bug 8002099 8010822
* @summary Add support for intersection types in cast expression * @summary Add support for intersection types in cast expression
*/ */
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 8008708
* @compile Foo.java * @compile Foo.java
* @compile Test.java * @compile Test.java
*/ */
......
/* /*
* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/** /**
* Class to hold annotations for ElementsAnnotatedWithTest. * Class to hold annotations for TestElementsAnnotatedWith.
*/ */
@AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings",
......
/** /nodynamiccopyright/
* Class to hold annotations for TestElementsAnnotatedWith.
*/
@AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings",
expectedSize=0,
names={})
@Undefined
public class ErroneousAnnotations {
@Undefined
private void foo() {return;}
}
ErroneousAnnotations.java:8:2: compiler.err.cant.resolve: kindname.class, Undefined, ,
ErroneousAnnotations.java:10:6: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, ErroneousAnnotations, null)
2 errors
Results: []
/* /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/** /**
* Class to hold annotations for ElementsAnnotatedWithTest. * Class to hold annotations for TestElementsAnnotatedWith.
*/ */
@AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings",
......
/* /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/** /**
* Class to hold annotations for ElementsAnnotatedWithTest. * Class to hold annotations for TestElementsAnnotatedWith.
*/ */
@SuppressWarnings("") @SuppressWarnings("")
public class Part2 { public class Part2 {
......
/* /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/** /**
* Class to hold annotations for ElementsAnnotatedWithTest. * Class to hold annotations for TestElementsAnnotatedWith.
*/ */
@AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings",
......
/* /*
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 8030049
* @summary Tests that getElementsAnnotatedWith works properly. * @summary Tests that getElementsAnnotatedWith works properly.
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library /tools/javac/lib * @library /tools/javac/lib
...@@ -37,23 +37,18 @@ ...@@ -37,23 +37,18 @@
* @compile -processor TestElementsAnnotatedWith -proc:only C2.java * @compile -processor TestElementsAnnotatedWith -proc:only C2.java
* @compile -processor TestElementsAnnotatedWith -proc:only Foo.java * @compile -processor TestElementsAnnotatedWith -proc:only Foo.java
* @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java * @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java
* @compile/fail/ref=ErroneousAnnotations.out -processor TestElementsAnnotatedWith -proc:only -XDrawDiagnostics ErroneousAnnotations.java
* @compile Foo.java * @compile Foo.java
* @compile/process -processor TestElementsAnnotatedWith -proc:only Foo * @compile/process -processor TestElementsAnnotatedWith -proc:only Foo
*/ */
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.io.*;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import javax.annotation.processing.*; import javax.annotation.processing.*;
import javax.tools.*;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import javax.lang.model.util.*;
import static javax.lang.model.util.ElementFilter.*; import static javax.lang.model.util.ElementFilter.*;
/** /**
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/** /**
* Class to hold annotations for ElementsAnnotatedWithTest. * Class to hold annotations for TestElementsAnnotatedWith.
*/ */
@AnnotatedElementInfo(annotationName="TpAnno", @AnnotatedElementInfo(annotationName="TpAnno",
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 7098660 * @bug 7098660 8014649
* @summary Write better overload resolution/inference tests * @summary Write better overload resolution/inference tests
* @library /tools/javac/lib * @library /tools/javac/lib
* @build JavacTestingAbstractProcessor ResolveHarness * @build JavacTestingAbstractProcessor ResolveHarness
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册