Merge branch 'master' at M5 into 'OT_BETA_JAVA8'
diff --git a/org.eclipse.jdt.core.tests.compiler/src/EvalTestsTarget.zip b/org.eclipse.jdt.core.tests.compiler/src/EvalTestsTarget.zip
new file mode 100644
index 0000000..19bb2e9
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/EvalTestsTarget.zip
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.compiler/src/TestJavadocVisibility.zip b/org.eclipse.jdt.core.tests.compiler/src/TestJavadocVisibility.zip
new file mode 100644
index 0000000..cfb2c9b
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/TestJavadocVisibility.zip
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java
new file mode 100644
index 0000000..600f7da
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java
@@ -0,0 +1,499 @@
+package org.eclipse.jdt.core.tests.compiler.parser;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.Locale;
+
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
+import org.eclipse.jdt.core.tests.util.Util;
+import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
+import org.eclipse.jdt.internal.codeassist.select.SelectionParser;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
+import org.eclipse.jdt.internal.compiler.DocumentElementParser;
+import org.eclipse.jdt.internal.compiler.IDocumentElementRequestor;
+import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
+import org.eclipse.jdt.internal.compiler.SourceElementParser;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.Expression;
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
+import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
+import org.eclipse.jdt.internal.compiler.parser.Parser;
+import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
+import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
+import org.eclipse.jdt.internal.core.search.indexing.IndexingParser;
+import org.eclipse.jdt.internal.core.util.CommentRecorderParser;
+
+public class AbstractSyntaxTreeTest extends AbstractCompilerTest implements IDocumentElementRequestor, ISourceElementRequestor {
+
+ protected static final int CHECK_PARSER = 0x1;
+ protected static final int CHECK_COMPLETION_PARSER = 0x2;
+ protected static final int CHECK_SELECTION_PARSER = 0x4;
+ protected static final int CHECK_DOCUMENT_ELEMENT_PARSER = 0x8;
+ protected static final int CHECK_COMMENT_RECORDER_PARSER = 0x10;
+ protected static final int CHECK_SOURCE_ELEMENT_PARSER = 0x20;
+ protected static final int CHECK_INDEXING_PARSER = 0x40;
+ protected static final int CHECK_JAVAC_PARSER = 0x80;
+ protected static int CHECK_ALL = (CHECK_PARSER | CHECK_COMPLETION_PARSER | CHECK_SELECTION_PARSER |
+ CHECK_DOCUMENT_ELEMENT_PARSER | CHECK_COMMENT_RECORDER_PARSER |
+ CHECK_SOURCE_ELEMENT_PARSER | CHECK_INDEXING_PARSER);
+ public static boolean optimizeStringLiterals = false;
+ private String referenceCompiler;
+ private String referenceCompilerTestsScratchArea;
+
+ public AbstractSyntaxTreeTest(String name, String referenceCompiler, String referenceCompilerTestsScratchArea) {
+ super(name);
+ this.referenceCompiler = referenceCompiler;
+ this.referenceCompilerTestsScratchArea = referenceCompilerTestsScratchArea;
+ }
+
+ public void checkParse(int parserToCheck, char[] source, String expectedSyntaxErrorDiagnosis,
+ String testName, String expectedUnitToString, ASTVisitor visitor) throws IOException {
+
+ CompilerOptions options = new CompilerOptions(getCompilerOptions());
+ options.complianceLevel = ClassFileConstants.JDK1_8;
+ options.sourceLevel = ClassFileConstants.JDK1_8;
+ options.targetJDK = ClassFileConstants.JDK1_8;
+
+ ICompilationUnit sourceUnit = null;
+ CompilationResult compilationResult = null;
+ CompilationUnitDeclaration unit = null;
+
+ if (this.referenceCompiler != null && (parserToCheck & CHECK_JAVAC_PARSER) != 0) {
+ String javaFilePath = this.referenceCompilerTestsScratchArea + "\\Xyz.java";
+ File f = new File(javaFilePath);
+ FileOutputStream o = new FileOutputStream(f);
+ OutputStreamWriter w = new OutputStreamWriter(o);
+ w.write(source);
+ w.close();
+ Process p = Runtime.getRuntime().exec (new String[] { this.referenceCompiler, "-sourcepath", this.referenceCompilerTestsScratchArea, javaFilePath }, null, new File(this.referenceCompilerTestsScratchArea));
+ try {
+ BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ BufferedReader stderr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ String line;
+ while ((line = stderr.readLine())!= null)
+ System.out.println(line);
+ while ((line = stdout.readLine())!= null)
+ System.out.println(line);
+ assertTrue("javac unhappy", p.waitFor() == 0);
+ } catch (InterruptedException e) {
+ System.err.println("Skipped javac behavior check due to interrupt...");
+ }
+ }
+ if ((parserToCheck & CHECK_PARSER) != 0) {
+ Parser parser1 =
+ new Parser(
+ new ProblemReporter(
+ DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+ options,
+ new DefaultProblemFactory(Locale.getDefault())),
+ optimizeStringLiterals);
+ sourceUnit = new CompilationUnit(source, testName, null);
+ compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
+ unit = parser1.parse(sourceUnit, compilationResult);
+ parser1.getMethodBodies(unit);
+ assertDianosticEquals(expectedSyntaxErrorDiagnosis, testName, compilationResult);
+ assertParseTreeEquals(expectedUnitToString, unit.toString());
+ if (visitor != null) {
+ unit.traverse(visitor, (CompilationUnitScope) null);
+ }
+ parser1 = null;
+ }
+
+ if ((parserToCheck & CHECK_COMPLETION_PARSER) != 0) {
+ CompletionParser parser2 = new CompletionParser(
+ new ProblemReporter(
+ DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+ options,
+ new DefaultProblemFactory(Locale.getDefault())),
+ false);
+ compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
+ unit = parser2.parse(sourceUnit, compilationResult, Integer.MAX_VALUE);
+ parser2.getMethodBodies(unit);
+ assertDianosticEquals(expectedSyntaxErrorDiagnosis, testName, compilationResult);
+ assertParseTreeEquals(expectedUnitToString, unit.toString());
+ parser2 = null;
+ }
+ if ((parserToCheck & CHECK_SELECTION_PARSER) != 0) {
+ SelectionParser parser3 = new SelectionParser(
+ new ProblemReporter(
+ DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+ options,
+ new DefaultProblemFactory(Locale.getDefault())));
+ compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
+ unit = parser3.parse(sourceUnit, compilationResult, Integer.MAX_VALUE, Integer.MAX_VALUE);
+ parser3.getMethodBodies(unit);
+ assertDianosticEquals(expectedSyntaxErrorDiagnosis, testName, compilationResult);
+ assertParseTreeEquals(expectedUnitToString, unit.toString());
+ parser3 = null;
+ }
+ if ((parserToCheck & CHECK_DOCUMENT_ELEMENT_PARSER) != 0) {
+ DocumentElementParser parser4 = new DocumentElementParser(
+ this,
+ new DefaultProblemFactory(Locale.getDefault()),
+ options);
+ compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
+ unit = parser4.parse(sourceUnit, compilationResult);
+ parser4.getMethodBodies(unit);
+ assertDianosticEquals(expectedSyntaxErrorDiagnosis, testName, compilationResult);
+ assertParseTreeEquals(expectedUnitToString, unit.toString());
+ parser4 = null;
+ }
+ if ((parserToCheck & CHECK_COMMENT_RECORDER_PARSER) != 0) {
+ CommentRecorderParser parser5 = new CommentRecorderParser(
+ new ProblemReporter(
+ DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+ options,
+ new DefaultProblemFactory(Locale.getDefault())),
+ optimizeStringLiterals);
+ compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
+ unit = parser5.parse(sourceUnit, compilationResult);
+ parser5.getMethodBodies(unit);
+ assertDianosticEquals(expectedSyntaxErrorDiagnosis, testName, compilationResult);
+ assertParseTreeEquals(expectedUnitToString, unit.toString());
+ parser5 = null;
+ }
+ if ((parserToCheck & CHECK_SOURCE_ELEMENT_PARSER) != 0) {
+ SourceElementParser parser6 = new SourceElementParser(this,
+ new DefaultProblemFactory(Locale.getDefault()),
+ options,
+ true,
+ optimizeStringLiterals);
+ compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
+ unit = parser6.parse(sourceUnit, compilationResult);
+ parser6.getMethodBodies(unit);
+ assertDianosticEquals(expectedSyntaxErrorDiagnosis, testName, compilationResult);
+ assertParseTreeEquals(expectedUnitToString, unit.toString());
+ parser6 = null;
+ }
+ if ((parserToCheck & CHECK_INDEXING_PARSER) != 0) {
+ IndexingParser parser7 = new IndexingParser(this,
+ new DefaultProblemFactory(Locale.getDefault()),
+ options,
+ true,
+ optimizeStringLiterals, false);
+ compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
+ unit = parser7.parse(sourceUnit, compilationResult);
+ parser7.getMethodBodies(unit);
+ assertDianosticEquals(expectedSyntaxErrorDiagnosis, testName, compilationResult);
+ assertParseTreeEquals(expectedUnitToString, unit.toString());
+ parser7 = null;
+ }
+ }
+
+ public void checkParse(int parserToCheck, char[] source, String expectedSyntaxErrorDiagnosis,
+ String testName, String expectedUnitToString) throws IOException {
+ checkParse(parserToCheck, source, expectedSyntaxErrorDiagnosis, testName, expectedUnitToString, null);
+ }
+
+ public void checkParse(char[] source, String expectedSyntaxErrorDiagnosis, String testName, String expectedUnitToString)
+ throws IOException {
+ checkParse(CHECK_ALL, source, expectedSyntaxErrorDiagnosis, testName, expectedUnitToString);
+ }
+
+ public void checkParse(char[] source, String expectedSyntaxErrorDiagnosis, String testName,
+ String expectedUnitToString, ASTVisitor visitor) throws IOException {
+ checkParse(CHECK_ALL, source, expectedSyntaxErrorDiagnosis, testName, expectedUnitToString, visitor);
+ }
+
+ private void assertParseTreeEquals(String expectedUnitToString, String computedUnitToString) {
+ if (expectedUnitToString == null) { // just checking that we are able to digest.
+ return;
+ }
+ if (!expectedUnitToString.equals(computedUnitToString)) {
+ System.out.println(Util.displayString(computedUnitToString));
+ }
+ assertEquals("Parse Tree is wrong",
+ Util.convertToIndependantLineDelimiter(expectedUnitToString),
+ Util.convertToIndependantLineDelimiter(computedUnitToString));
+ }
+
+ private void assertDianosticEquals(String expectedSyntaxErrorDiagnosis, String testName, CompilationResult compilationResult) {
+ String computedSyntaxErrorDiagnosis = getCompilerMessages(compilationResult);
+ assertEquals(
+ "Invalid syntax error diagnosis" + testName,
+ Util.convertToIndependantLineDelimiter(expectedSyntaxErrorDiagnosis),
+ Util.convertToIndependantLineDelimiter(computedSyntaxErrorDiagnosis));
+ }
+
+ private String getCompilerMessages(CompilationResult compilationResult) {
+ StringBuffer buffer = new StringBuffer(100);
+ if (compilationResult.hasProblems() || compilationResult.hasTasks()) {
+ CategorizedProblem[] problems = compilationResult.getAllProblems();
+ int count = problems.length;
+ int problemCount = 0;
+ char[] unitSource = compilationResult.compilationUnit.getContents();
+ for (int i = 0; i < count; i++) {
+ if (problems[i] != null) {
+ if (problemCount == 0)
+ buffer.append("----------\n");
+ problemCount++;
+ buffer.append(problemCount + (problems[i].isError() ? ". ERROR" : ". WARNING"));
+ buffer.append(" in " + new String(problems[i].getOriginatingFileName()).replace('/', '\\'));
+ try {
+ buffer.append(((DefaultProblem)problems[i]).errorReportSource(unitSource));
+ buffer.append("\n");
+ buffer.append(problems[i].getMessage());
+ buffer.append("\n");
+ } catch (Exception e) {
+ }
+ buffer.append("----------\n");
+ }
+ }
+ }
+ String computedSyntaxErrorDiagnosis = buffer.toString();
+ return computedSyntaxErrorDiagnosis;
+ }
+
+ public void acceptImport(int declarationStart, int declarationEnd, int[] javaDocPositions,
+ char[] name, int nameStartPosition, boolean onDemand, int modifiers) {
+
+
+ }
+
+ public void acceptInitializer(int declarationStart, int declarationEnd, int[] javaDocPositions,
+ int modifiers, int modifiersStart, int bodyStart, int bodyEnd) {
+
+
+ }
+
+ public void acceptLineSeparatorPositions(int[] positions) {
+
+
+ }
+
+ public void acceptPackage(int declarationStart, int declarationEnd, int[] javaDocPositions,
+ char[] name, int nameStartPosition) {
+
+
+ }
+
+ public void acceptProblem(CategorizedProblem problem) {
+
+
+ }
+
+ public void enterClass(int declarationStart, int[] javaDocPositions, int modifiers,
+ int modifiersStart, int classStart, char[] name, int nameStart, int nameEnd,
+ char[] superclass, int superclassStart, int superclassEnd, char[][] superinterfaces, int[] superinterfaceStarts,
+ int[] superinterfaceEnds, int bodyStart) {
+
+
+ }
+
+ public void enterCompilationUnit() {
+
+
+ }
+
+ public void enterConstructor(int declarationStart, int[] javaDocPositions, int modifiers,
+ int modifiersStart, char[] name, int nameStart, int nameEnd, char[][] parameterTypes,
+ int[] parameterTypeStarts, int[] parameterTypeEnds, char[][] parameterNames, int[] parameterNameStarts, int[] parameterNameEnds,
+ int parametersEnd, char[][] exceptionTypes, int[] exceptionTypeStarts, int[] exceptionTypeEnds, int bodyStart) {
+
+
+ }
+
+ public void enterField(int declarationStart, int[] javaDocPositions, int modifiers,
+ int modifiersStart, char[] type, int typeStart, int typeEnd, int typeDimensionCount,
+ char[] name, int nameStart, int nameEnd, int extendedTypeDimensionCount, int extendedTypeDimensionEnd) {
+
+
+ }
+
+ public void enterInterface(int declarationStart, int[] javaDocPositions, int modifiers,
+ int modifiersStart, int interfaceStart, char[] name, int nameStart, int nameEnd,
+ char[][] superinterfaces, int[] superinterfaceStarts, int[] superinterfaceEnds, int bodyStart) {
+
+
+ }
+
+ public void enterMethod(int declarationStart, int[] javaDocPositions, int modifiers,
+ int modifiersStart, char[] returnType, int returnTypeStart, int returnTypeEnd, int returnTypeDimensionCount,
+ char[] name, int nameStart, int nameEnd, char[][] parameterTypes, int[] parameterTypeStarts,
+ int[] parameterTypeEnds, char[][] parameterNames, int[] parameterNameStarts, int[] parameterNameEnds, int parametersEnd,
+ int extendedReturnTypeDimensionCount, int extendedReturnTypeDimensionEnd, char[][] exceptionTypes, int[] exceptionTypeStarts, int[] exceptionTypeEnds,
+ int bodyStart) {
+
+
+ }
+
+ public void exitClass(int bodyEnd, int declarationEnd) {
+
+
+ }
+
+ public void exitCompilationUnit(int declarationEnd) {
+
+
+ }
+
+ public void exitConstructor(int bodyEnd, int declarationEnd) {
+
+
+ }
+
+ public void exitField(int bodyEnd, int declarationEnd) {
+
+
+ }
+
+ public void exitInterface(int bodyEnd, int declarationEnd) {
+
+
+ }
+
+ public void exitMethod(int bodyEnd, int declarationEnd) {
+
+
+ }
+
+ public void acceptAnnotationTypeReference(char[][] annotation, int sourceStart,
+ int sourceEnd) {
+
+
+ }
+
+ public void acceptAnnotationTypeReference(char[] annotation, int sourcePosition) {
+
+
+ }
+
+ public void acceptConstructorReference(char[] typeName, int argCount,
+ int sourcePosition) {
+
+
+ }
+
+ public void acceptFieldReference(char[] fieldName, int sourcePosition) {
+
+
+ }
+
+ public void acceptImport(int declarationStart, int declarationEnd, int nameStart,
+ int nameEnd, char[][] tokens, boolean onDemand, int modifiers) {
+
+
+ }
+
+ public void acceptMethodReference(char[] methodName, int argCount, int sourcePosition) {
+
+
+ }
+
+ public void acceptPackage(ImportReference importReference) {
+
+
+ }
+
+ public void acceptTypeReference(char[][] typeName, int sourceStart, int sourceEnd) {
+
+
+ }
+
+ public void acceptTypeReference(char[] typeName, int sourcePosition) {
+
+
+ }
+
+ public void acceptUnknownReference(char[][] name, int sourceStart, int sourceEnd) {
+
+
+ }
+
+ public void acceptUnknownReference(char[] name, int sourcePosition) {
+
+
+ }
+
+ public void enterConstructor(MethodInfo methodInfo) {
+
+
+ }
+
+ public void enterField(FieldInfo fieldInfo) {
+
+
+ }
+
+ public void enterInitializer(int declarationStart, int modifiers) {
+
+
+ }
+
+ public void enterMethod(MethodInfo methodInfo) {
+
+
+ }
+
+ public void enterType(TypeInfo typeInfo) {
+
+
+ }
+
+ public void exitConstructor(int declarationEnd) {
+
+
+ }
+
+ public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
+
+
+ }
+
+ public void exitInitializer(int declarationEnd) {
+
+
+ }
+
+ public void exitMethod(int declarationEnd, Expression defaultValue) {
+
+
+ }
+
+ public void exitType(int declarationEnd) {
+
+
+ }
+
+//{ObjectTeams: new methods
+ public void acceptBaseReference(char[][] typeName, int sourceStart, int sourceEnd) {
+
+ }
+
+ public void enterCalloutMapping(CalloutInfo info) {
+
+ }
+
+ public void enterCalloutToFieldMapping(CalloutToFieldInfo info) {
+
+ }
+
+ public void enterCallinMapping(CallinInfo info) {
+
+ }
+
+ public void exitCalloutMapping(int sourceEnd, int declarationSourceEnd) {
+
+ }
+
+ public void exitCalloutToFieldMapping(int sourceEnd, int declarationSourceEnd) {
+
+ }
+
+ public void exitCallinMapping(int sourceEnd, int declarationSourceEnd) {
+
+ }
+// SH}
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
index a0a9e99..e6934f5 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Technical University Berlin - adapted for Object Teams
@@ -22,11 +26,11 @@
}
// Static initializer to specify tests subset using TESTS_* static variables
// All specified tests which does not belong to the class are skipped...
-//static {
-// TESTS_NAMES = new String[] { "test000" };
+static {
+// TESTS_NAMES = new String[] { "test0061" };
// TESTS_NUMBERS = new int[] { 50 };
// TESTS_RANGE = new int[] { 21, 50 };
-//}
+}
public static Test suite() {
return buildAllCompliancesTestSuite(testClass());
}
@@ -62,6 +66,25 @@
this.runNegativeTest(testFiles, expected17ProblemLog);
}
}
+public void runComplianceParserTest(
+ String[] testFiles,
+ String expected13ProblemLog,
+ String expected14ProblemLog,
+ String expected15ProblemLog,
+ String expected16ProblemLog,
+ String expected17ProblemLog){
+ if (this.complianceLevel == ClassFileConstants.JDK1_3) {
+ this.runNegativeTest(testFiles, expected13ProblemLog);
+ } else if(this.complianceLevel == ClassFileConstants.JDK1_4) {
+ this.runNegativeTest(testFiles, expected14ProblemLog);
+ } else if(this.complianceLevel == ClassFileConstants.JDK1_5) {
+ this.runNegativeTest(testFiles, expected15ProblemLog);
+ } else if(this.complianceLevel == ClassFileConstants.JDK1_6) {
+ this.runNegativeTest(testFiles, expected16ProblemLog);
+ } else if(this.complianceLevel < ClassFileConstants.JDK1_8) {
+ this.runNegativeTest(testFiles, expected17ProblemLog);
+ }
+ }
public void test0001() {
String[] testFiles = new String[] {
"X.java",
@@ -1061,12 +1084,12 @@
expected13ProblemLog;
String expected15ProblemLog =
- "----------\n" +
- "1. ERROR in X.java (at line 1)\n" +
- " import static for;\n" +
- " ^^^\n" +
- "Syntax error on token \"for\", Identifier expected\n" +
- "----------\n";
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " import static for;\n" +
+ " ^^^\n" +
+ "Syntax error on token \"for\", invalid Name\n" +
+ "----------\n";
runComplianceParserTest(
testFiles,
@@ -1344,7 +1367,7 @@
expected15ProblemLog
);
}
-public void test0030() {
+public void _test0030() {
String[] testFiles = new String[] {
"X.java",
"public class X {\n" +
@@ -1459,7 +1482,7 @@
expected15ProblemLog
);
}
-public void test0032() {
+public void _test0032() {
String[] testFiles = new String[] {
"X.java",
"public class X <T1 extends String, T2 extends Y {\n" +
@@ -2646,4 +2669,340 @@
expected17ProblemLog
);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383714
+public void test0057() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " public void foo() default { System.out.println(); }\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public void foo() default { System.out.println(); }\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Default methods are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383714
+public void test0058() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(int p);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I i = System::exit;\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " I i = System::exit;\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Method references are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383714
+public void test0059() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(int p);\n" +
+ "}\n" +
+ "class Y {\n" +
+ " static void goo(int x) {\n" +
+ " }\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " I i = super::goo;\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " I i = super::goo;\n" +
+ " ^^^^^^^^^^\n" +
+ "Method references are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383714
+public void test0060() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(int p);\n" +
+ "}\n" +
+ "class Y {\n" +
+ " void goo(int x) {\n" +
+ " }\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " I i = new Y()::goo;\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " I i = new Y()::goo;\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Method references are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383714
+public void test0061() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(int p);\n" +
+ "}\n" +
+ "class Y {\n" +
+ " void goo(int x) {\n" +
+ " }\n" +
+ " Y() {}\n" +
+ " Y(int x) {}\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " I i = Y::new;\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 11)\n" +
+ " I i = Y::new;\n" +
+ " ^^^^^^^\n" +
+ "Constructor references are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383714
+public void test0062() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " int foo(int p);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I i = p -> 10 + 20 + 30;\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " I i = p -> 10 + 20 + 30;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "Lambda expressions are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=381358
+public void test0063() {
+ if (this.complianceLevel <= ClassFileConstants.JDK1_4 || this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " int foo(int p);\n" +
+ "}\n" +
+ "public class X<T> {\n" +
+ " I i = X<String>::foo;\n" +
+ " I i2 = (p) -> 10;\n" +
+ " public static int foo(int p) {\n" +
+ " return p;\n" +
+ " }\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " I i = X<String>::foo;\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "Method references are allowed only at source level 1.8 or above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " I i2 = (p) -> 10;\n" +
+ " ^^^^^^^^^\n" +
+ "Lambda expressions are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383913#c22
+public void test0064() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] source = new String[] {
+ "X.java",
+ "class X {\n" +
+ " void foo(X this){}\n" +
+ "}"
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " void foo(X this){}\n" +
+ " ^^^^\n" +
+ "Explicit declaration of 'this' parameter is allowed only at source level 1.8 or above\n" +
+ "----------\n";
+ runComplianceParserTest(
+ source,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=391201
+public void testBug391201() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8 || this.complianceLevel < ClassFileConstants.JDK1_5) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @Marker int foo(@Marker int p) {\n" +
+ " @Marker int i = 0;\n" +
+ " return i;\n" +
+ " }\n" +
+ " @Marker\n" +
+ " class Y {}\n" +
+ " @java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_USE)\n" +
+ " @interface Marker {}" +
+ "}",
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n" +
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " @Marker int foo(@Marker int p) {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are available only when source level is at least 1.8\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " @Marker int foo(@Marker int p) {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are available only when source level is at least 1.8\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " @Marker int i = 0;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are available only when source level is at least 1.8\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 6)\n" +
+ " @Marker\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are available only when source level is at least 1.8\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
index 5eb01c8..ba11373 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Technical University Berlin - adapted for Object Teams
@@ -2500,7 +2504,7 @@
* Should recover from method with missing argument names
*/
-public void test32() {
+public void _test32() {
String s =
"public class WB2 { \n"+
@@ -4646,14 +4650,14 @@
" super();\n" +
" }\n" +
" int hello() {\n" +
- " fo = $missing$;\n" +
+ " fo $missing$;\n" +
" }\n" +
" int world() {\n" +
" }\n" +
" void foo() {\n" +
" }\n" +
" }\n" +
- " ba = $missing$;\n" +
+ " ba $missing$;\n" +
" }\n" +
"}\n";
@@ -4848,7 +4852,7 @@
" else\n" +
" if ((depth > 1))\n" +
" {\n" +
- " sol = $missing$;\n" +
+ " sol $missing$;\n" +
" }\n" +
" else\n" +
" ;\n" +
@@ -6003,7 +6007,7 @@
" restricts breakpoint;\n" +
" given thread;\n" +
" any other;\n" +
- " specified = $missing$;\n" +
+ " specified $missing$;\n" +
" }\n" +
" public void removeThreadFilter(IJavaThread thread) {\n" +
" removes the;\n" +
@@ -6014,7 +6018,7 @@
" request as;\n" +
" does not;\n" +
" the removal;\n" +
- " thread = $missing$;\n" +
+ " thread $missing$;\n" +
:giro */
// SH}
" }\n" +
@@ -6582,7 +6586,7 @@
expectedFullUnitToString,
expectedCompletionDietUnitToString, testName);
}
-public void test110() {
+public void _test110() {
String s =
"public class X {\n" +
" void bar(){\n" +
@@ -7585,7 +7589,7 @@
expectedCompletionDietUnitToString, testName);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=157570
-public void test124() {
+public void _test124() {
String s =
"public class Test {\n" +
" void aMethod() {\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
index 55209fb..bf903fa 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
@@ -1,9 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
@@ -949,7 +953,7 @@
expectedFullUnitToString,
expectedCompletionDietUnitToString, testName);
}
-public void test0019() {
+public void _test0019() {
String s =
"package a; \n"
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java
new file mode 100644
index 0000000..744c33f
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java
@@ -0,0 +1,719 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.parser;
+
+import java.io.File;
+import java.io.IOException;
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
+
+public class LambdaExpressionSyntaxTest extends AbstractSyntaxTreeTest {
+
+ private static String jsr335TestScratchArea = "c:\\Jsr335TestScratchArea";
+ private static String referenceCompiler = "C:\\jdk-7-ea-bin-b75-windows-i586-30_oct_2009\\jdk7\\bin\\javac.exe"; // TODO: Patch when RI becomes available.
+
+ public static Class testClass() {
+ return LambdaExpressionSyntaxTest.class;
+ }
+ public void initialize(CompilerTestSetup setUp) {
+ super.initialize(setUp);
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+ }
+
+ public LambdaExpressionSyntaxTest(String testName){
+ super(testName, referenceCompiler, jsr335TestScratchArea);
+ if (referenceCompiler != null) {
+ File f = new File(jsr335TestScratchArea);
+ if (!f.exists()) {
+ f.mkdir();
+ }
+ CHECK_ALL |= CHECK_JAVAC_PARSER;
+ }
+ }
+
+ static {
+ // TESTS_NAMES = new String[] { "test0012" };
+ // TESTS_NUMBERS = new int[] { 133, 134, 135 };
+ if (!(new File(referenceCompiler).exists())) {
+ referenceCompiler = null;
+ jsr335TestScratchArea = null;
+ }
+ }
+ // type elided, unparenthesized parameter + expression body lambda in casting context.
+ public void test0001() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(((I) x -> x * x).square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(((I) (<no type> x) -> (x * x)).square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0001", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda as initializer.
+ public void test0002() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = x -> x * x;\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = (<no type> x) -> (x * x);\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0002", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda as initializer, full lambda is parenthesized.
+ public void test0003() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = ((((x -> x * x))));\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = (((((<no type> x) -> (x * x)))));\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0003", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda as RHS of assignment, full lambda is parenthesized.
+ public void test0004() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i;\n" +
+ " i = (x -> x * x);\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i;\n" +
+ " i = ((<no type> x) -> (x * x));\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0004", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in return statement, full lambda is parenthesized.
+ public void test0005() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static I getI() {\n" +
+ " return (x -> x * x);\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static I getI() {\n" +
+ " return ((<no type> x) -> (x * x));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0005", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in conditional expression.
+ public void test0006() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = args == null ? x -> x * x : x -> x * x * x;\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = ((args == null) ? (<no type> x) -> (x * x) : (<no type> x) -> ((x * x) * x));\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0006", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in message send.
+ public void test0007() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " foo(x -> x * x, x -> x * x * x);\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " foo((<no type> x) -> (x * x), (<no type> x) -> ((x * x) * x));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0007", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in constructor call.
+ public void test0008() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " X (I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " new X(x -> x * x, x -> x * x * x);\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " X(I i1, I i2) {\n" +
+ " super();\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X((<no type> x) -> (x * x), (<no type> x) -> ((x * x) * x));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0008", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in lambda.
+ public void test0009() throws IOException {
+ String source =
+ "interface I {\n" +
+ " I square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println (((I) a->b->c->d->e->f->g-> null).square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " I square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(((I) (<no type> a) -> (<no type> b) -> (<no type> c) -> (<no type> d) -> (<no type> e) -> (<no type> f) -> (<no type> g) -> null).square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0009", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in an initializer block
+ public void test00010() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static I i = x -> x * x;\n" +
+ " {\n" +
+ " i = x -> x * x * x;\n" +
+ " }\n" +
+ " static {\n" +
+ " i = x -> x * x * x;\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static I i = (<no type> x) -> (x * x);\n" +
+ " {\n" +
+ " i = (<no type> x) -> ((x * x) * x);\n" +
+ " }\n" +
+ " static {\n" +
+ " i = (<no type> x) -> ((x * x) * x);\n" +
+ " }\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test00010", expectedUnitToString);
+ }
+ // type elided, parenthesized parameter + expression body lambda in casting context.
+ public void test0011() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(((I) (x) -> x * x).square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(((I) (<no type> x) -> (x * x)).square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0011", expectedUnitToString);
+ }
+ // Normal & minimal parameter list + expression body lambda in assignment context.
+ public void test0012() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = (int x) -> x * x;\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = (int x) -> (x * x);\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0012", expectedUnitToString);
+ }
+ // Normal parameter list, with modifiers & annotations + expression body lambda in invocation context.
+ public void test0013() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " @interface Positive {}\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " foo((final int x) -> x * x, (final @Positive int x) -> x * x * x);\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " @interface Positive {\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " foo((final int x) -> (x * x), (final @Positive int x) -> ((x * x) * x));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0013", expectedUnitToString);
+ }
+ // Vararg parameter list, with modifiers & annotations + expression body lambda in message send context.
+ public void test0014() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int ... x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " @interface Positive {}\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " foo((final int ... x) -> 10, (final @Positive int [] x) -> 20);\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int... x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " @interface Positive {\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " foo((final int... x) -> 10, (final @Positive int[] x) -> 20);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0014", expectedUnitToString);
+ }
+ // multi parameter type elided list + expression body lambda in return statement.
+ public void test0015() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int product(int x, int y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static I getI() {\n" +
+ " return ((x, y) -> x * y);\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.product(5, 6));\n" +
+ " }\n" +
+ "};\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int product(int x, int y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static I getI() {\n" +
+ " return ((<no type> x, <no type> y) -> (x * y));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.product(5, 6));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0015", expectedUnitToString);
+ }
+ // multi parameter type specified list + block body lambda in return statement.
+ public void test0016() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int product(int x, int y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static I getI() {\n" +
+ " return (int x, int y) -> { return x * y; };\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.product(5, 6));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int product(int x, int y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static I getI() {\n" +
+ " return (int x, int y) -> {\n" +
+ " return (x * y);\n" +
+ "};\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.product(5, 6));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0016", expectedUnitToString);
+ }
+ // noarg + block body lambda
+ public void test0017() throws IOException {
+ String source =
+ "interface I {\n" +
+ " String noarg();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println( ((I) () -> { return \"noarg\"; }).noarg());\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " String noarg();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(((I) () -> {\n" +
+ " return \"noarg\";\n" +
+ "}).noarg());\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0017", expectedUnitToString);
+ }
+ // Assorted tests.
+ public void test0018() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo();\n" +
+ "}\n" +
+ "\n" +
+ "interface J {\n" +
+ " int foo();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I i1 = ()->{}; \n" +
+ " J j1 = ()->0;\n" +
+ " J j2 = ()->{ return 0; };\n" +
+ " I i2 = ()->{ System.gc(); };\n" +
+ " J j3 = ()->{\n" +
+ " if (true) return 0;\n" +
+ " else {\n" +
+ " int r = 12;\n" +
+ " for (int i = 1; i < 8; i++)\n" +
+ " r += i;\n" +
+ " return r;\n" +
+ " }\n" +
+ " };\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo();\n" +
+ "}\n" +
+ "interface J {\n" +
+ " int foo();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I i1 = () -> {\n" +
+ " };\n" +
+ " J j1 = () -> 0;\n" +
+ " J j2 = () -> {\n" +
+ " return 0;\n" +
+ " };\n" +
+ " I i2 = () -> {\n" +
+ " System.gc();\n" +
+ " };\n" +
+ " J j3 = () -> {\n" +
+ " if (true)\n" +
+ " return 0;\n" +
+ " else\n" +
+ " {\n" +
+ " int r = 12;\n" +
+ " for (int i = 1;; (i < 8); i ++) \n" +
+ " r += i;\n" +
+ " return r;\n" +
+ " }\n" +
+ " };\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0018", expectedUnitToString);
+ }
+
+ // like test0001() but body expression is an assignment
+ public void test0019() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " int y;\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(((I) x -> y = x * x ).square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " int y;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(((I) (<no type> x) -> y = (x * x)).square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0019", expectedUnitToString);
+ }
+
+ // Coverage: exercise this condition in Parser.consumeExpression():
+ // if (this.valueLambdaNestDepth >= 0 && this.stateStackLengthStack[this.valueLambdaNestDepth] == this.stateStackTop - 1)
+ // make sure we see a (true && false) combination
+ public void testNestedLambda01() throws IOException {
+ String source =
+ "public class C {\n" +
+ " I foo() {\n" +
+ " return (i1, i2) -> (String x1, String x2) -> { \n" +
+ " return x1+x2; \n" + // here end-of-expression does not finish the type-eliding lambda (i1,i2)->...
+ " };\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "interface I {\n" +
+ " String doit(String s1, String s2);\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class C {\n" +
+ " public C() {\n" +
+ " super();\n" +
+ " }\n" +
+ " I foo() {\n" +
+ " return (<no type> i1, <no type> i2) -> (String x1, String x2) -> {\n" +
+ " return (x1 + x2);\n" +
+ "};\n" +
+ " }\n" +
+ "}\n" +
+ "interface I {\n" +
+ " String doit(String s1, String s2);\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "testNestedLambda01", expectedUnitToString);
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385132
+ public void test385132() throws IOException {
+ String source = "->";
+ String expectedErrorString =
+ "----------\n" +
+ "1. ERROR in test385132 (at line 1)\n" +
+ " ->\n" +
+ " ^^\n" +
+ "Syntax error on token \"->\", delete this token\n" +
+ "----------\n";
+
+ checkParse(CHECK_PARSER , source.toCharArray(), expectedErrorString, "test385132", null);
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
index 75d26ea..a4651ea 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -71,18 +75,22 @@
" }\n" +
"}\n"
},
- "----------\n" +
- "1. ERROR in X.java (at line 3)\n" +
- " throws new X\n" +
- " ^^^^^^\n" +
- "Syntax error on token \"throws\", throw expected\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " throws new X\n" +
- " ^\n" +
- "Syntax error, unexpected end of method\n" +
- "----------\n"
- );
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"throws\", throw expected\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^\n" +
+ "Syntax error, insert \"( )\" to complete Expression\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^\n" +
+ "Syntax error, insert \";\" to complete BlockStatements\n" +
+ "----------\n");
}
public void test004() {
this.runNegativeTest(
@@ -130,18 +138,22 @@
" }\n" +
"}\n"
},
- "----------\n" +
- "1. ERROR in X.java (at line 3)\n" +
- " throws new X\n" +
- " ^^^^^^\n" +
- "Syntax error on token \"throws\", throw expected\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " throws new X\n" +
- " ^\n" +
- "Syntax error, unexpected end of initializer\n" +
- "----------\n"
- );
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"throws\", throw expected\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^\n" +
+ "Syntax error, insert \"( )\" to complete Expression\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^\n" +
+ "Syntax error, insert \";\" to complete BlockStatements\n" +
+ "----------\n");
}
public void test007() {
this.runNegativeTest(
@@ -228,7 +240,7 @@
"----------\n"
);
}
-public void test011() {
+public void _test011() {
this.runNegativeTest(
new String[] {
"X.java",
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java
new file mode 100644
index 0000000..c2e7612
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java
@@ -0,0 +1,983 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.parser;
+
+import java.io.File;
+import java.io.IOException;
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
+
+public class ReferenceExpressionSyntaxTest extends AbstractSyntaxTreeTest {
+
+ private static String jsr335TestScratchArea = "c:\\Jsr335TestScratchArea";
+ private static String referenceCompiler = "C:\\jdk-7-ea-bin-b75-windows-i586-30_oct_2009\\jdk7\\bin\\javac.exe"; // TODO: Patch when RI becomes available.
+
+ public static Class testClass() {
+ return ReferenceExpressionSyntaxTest.class;
+ }
+ public void initialize(CompilerTestSetup setUp) {
+ super.initialize(setUp);
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+ }
+
+ public ReferenceExpressionSyntaxTest(String testName){
+ super(testName, referenceCompiler, jsr335TestScratchArea);
+ if (referenceCompiler != null) {
+ File f = new File(jsr335TestScratchArea);
+ if (!f.exists()) {
+ f.mkdir();
+ }
+ CHECK_ALL |= CHECK_JAVAC_PARSER;
+ }
+ }
+
+ static {
+ // TESTS_NAMES = new String[] { "test0012" };
+ // TESTS_NUMBERS = new int[] { 133, 134, 135 };
+ if (!(new File(referenceCompiler).exists())) {
+ referenceCompiler = null;
+ jsr335TestScratchArea = null;
+ }
+ }
+ // Reference expression - super:: form, without type arguments.
+ public void test0001() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " public static void main(String [] args) {\n" +
+ " new X().doit();\n" +
+ " }\n" +
+ " void doit() {\n" +
+ " I i = super::foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().doit();\n" +
+ " }\n" +
+ " void doit() {\n" +
+ " I i = super::foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0001", expectedUnitToString);
+ }
+ // Reference expression - super:: form, with type arguments.
+ public void test0002() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " public static void main(String [] args) {\n" +
+ " new X().doit();\n" +
+ " }\n" +
+ " void doit() {\n" +
+ " I i = super::<String>foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().doit();\n" +
+ " }\n" +
+ " void doit() {\n" +
+ " I i = super::<String>foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0002", expectedUnitToString);
+ }
+ // Reference expression - SimpleName:: form, without type arguments.
+ public void test0003() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y::foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y::foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0003", expectedUnitToString);
+ }
+ // Reference expression - SimpleName:: form, with type arguments.
+ public void test0004() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y::<String>foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y::<String>foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0004", expectedUnitToString);
+ }
+ // Reference expression - QualifiedName:: form, without type arguments.
+ public void test0005() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y.Z::foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " static class Z {\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y.Z::foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " static class Z {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0005", expectedUnitToString);
+ }
+ // Reference expression - QualifiedName:: form, with type arguments.
+ public void test0006() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y.Z::<String>foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " static class Z {\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y.Z::<String>foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " static class Z {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0006", expectedUnitToString);
+ }
+ // Reference expression - Primary:: form, without type arguments.
+ public void test0007() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = new Y()::foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = new Y()::foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0007", expectedUnitToString);
+ }
+ // Reference expression - primary:: form, with type arguments.
+ public void test0008() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = new Y()::<String>foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = new Y()::<String>foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0008", expectedUnitToString);
+ }
+ // Reference expression - X<T>:: form, without type arguments.
+ public void test0009() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String> y, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>::foo;\n" +
+ " i.foo(new Y<String>(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String> y, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>::foo;\n" +
+ " i.foo(new Y<String>(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0009", expectedUnitToString);
+ }
+ // Reference expression - X<T>:: form, with type arguments.
+ public void test0010() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String> y, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>::<String>foo;\n" +
+ " i.foo(new Y<String>(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String> y, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>::<String>foo;\n" +
+ " i.foo(new Y<String>(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0010", expectedUnitToString);
+ }
+ // Reference expression - X<T>.Name:: form, without type arguments.
+ public void test0011() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String>.Z z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.Z::foo;\n" +
+ " i.foo(new Y<String>().new Z(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String>.Z z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>.Z::foo;\n" +
+ " i.foo(new Y<String>().new Z(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0011", expectedUnitToString);
+ }
+ // Reference expression - X<T>.Name:: form, with type arguments.
+ public void test0012() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String>.Z z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.Z::<String>foo;\n" +
+ " i.foo(new Y<String>().new Z(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String>.Z z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>.Z::<String>foo;\n" +
+ " i.foo(new Y<String>().new Z(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0012", expectedUnitToString);
+ }
+ // Reference expression - X<T>.Y<K>:: form, without type arguments.
+ public void test0013() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String>.Z<Integer> z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.Z<Integer>::foo;\n" +
+ " i.foo(new Y<String>().new Z<Integer>(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String>.Z<Integer> z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>.Z<Integer>::foo;\n" +
+ " i.foo(new Y<String>().new Z<Integer>(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0013", expectedUnitToString);
+ }
+ // Reference expression - X<T>.Y<K>:: form, with type arguments.
+ public void test0014() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String>.Z<Integer> z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.Z<Integer>::<String>foo;\n" +
+ " i.foo(new Y<String>().new Z<Integer>(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String>.Z<Integer> z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>.Z<Integer>::<String>foo;\n" +
+ " i.foo(new Y<String>().new Z<Integer>(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0014", expectedUnitToString);
+ }
+ // Constructor reference expression - X<T>.Y<K>::new form, with type arguments.
+ public void test0015() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String> y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.Z<Integer>::<String>new;\n" +
+ " i.foo(new Y<String>()); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " Z() {\n" +
+ " System.out.println(\"Y<T>.Z<K>::new\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String> y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>.Z<Integer>::<String>new;\n" +
+ " i.foo(new Y<String>());\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " System.out.println(\"Y<T>.Z<K>::new\");\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0015", expectedUnitToString);
+ }
+ // Reference expression - PrimitiveType[]:: form, with type arguments.
+ public void test0016() throws IOException {
+ String source =
+ "interface I {\n" +
+ " Object copy(int [] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = int[]::<String>clone;\n" +
+ " i.copy(new int[10]); \n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " Object copy(int[] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = int[]::<String>clone;\n" +
+ " i.copy(new int[10]);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0016", expectedUnitToString);
+ }
+ // Reference expression - Name[]:: form, with type arguments.
+ public void test0017() throws IOException {
+ String source =
+ "interface I {\n" +
+ " Object copy(X [] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = X[]::<String>clone;\n" +
+ " i.copy(new X[10]); \n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " Object copy(X[] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = X[]::<String>clone;\n" +
+ " i.copy(new X[10]);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0017", expectedUnitToString);
+ }
+ // Reference expression - X<T>.Y<K>[]:: form, with type arguments.
+ public void test0018() throws IOException {
+ String source =
+ "interface I {\n" +
+ " Object copy(X<String>.Y<Integer> [] p);\n" +
+ "}\n" +
+ "public class X<T> {\n" +
+ " class Y<K> {\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = X<String>.Y<Integer>[]::<String>clone;\n" +
+ " X<String>.Y<Integer>[] xs = null;\n" +
+ " i.copy(xs); \n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " Object copy(X<String>.Y<Integer>[] p);\n" +
+ "}\n" +
+ "public class X<T> {\n" +
+ " class Y<K> {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = X<String>.Y<Integer>[]::<String>clone;\n" +
+ " X<String>.Y<Integer>[] xs = null;\n" +
+ " i.copy(xs);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0018", expectedUnitToString);
+ }
+
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=384320, syntax error while mixing 308 and 335.
+ public void test0019() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(X<String> s, int x);\n" +
+ "}\n" +
+ "public class X<T> {\n" +
+ " I i = X<@Foo({\"hello\"}) String>::foo;\n" +
+ " void foo(int x) {\n" +
+ " }\n" +
+ "}\n" +
+ "@interface Foo {\n" +
+ " String [] value();\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(X<String> s, int x);\n" +
+ "}\n" +
+ "public class X<T> {\n" +
+ " I i = X<@Foo({\"hello\"}) String>::foo;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " }\n" +
+ "}\n" +
+ "@interface Foo {\n" +
+ " String[] value();\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0019", expectedUnitToString);
+ }
+
+ // Reference expression - Name::new forms, with/without type arguments.
+ public void test0020() throws IOException {
+ String source =
+ "interface I {\n" +
+ " Y foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " class Z extends Y {\n" +
+ " public Z(int x) {\n" +
+ " super(x);\n" +
+ " System.out.println(\"Z\"+x);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " Y y;\n" +
+ " I i = Y::new;\n" +
+ " y = i.foo(10); \n" +
+ " i = X.Z::new;\n" +
+ " y = i.foo(20); \n" +
+ " i = W<Integer>::new;\n" +
+ " y = i.foo(23);\n" +
+ " }\n" +
+ "}\n" +
+ "class W<T> extends Y {\n" +
+ " public W(T x) {\n" +
+ " super(0);\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public Y(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " Y foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " class Z extends Y {\n" +
+ " public Z(int x) {\n" +
+ " super(x);\n" +
+ " System.out.println((\"Z\" + x));\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " Y y;\n" +
+ " I i = Y::new;\n" +
+ " y = i.foo(10);\n" +
+ " i = X.Z::new;\n" +
+ " y = i.foo(20);\n" +
+ " i = W<Integer>::new;\n" +
+ " y = i.foo(23);\n" +
+ " }\n" +
+ "}\n" +
+ "class W<T> extends Y {\n" +
+ " public W(T x) {\n" +
+ " super(0);\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public Y(int x) {\n" +
+ " super();\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0003", expectedUnitToString);
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385132
+ public void test385132() throws IOException {
+ String source = "::";
+ String expectedErrorString =
+ "----------\n" +
+ "1. ERROR in test385132 (at line 1)\n" +
+ " ::\n" +
+ " ^^\n" +
+ "Syntax error on token \"::\", delete this token\n" +
+ "----------\n";
+
+ checkParse(CHECK_PARSER , source.toCharArray(), expectedErrorString, "test385132", null);
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385374, Support for 308 style type annotations on 335 constructs.
+ public void test385374() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo();\n" +
+ "}\n" +
+ "@interface TypeAnnotation {\n" +
+ "}\n" +
+ "\n" +
+ "class X<T> {\n" +
+ " // Primitive array form\n" +
+ " I x1 = @TypeAnnotation int []::clone;\n" +
+ " // Primitive array form with dimension annotations.\n" +
+ " I x2 = @TypeAnnotation int @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" +
+ " // Primitive array form with dimension annotations and type parameter annotations.\n" +
+ " I x3 = @TypeAnnotation int @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
+ " // Reference type name form\n" +
+ " I x4 = @TypeAnnotation X::clone;\n" +
+ " // Reference type name array form\n" +
+ " I x5 = @TypeAnnotation X []::clone;\n" +
+ " // Reference type name array form with dimension annotations.\n" +
+ " I x6 = @TypeAnnotation X @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" +
+ " // Reference type name array form with dimension annotations and type parameter annotations.\n" +
+ " I x7 = @TypeAnnotation X @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
+ " // Generic type array form with dimension annotations and type parameter annotations.\n" +
+ " I x8 = @TypeAnnotation X<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
+ " // Qualified generic type array form with dimension annotations and type parameter annotations.\n" +
+ " I x9 = @TypeAnnotation X<@TypeParameterAnnotation String>.Y<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo();\n" +
+ "}\n" +
+ "@interface TypeAnnotation {\n" +
+ "}\n" +
+ "class X<T> {\n" +
+ " I x1 = @TypeAnnotation int[]::clone;\n" +
+ " I x2 = @TypeAnnotation int @ArrayAnnotation [] @ArrayAnnotation []::clone;\n" +
+ " I x3 = @TypeAnnotation int @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" +
+ " I x4 = @TypeAnnotation X::clone;\n" +
+ " I x5 = @TypeAnnotation X[]::clone;\n" +
+ " I x6 = @TypeAnnotation X @ArrayAnnotation [] @ArrayAnnotation []::clone;\n" +
+ " I x7 = @TypeAnnotation X @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" +
+ " I x8 = @TypeAnnotation X<@TypeParameterAnnotation String> @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" +
+ " I x9 = @TypeAnnotation X<@TypeParameterAnnotation String>.Y<@TypeParameterAnnotation String> @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test385374", expectedUnitToString);
+ }
+ /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=385374, Support for 308 style type annotations on 335 constructs - make sure illegal modifiers are rejected
+ This test has been rendered meaningless as the grammar has been so throughly changed - Type annotations are not accepted via modifiers in the first place.
+ Disabling this test as we don't want fragile and unstable tests that are at the whimsy of the diagnose parser's complex algorithms.
+ */
+ public void test385374a() throws IOException {
+ // Nop.
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java
index f07295e..9d90885 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java
@@ -1,9 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
@@ -110,6 +114,17 @@
TestCase.RUN_ONLY_ID = null;
all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_7, tests_1_7));
}
+ if ((possibleComplianceLevels & AbstractCompilerTest.F_1_8) != 0) {
+ ArrayList tests_1_8 = (ArrayList)testClasses.clone();
+ tests_1_8.addAll(TEST_CLASSES_1_5);
+ // Reset forgotten subsets tests
+ TestCase.TESTS_PREFIX = null;
+ TestCase.TESTS_NAMES = null;
+ TestCase.TESTS_NUMBERS= null;
+ TestCase.TESTS_RANGE = null;
+ TestCase.RUN_ONLY_ID = null;
+ all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_8, tests_1_8));
+ }
return all;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
index e5a9a09..1ca2a31 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Technical University Berlin - adapted for Object Teams
@@ -163,27 +167,27 @@
"} \n";
String expectedSyntaxErrorDiagnosis =
- "----------\n" +
- "1. ERROR in <parenthesis mismatch> (at line 3)\n" +
- " [ arg1, \n" +
- " ^\n" +
- "Syntax error on token \"[\", invalid Type\n" +
- "----------\n" +
- "2. ERROR in <parenthesis mismatch> (at line 4)\n" +
- " { arg2, ] \n" +
- " ^\n" +
- "Syntax error on token \"{\", invalid Type\n" +
- "----------\n" +
- "3. ERROR in <parenthesis mismatch> (at line 4)\n" +
- " { arg2, ] \n" +
- " ^\n" +
- "Syntax error on token \"]\", invalid Type\n" +
- "----------\n" +
- "4. ERROR in <parenthesis mismatch> (at line 5)\n" +
- " arg3, \n" +
- " ^\n" +
- "Syntax error on token \",\", FormalParameter expected after this token\n" +
- "----------\n";
+ "----------\n" +
+ "1. ERROR in <parenthesis mismatch> (at line 3)\n" +
+ " [ arg1, \n" +
+ " ^\n" +
+ "Syntax error on token \"[\", byte expected\n" +
+ "----------\n" +
+ "2. ERROR in <parenthesis mismatch> (at line 4)\n" +
+ " { arg2, ] \n" +
+ " ^\n" +
+ "Syntax error on token \"{\", byte expected\n" +
+ "----------\n" +
+ "3. ERROR in <parenthesis mismatch> (at line 4)\n" +
+ " { arg2, ] \n" +
+ " ^\n" +
+ "Syntax error on token \"]\", byte expected\n" +
+ "----------\n" +
+ "4. ERROR in <parenthesis mismatch> (at line 5)\n" +
+ " arg3, \n" +
+ " ^\n" +
+ "Syntax error on token \",\", FormalParameter expected after this token\n" +
+ "----------\n";
String testName = "<parenthesis mismatch>";
checkParse(
@@ -270,12 +274,12 @@
"} \n";
String expectedSyntaxErrorDiagnosis =
- "----------\n"+
- "1. ERROR in <test> (at line 3)\n"+
- " i; \n"+
- " ^\n"+
- "Syntax error, insert \"AssignmentOperator Expression\" to complete Expression\n"+
- "----------\n";
+ "----------\n" +
+ "1. ERROR in <test> (at line 3)\n" +
+ " i; \n" +
+ " ^\n" +
+ "Syntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration\n" +
+ "----------\n";
String testName = "<test>";
checkParse(
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
index 44d8b3c..491d0ed 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -128,6 +132,21 @@
TestCase.RUN_ONLY_ID = null;
all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_7, tests_1_7));
}
+ if ((possibleComplianceLevels & AbstractCompilerTest.F_1_8) != 0) {
+ ArrayList tests_1_8 = (ArrayList)testClasses.clone();
+ tests_1_8.addAll(TEST_CLASSES_1_5);
+ tests_1_8.add(ParserTest1_7.class);
+ tests_1_8.add(LambdaExpressionSyntaxTest.class);
+ tests_1_8.add(ReferenceExpressionSyntaxTest.class);
+ tests_1_8.add(TypeAnnotationSyntaxTest.class);
+ // Reset forgotten subsets tests
+ TestCase.TESTS_PREFIX = null;
+ TestCase.TESTS_NAMES = null;
+ TestCase.TESTS_NUMBERS= null;
+ TestCase.TESTS_RANGE = null;
+ TestCase.RUN_ONLY_ID = null;
+ all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_8, tests_1_8));
+ }
return all;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java
new file mode 100644
index 0000000..d93fe21
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java
@@ -0,0 +1,3837 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.parser;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.HashMap;
+import java.util.Map;
+import junit.framework.Test;
+import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.ast.Annotation;
+import org.eclipse.jdt.internal.compiler.ast.Argument;
+import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation;
+import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.NormalAnnotation;
+import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation;
+import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
+
+public class TypeAnnotationSyntaxTest extends AbstractSyntaxTreeTest {
+
+ private static String jsr308TestScratchArea = "c:\\Jsr308TestScratchArea";
+ private static String referenceCompiler = "C:\\jdk-7-ea-bin-b75-windows-i586-30_oct_2009\\jdk7\\bin\\javac.exe";
+
+ static {
+// TESTS_NAMES = new String [] { "test0137" };
+ }
+ public static Class testClass() {
+ return TypeAnnotationSyntaxTest.class;
+ }
+ public void initialize(CompilerTestSetup setUp) {
+ super.initialize(setUp);
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+ }
+
+ static final class LocationPrinterVisitor extends ASTVisitor {
+ Annotation[] primaryAnnotations;
+ TypeReference enclosingReference;
+ Map locations;
+
+ public LocationPrinterVisitor() {
+ this.locations = new HashMap();
+ }
+
+ public Map getLocations() {
+ return this.locations;
+ }
+ public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
+ Annotation[] annotations = fieldDeclaration.annotations;
+ this.enclosingReference = fieldDeclaration.type;
+ this.primaryAnnotations = annotations;
+ return true;
+ }
+ public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
+ this.primaryAnnotations = methodDeclaration.annotations;
+ TypeReference returnType = methodDeclaration.returnType;
+ if (returnType != null) {
+ this.enclosingReference = returnType;
+ returnType.traverse(this, scope);
+ }
+ if (methodDeclaration.thrownExceptions != null) {
+ int thrownExceptionsLength = methodDeclaration.thrownExceptions.length;
+ for (int i = 0; i < thrownExceptionsLength; i++) {
+ TypeReference typeReference = methodDeclaration.thrownExceptions[i];
+ this.enclosingReference = typeReference;
+ this.primaryAnnotations = null;
+ typeReference.traverse(this, scope);
+ }
+ }
+ return false;
+ }
+ public boolean visit(Argument argument, ClassScope scope) {
+ Annotation[] annotations = argument.annotations;
+ this.enclosingReference = argument.type;
+ this.primaryAnnotations = annotations;
+ return true;
+ }
+ public boolean visit(Argument argument, BlockScope scope) {
+ Annotation[] annotations = argument.annotations;
+ this.enclosingReference = argument.type;
+ this.primaryAnnotations = annotations;
+ return true;
+ }
+ public boolean visit(MarkerAnnotation annotation, BlockScope scope) {
+ if (this.enclosingReference != null) {
+ storeLocations(annotation, Annotation.getLocations(this.enclosingReference, this.primaryAnnotations, annotation, null));
+ }
+ return false;
+ }
+ public boolean visit(SingleMemberAnnotation annotation, BlockScope scope) {
+ if (this.enclosingReference != null) {
+ storeLocations(annotation, Annotation.getLocations(this.enclosingReference, this.primaryAnnotations, annotation, null));
+ }
+ return false;
+ }
+ public boolean visit(NormalAnnotation annotation, BlockScope scope) {
+ if (this.enclosingReference != null) {
+ storeLocations(annotation, Annotation.getLocations(this.enclosingReference, this.primaryAnnotations, annotation, null));
+ }
+ return false;
+ }
+ public void storeLocations(Annotation annotation, int[] tab) {
+ String key = String.valueOf(annotation);
+ if (this.locations.get(key) != null) {
+ return;
+ }
+ if (tab == null) {
+ this.locations.put(key, null);
+ return;
+ }
+ StringBuffer buffer = new StringBuffer("{");
+ for (int i = 0, max = tab.length; i < max; i++) {
+ if (i > 0) {
+ buffer.append(',');
+ }
+ buffer.append(tab[i]);
+ }
+ buffer.append('}');
+ this.locations.put(key, String.valueOf(buffer));
+ }
+
+ public boolean visit(ArrayTypeReference arrayReference, BlockScope scope) {
+ if (this.enclosingReference == null) return false;
+ return true;
+ }
+ public boolean visit(ParameterizedSingleTypeReference typeReference, BlockScope scope) {
+ if (this.enclosingReference == null) return false;
+ return true;
+ }
+ public boolean visit(SingleTypeReference typeReference, BlockScope scope) {
+ if (this.enclosingReference == null) return false;
+ return true;
+ }
+ }
+public TypeAnnotationSyntaxTest(String testName){
+ super(testName, referenceCompiler, jsr308TestScratchArea);
+ if (referenceCompiler != null) {
+ File f = new File(jsr308TestScratchArea);
+ if (!f.exists()) {
+ f.mkdir();
+ }
+ if (f.exists()) {
+ try {
+ OutputStreamWriter w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "Marker.java")));
+ w.write("@interface Marker {}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "Normal.java")));
+ w.write("@interface Normal {\n\tint value() default 10;\n}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "SingleMember.java")));
+ w.write("@interface SingleMember {\n\tint value() default 10;\n}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "Positive.java")));
+ w.write("@interface Positive {}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "Negative.java")));
+ w.write("@interface Negative{}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "Readonly.java")));
+ w.write("@interface Readonly {}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "NonNull.java")));
+ w.write("@interface NonNull {}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "HashMap.java")));
+ w.write("class HashMap<X,Y> {\n class Iterator {}; \n}\n".toCharArray());
+ w.close();
+ CHECK_ALL |= CHECK_JAVAC_PARSER;
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+}
+
+static {
+// TESTS_NAMES = new String[] { "test0038", "test0039", "test0040a" };
+// TESTS_NUMBERS = new int[] { 133, 134, 135 };
+ if (!(new File(referenceCompiler).exists())) {
+ referenceCompiler = null;
+ jsr308TestScratchArea = null;
+ }
+}
+void traverse (File f) throws IOException {
+ if (f.isDirectory()) {
+ File [] files = f.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ traverse(files[i]);
+ }
+ } else {
+ if (f.getName().endsWith(".java")) {
+ System.out.println(f.getCanonicalPath());
+ char [] contents = new char[(int) f.length()];
+ FileInputStream fs = new FileInputStream(f);
+ InputStreamReader isr = new InputStreamReader(fs);
+ isr.read(contents);
+ checkParse(contents, null, f.getCanonicalPath(), null);
+ }
+ }
+}
+public void _test000() throws IOException {
+ traverse(new File("C:\\jsr308tests"));
+}
+
+public void test0001() throws IOException {
+ String source = "@Marker class A extends String {}\n;" +
+ "@Marker class B extends @Marker String {}\n" +
+ "@Marker class C extends @Marker @SingleMember(0) String {}\n" +
+ "@Marker class D extends @Marker @SingleMember(0) @Normal(Value = 0) String {}\n" +
+ "@Marker class E extends String {}\n;";
+
+ String expectedUnitToString =
+ "@Marker class A extends String {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class B extends @Marker String {\n" +
+ " B() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class C extends @Marker @SingleMember(0) String {\n" +
+ " C() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class D extends @Marker @SingleMember(0) @Normal(Value = 0) String {\n" +
+ " D() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class E extends String {\n" +
+ " E() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0001", expectedUnitToString);
+}
+public void test0002() throws IOException {
+ String source = "class A extends String {}\n;" +
+ "class B extends @Marker String {}\n" +
+ "class C extends @Marker @SingleMember(0) String {}\n" +
+ "class D extends @Marker @SingleMember(0) @Normal(Value = 0) String {}\n" +
+ "class E extends String {}\n;";
+
+ String expectedUnitToString =
+ "class A extends String {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class B extends @Marker String {\n" +
+ " B() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class C extends @Marker @SingleMember(0) String {\n" +
+ " C() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class D extends @Marker @SingleMember(0) @Normal(Value = 0) String {\n" +
+ " D() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class E extends String {\n" +
+ " E() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0002", expectedUnitToString);
+}
+public void test0003() throws IOException {
+ String source = "@Marker class A implements Comparable, " +
+ " @Marker Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A implements Comparable, @Marker Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0003", expectedUnitToString);
+}
+public void test0004() throws IOException {
+ String source = "@Marker class A implements Comparable, " +
+ " @Marker @SingleMember(0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A implements Comparable, @Marker @SingleMember(0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0004", expectedUnitToString);
+}
+public void test0005() throws IOException {
+ String source = "@Marker class A implements Comparable, " +
+ " @Marker @SingleMember(0) @Normal(Value=0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A implements Comparable, @Marker @SingleMember(0) @Normal(Value = 0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0005", expectedUnitToString);
+}
+public void test0006() throws IOException {
+ String source = "@Marker class A implements @Marker Comparable, " +
+ " @Marker @SingleMember(0) @Normal(Value=0) Serializable," +
+ " @Marker Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A implements @Marker Comparable, @Marker @SingleMember(0) @Normal(Value = 0) Serializable, @Marker Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0006", expectedUnitToString);
+}
+public void test007() throws IOException {
+ String source = "@Marker class A extends Object implements Comparable, " +
+ " @Marker @SingleMember(10) @Normal(Value=0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A extends Object implements Comparable, @Marker @SingleMember(10) @Normal(Value = 0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0007", expectedUnitToString);
+}
+public void test0008() throws IOException {
+ String source = "@Marker class A extends @Marker Object implements Comparable, " +
+ " @Marker @SingleMember(0) @Normal(Value=0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A extends @Marker Object implements Comparable, @Marker @SingleMember(0) @Normal(Value = 0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0008", expectedUnitToString);
+}
+public void test0009() throws IOException {
+ String source = "@Marker class A extends @Marker @SingleMember(0) Object implements Comparable, " +
+ " @Marker @SingleMember(0) @Normal(Value=0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A extends @Marker @SingleMember(0) Object implements Comparable, @Marker @SingleMember(0) @Normal(Value = 0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0009", expectedUnitToString);
+}
+public void test0010() throws IOException {
+ String source = "@Marker class A extends @Marker @SingleMember(0) @Normal(Value=0) Object implements Comparable, " +
+ " @Marker @SingleMember(0) @Normal(Value=0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A extends @Marker @SingleMember(0) @Normal(Value = 0) Object implements Comparable, @Marker @SingleMember(0) @Normal(Value = 0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0010", expectedUnitToString);
+}
+public void test0011() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker String[] @Marker[][] s[] @SingleMember(0)[][] @Normal(Value = 0)[][];\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker String[] @Marker [][][] @SingleMember(0) [][] @Normal(Value = 0) [][] s;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0011", expectedUnitToString);
+}
+public void test0012() throws IOException {
+ String source = "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[] f[];\n" +
+ " @English String[] @NonNull[] s[] @Nullable[][];\n" +
+ " float[] p[];\n" +
+ "public static void main(String args[]) {\n" +
+ " @Readonly String @Nullable[] @NonNull[] s;\n" +
+ " s = new @Readonly String @NonNull[5] @Nullable[];\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[][] f;\n" +
+ " @English String[] @NonNull [][] @Nullable [][] s;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " @Readonly String @Nullable [] @NonNull [] s;\n" +
+ " s = new @Readonly String @NonNull [5] @Nullable [];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0012", expectedUnitToString);
+}
+public void test0013() throws IOException {
+ String source = "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[] f[];\n" +
+ " @English String[] @NonNull[] s[] @Nullable[][];\n" +
+ " float[] p[];\n" +
+ "public static void main(String args[]) {\n" +
+ " @Readonly String s;\n" +
+ " s = new @Readonly String @NonNull[] @Nullable[] { {\"Hello\"}, {\"World\"}} [0][0];\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[][] f;\n" +
+ " @English String[] @NonNull [][] @Nullable [][] s;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " @Readonly String s;\n" +
+ " s = new @Readonly String @NonNull [] @Nullable []{{\"Hello\"}, {\"World\"}}[0][0];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0013", expectedUnitToString);
+}
+public void test0014() throws IOException {
+ String source = "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[] f[];\n" +
+ " @English String[] @NonNull[] s[] @Nullable[][];\n" +
+ " float[] p[];\n" +
+ "public static int main(String args[])[] @Marker[][] @Marker @SingleMember(0) @Normal(Value=0)[][] {\n" +
+ " @Readonly String @Nullable[] @NonNull[] s;\n" +
+ " s = new @Readonly String @NonNull[5] @Nullable[];\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[][] f;\n" +
+ " @English String[] @NonNull [][] @Nullable [][] s;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static int[] @Marker [][] @Marker @SingleMember(0) @Normal(Value = 0) [][] main(String[] args) {\n" +
+ " @Readonly String @Nullable [] @NonNull [] s;\n" +
+ " s = new @Readonly String @NonNull [5] @Nullable [];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0014", expectedUnitToString);
+
+}
+public void test0015() throws IOException {
+ String source = "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[] f[];\n" +
+ " @English String[] @NonNull[] s[] @Nullable[][];\n" +
+ " float[] p[];\n" +
+ "public static int main(String args[])[] @Marker[][] @Marker @SingleMember(0) @Normal(Value=0)[][] {\n" +
+ " @Readonly String @Nullable[] @NonNull[] s;\n" +
+ " s = new @Readonly String @NonNull[5] @Nullable[];\n" +
+ "}\n" +
+ "@Marker public A () {}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[][] f;\n" +
+ " @English String[] @NonNull [][] @Nullable [][] s;\n" +
+ " float[][] p;\n" +
+ " public static int[] @Marker [][] @Marker @SingleMember(0) @Normal(Value = 0) [][] main(String[] args) {\n" +
+ " @Readonly String @Nullable [] @NonNull [] s;\n" +
+ " s = new @Readonly String @NonNull [5] @Nullable [];\n" +
+ " }\n" +
+ " public @Marker A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0015", expectedUnitToString);
+}
+// parameters
+public void test0016() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(int[] @SingleMember(10)[][] args[] @Normal(Value = 10)[][])[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(int[] @SingleMember(10) [][][] @Normal(Value = 10) [][] args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0016", expectedUnitToString);
+}
+public void test0017() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(String[] @SingleMember(10)[][] args[] @Normal(Value = 10)[][])[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(String[] @SingleMember(10) [][][] @Normal(Value = 10) [][] args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0017", expectedUnitToString);
+}
+public void test0018() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(HashMap<String, Object>[] @SingleMember(10)[][] args[] @Normal(Value = 10)[][])[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(HashMap<String, Object>[] @SingleMember(10) [][][] @Normal(Value = 10) [][] args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0018", expectedUnitToString);
+}
+public void test0019() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker [][] main(HashMap<String, Object>.Iterator[] @SingleMember(10) [][] args[] @Normal(Value = 10) [][])[] @Marker [][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(HashMap<String, Object>.Iterator[] @SingleMember(10) [][][] @Normal(Value = 10) [][] args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0019", expectedUnitToString);
+}
+// varargs annotation
+public void test0020() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(int[] @SingleMember(10)[][] @Marker ... args )[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(int[] @SingleMember(10) [][] @Marker ... args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0020", expectedUnitToString);
+}
+public void test0021() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(String[] @SingleMember(10)[][] @Marker ... args )[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(String[] @SingleMember(10) [][] @Marker ... args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0021", expectedUnitToString);
+}
+public void test0022() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(HashMap<Integer,String>[] @SingleMember(10)[][] @Marker ... args )[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(HashMap<Integer, String>[] @SingleMember(10) [][] @Marker ... args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0022", expectedUnitToString);
+}
+public void test0023() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(HashMap<Integer,String>.Iterator[] @SingleMember(10)[][] @Marker ... args )[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(HashMap<Integer, String>.Iterator[] @SingleMember(10) [][] @Marker ... args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0023", expectedUnitToString);
+}
+// local variables
+public void test0024() throws IOException {
+ String source = "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ "public static void main(String args[]) {\n" +
+ " int[] f[];\n" +
+ " @English String[] @NonNull[] s[] @Nullable[][];\n" +
+ " float[] p[];\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " int[][] f;\n" +
+ " @English String[] @NonNull [][] @Nullable [][] s;\n" +
+ " float[][] p;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0024", expectedUnitToString);
+}
+// type parameter
+public void test0025() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> void foo() {\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer>void foo() {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0025", expectedUnitToString);
+}
+// Type
+public void test0026() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker int foo() {\n" +
+ " return 0;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> int bar() {\n" +
+ " return 0;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0026 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker int foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0026", null);
+}
+// Type
+public void test0027() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker String foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> String bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0027 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker String foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0027", null);
+}
+//Type
+public void test0028() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object> foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> HashMap<String, @NonNull Object> bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0028 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object> foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0028", null);
+}
+// Type
+public void test0029() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> HashMap<String, @NonNull Object>.Iterator bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0029 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0029", null);
+}
+//Type
+public void test0030() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator[] @NonEmpty[][] foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> HashMap<String, @NonNull Object>.Iterator[] @NonEmpty[][] bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0030 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator[] @NonEmpty[][] foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0030", null);
+}
+//Type
+public void test0031() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker int[] @NonEmpty[][] foo() {\n" +
+ " return 0;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> int[] @NonEmpty[][] bar() {\n" +
+ " return 0;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0031 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker int[] @NonEmpty[][] foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0031", null);
+}
+// Type
+public void test0032() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker String[]@NonEmpty[][] foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> String[]@NonEmpty[][] bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0032 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker String[]@NonEmpty[][] foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0032", null);
+}
+//Type
+public void test0033() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>[] @NonEmpty[][] foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> HashMap<String, @NonNull Object>[]@NonEmpty[][] bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0033 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>[] @NonEmpty[][] foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0033", null);
+}
+// Type0 field declaration.
+public void test0034() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker int k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker int k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0034", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0035() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker String k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker String k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0035", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0036() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer> k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer> k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0036", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0037() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0037", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0038() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker int[] @NonEmpty[][] k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker int[] @NonEmpty [][] k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0038", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0039() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker String[] @NonEmpty[][]k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker String[] @NonEmpty [][] k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0039", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0040() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>[] @NonEmpty[][] k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>[] @NonEmpty [][] k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0040", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0041() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty[][] k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty [][] k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0041", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0042() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker int foo() { return 0; }\n" +
+ " public int bar() { return 0; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int foo() {\n" +
+ " return 0;\n" +
+ " }\n" +
+ " public int bar() {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0042", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0043() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker String foo() { return null; }\n" +
+ " public String bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker String foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public String bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0043", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0044() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer> foo() { return null; }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer> bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer> foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer> bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0044", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0045() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator foo() { return null; }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer>.Iterator bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer>.Iterator bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0045", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0046() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker int[] foo() @NonEmpty[][] { return 0; }\n" +
+ " public int[] @NonEmpty[][] bar() { return 0; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @NonEmpty [][] foo() {\n" +
+ " return 0;\n" +
+ " }\n" +
+ " public int[] @NonEmpty [][] bar() {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0046", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0047() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker String[] foo() @NonEmpty[][] { return null; }\n" +
+ " public String[] @NonEmpty[][] bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker String[] @NonEmpty [][] foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public String[] @NonEmpty [][] bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0047", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0048() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>[] foo() @NonEmpty[][] { return null; }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer> [] @NonEmpty[][] bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>[] @NonEmpty [][] foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer>[] @NonEmpty [][] bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0048", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0049() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] foo() @NonEmpty[][] { return null; }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty[][] bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty [][] foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty [][] bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0049", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0050() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker int p;\n" +
+ " int q;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker int p;\n" +
+ " int q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0050", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0051() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker String p;\n" +
+ " String q;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker String p;\n" +
+ " String q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0051", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0052() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer> p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer> q;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer> p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer> q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0052", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0053() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer>.Iterator q;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer>.Iterator q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0053", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0054() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker int[] @NonNull[] p @NonEmpty[][];\n" +
+ " int[] @NonNull[] q @NonEmpty[][];\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker int[] @NonNull [] @NonEmpty [][] p;\n" +
+ " int[] @NonNull [] @NonEmpty [][] q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0054", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0055() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker String[] @NonNull[] p @NonEmpty[][];\n" +
+ " String[] @NonNull[] q @NonEmpty[][];\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker String[] @NonNull [] @NonEmpty [][] p;\n" +
+ " String[] @NonNull [] @NonEmpty [][] q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0055", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0056() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>[] @NonNull[] p @NonEmpty[][];\n" +
+ " HashMap<@Positive Integer, @Negative Integer>[] @NonNull[] q @NonEmpty[][];\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>[] @NonNull [] @NonEmpty [][] p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer>[] @NonNull [] @NonEmpty [][] q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0056", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0057() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonNull[] p @NonEmpty[][];\n" +
+ " HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonNull[] @NonEmpty[][] q;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonNull [] @NonEmpty [][] p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonNull [] @NonEmpty [][] q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0057", expectedUnitToString);
+}
+//Type0 foreach
+public void test0058() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " String @NonNull[] @Marker[] s @Readonly[];\n" +
+ " for (@Readonly String @NonNull[] si @Marker[] : s) {}\n" +
+ " for (String @NonNull[] sii @Marker[] : s) {}\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " String @NonNull [] @Marker [] @Readonly [] s;\n" +
+ " for (@Readonly String @NonNull [] @Marker [] si : s) \n" +
+ " {\n" +
+ " }\n" +
+ " for (String @NonNull [] @Marker [] sii : s) \n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0058", expectedUnitToString);
+}
+//Type0 foreach
+public void test0059() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " int @NonNull[] @Marker[] s @Readonly[];\n" +
+ " for (@Readonly int @NonNull[] si @Marker[] : s) {}\n" +
+ " for (int @NonNull[] sii @Marker[] : s) {}\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " int @NonNull [] @Marker [] @Readonly [] s;\n" +
+ " for (@Readonly int @NonNull [] @Marker [] si : s) \n" +
+ " {\n" +
+ " }\n" +
+ " for (int @NonNull [] @Marker [] sii : s) \n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0059", expectedUnitToString);
+}
+// cast expression
+public void test0060() throws IOException {
+ String source = "public class Clazz {\n" +
+ "public static void main(String[] args) {\n" +
+ "int x;\n" +
+ "x = (Integer)\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @Normal(Value=0)[][] )\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @SingleMember(0)[][] )\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @Marker[][] )\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>[] @Normal(Value=0)[][] )\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>[] @SingleMember(0)[][] )\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>[] @Marker[][] )\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly String[] @Normal(Value=0)[][] )\n" +
+ "(@Readonly String[] @SingleMember(0)[][] )\n" +
+ "(@Readonly String[] @Marker[][] )\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly int[] @Normal(Value=0)[][] )\n" +
+ "(@Readonly int[] @SingleMember(0)[][] )\n" +
+ "(@Readonly int[] @Marker[][] )\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator)\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>)\n" +
+ "(@Readonly Object)\n" +
+ "(@ReadOnly String)\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly int) 10;\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class Clazz {\n" +
+ " public Clazz() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " int x;\n" +
+ " x = (Integer) (@Readonly Object) ( @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @Normal(Value = 0) [][]) ( @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @SingleMember(0) [][]) ( @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @Marker [][]) (@Readonly Object) (@Readonly HashMap<@Positive Integer, @Negative Integer>[] @Normal(Value = 0) [][]) (@Readonly HashMap<@Positive Integer, @Negative Integer>[] @SingleMember(0) [][]) (@Readonly HashMap<@Positive Integer, @Negative Integer>[] @Marker [][]) (@Readonly Object) (@Readonly String[] @Normal(Value = 0) [][]) (@Readonly String[] @SingleMember(0) [][]) (@Readonly String[] @Marker [][]) (@Readonly Object) (@Readonly int[] @Normal(Value = 0) [][]) (@Readonly int[] @SingleMember(0) [][]) (@Readonly int[] @Marker [][]) (@Readonly Object) ( @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator) (@Readonly Object) (@Readonly HashMap<@Positive Integer, @Negative Integer>) (@Readonly Object) (@ReadOnly String) (@Readonly Object) (@Readonly int) 10;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0060", expectedUnitToString);
+}
+//cast expression
+public void test0061() throws IOException {
+ String source = "public class Clazz {\n" +
+ "public static void main(String[] args) {\n" +
+ "int x;\n" +
+ "x = (Integer)\n" +
+ "(Object)\n" +
+ "(@Readonly HashMap<Integer, @Negative Integer>.Iterator[] @Normal(Value=0)[][] )\n" +
+ "(HashMap<@Positive Integer, Integer>.Iterator[] @SingleMember(0)[][] )\n" +
+ "(@Readonly HashMap<Integer, @Negative Integer>.Iterator[] @Marker[][] )\n" +
+ "(Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, Integer>[] @Normal(Value=0)[][] )\n" +
+ "(HashMap<Integer, @Negative Integer>[] @SingleMember(0)[][] )\n" +
+ "(@Readonly HashMap<@Positive Integer, Integer>[] @Marker[][] )\n" +
+ "(Object)\n" +
+ "(@Readonly String[] @Normal(Value=0)[][] )\n" +
+ "(String[] @SingleMember(0)[][] )\n" +
+ "(@Readonly String[] @Marker[][] )\n" +
+ "(Object)\n" +
+ "(@Readonly int[] @Normal(Value=0)[][] )\n" +
+ "(int[] @SingleMember(0)[][] )\n" +
+ "(@Readonly int[] @Marker[][] )\n" +
+ "(Object)\n" +
+ "(@Readonly HashMap<Integer, @Negative Integer>.Iterator)\n" +
+ "(Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, Integer>)\n" +
+ "(Object)\n" +
+ "(@ReadOnly String)\n" +
+ "(Object)\n" +
+ "(@Readonly int) 10;\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class Clazz {\n" +
+ " public Clazz() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " int x;\n" +
+ " x = (Integer) (Object) ( @Readonly HashMap<Integer, @Negative Integer>.Iterator[] @Normal(Value = 0) [][]) (HashMap<@Positive Integer, Integer>.Iterator[] @SingleMember(0) [][]) ( @Readonly HashMap<Integer, @Negative Integer>.Iterator[] @Marker [][]) (Object) (@Readonly HashMap<@Positive Integer, Integer>[] @Normal(Value = 0) [][]) (HashMap<Integer, @Negative Integer>[] @SingleMember(0) [][]) (@Readonly HashMap<@Positive Integer, Integer>[] @Marker [][]) (Object) (@Readonly String[] @Normal(Value = 0) [][]) (String[] @SingleMember(0) [][]) (@Readonly String[] @Marker [][]) (Object) (@Readonly int[] @Normal(Value = 0) [][]) (int[] @SingleMember(0) [][]) (@Readonly int[] @Marker [][]) (Object) ( @Readonly HashMap<Integer, @Negative Integer>.Iterator) (Object) (@Readonly HashMap<@Positive Integer, Integer>) (Object) (@ReadOnly String) (Object) (@Readonly int) 10;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0061", expectedUnitToString);
+}
+// instanceof checks
+public void test0062() throws IOException {
+ String source = "public class Clazz {\n" +
+ "public static void main(Object o) {\n" +
+ "if (o instanceof @Readonly String) {\n" +
+ "} else if (o instanceof @Readonly int[] @NonEmpty[][] ) {\n" +
+ "} else if (o instanceof @Readonly String[] @NonEmpty[][] ) {\n" +
+ "} else if (o instanceof @Readonly HashMap<?,?>[] @NonEmpty[][] ) {\n" +
+ "} else if (o instanceof @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty[][] ) {\n" +
+ "} else if (o instanceof @Readonly HashMap<?,?>) {\n" +
+ "} else if (o instanceof @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator) {\n" +
+ "}\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class Clazz {\n" +
+ " public Clazz() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(Object o) {\n" +
+ " if ((o instanceof @Readonly String))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly int[] @NonEmpty [][]))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly String[] @NonEmpty [][]))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly HashMap<?, ?>[] @NonEmpty [][]))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty [][]))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly HashMap<?, ?>))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator))\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0062", expectedUnitToString);
+}
+// assorted unclassified
+public void test0063() throws IOException {
+ String source = "import java.util.HashMap;\n" +
+ "import java.util.Map; \n" +
+ "\n" +
+ "public class Clazz <@A M extends @B String, @C N extends @D Comparable> extends\n" +
+ " @E Object implements @F Comparable <@G Object> {\n" +
+ " \n" +
+ " Clazz(char[] ...args) { \n" +
+ " }\n" +
+ " \n" +
+ " int @I[] f @J[], g, h[], i@K[];\n" +
+ " int @L[][]@M[] f2; \n" +
+ " \n" +
+ " Clazz (int @N[] @O... a) {}\n" +
+ " int @R[]@S[] aa() {}\n" +
+ " \n" +
+ " int @T[]@U[]@V[] a () @W[]@X[]@Y[] { return null; }\n" +
+ " \n" +
+ " public void main(String @A[] @B ... args) throws @D Exception {\n" +
+ " \n" +
+ " HashMap<@E String, @F String> b1;\n" +
+ " \n" +
+ " int b; b = (@G int) 10;\n" +
+ " \n" +
+ " char @H[]@I[] ch; ch = (@K char @L[]@M[])(@N char @O[]@P[]) null;\n" +
+ " \n" +
+ " int[] i; i = new @Q int @R[10];\n" +
+ " \n" +
+ " \n" +
+ " Integer w; w = new X<@S String, @T Integer>().get(new @U Integer(12));\n" +
+ " throw new @V Exception(\"test\");\n" +
+ " boolean c; c = null instanceof @W String;\n" +
+ " } \n" +
+ " public <@X X, @Y Y> void foo(X x, Y @Z... y) { \n" +
+ " \n" +
+ "}\n" +
+ " \n" +
+ " void foo(Map<? super @A Object, ? extends @B String> m){}\n" +
+ " public int compareTo(Object arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "\n" +
+ "}\n" +
+ "class X<@C K, @D T extends @E Object & @F Comparable<? super @G T>> {\n" +
+ " \n" +
+ " public Integer get(Integer integer) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+
+
+ String expectedUnitToString = "import java.util.HashMap;\n" +
+ "import java.util.Map;\n" +
+ "public class Clazz<@A M extends @B String, @C N extends @D Comparable> extends @E Object implements @F Comparable<@G Object> {\n" +
+ " int @I [] @J [] f;\n" +
+ " int @I [] g;\n" +
+ " int @I [][] h;\n" +
+ " int @I [] @K [] i;\n" +
+ " int @L [][] @M [] f2;\n" +
+ " Clazz(char[]... args) {\n" +
+ " super();\n" +
+ " }\n" +
+ " Clazz(int @N [] @O ... a) {\n" +
+ " super();\n" +
+ " }\n" +
+ " int @R [] @S [] aa() {\n" +
+ " }\n" +
+ " int @T [] @U [] @V [] @W [] @X [] @Y [] a() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public void main(String @A [] @B ... args) throws @D Exception {\n" +
+ " HashMap<@E String, @F String> b1;\n" +
+ " int b;\n" +
+ " b = (@G int) 10;\n" +
+ " char @H [] @I [] ch;\n" +
+ " ch = (@K char @L [] @M []) (@N char @O [] @P []) null;\n" +
+ " int[] i;\n" +
+ " i = new @Q int @R [10];\n" +
+ " Integer w;\n" +
+ " w = new X<@S String, @T Integer>().get(new @U Integer(12));\n" +
+ " throw new @V Exception(\"test\");\n" +
+ " boolean c;\n" +
+ " c = (null instanceof @W String);\n" +
+ " }\n" +
+ " public <@X X, @Y Y>void foo(X x, Y @Z ... y) {\n" +
+ " }\n" +
+ " void foo(Map<? super @A Object, ? extends @B String> m) {\n" +
+ " }\n" +
+ " public int compareTo(Object arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n" +
+ "class X<@C K, @D T extends @E Object & @F Comparable<? super @G T>> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public Integer get(Integer integer) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ // indexing parser avoids creating lots of nodes, so parse tree comes out incorrectly.
+ // this is not bug, but intended behavior - see IndexingParser.newSingleNameReference(char[], long)
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0063", expectedUnitToString);
+}
+//assorted unclassified
+public void test0064() throws IOException {
+ String source = "class X<T extends @E Object & @F Comparable<? super T>> {}\n";
+ String expectedUnitToString = "class X<T extends @E Object & @F Comparable<? super T>> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ // indexing parser avoids creating lots of nodes, so parse tree comes out incorrectly.
+ // this is not bug, but intended behavior - see IndexingParser.newSingleNameReference(char[], long)
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test064", expectedUnitToString);
+}
+//type class literal expression
+public void test0066() throws IOException {
+ String source = "public class X {\n" +
+ " <T extends Y<@A String @C[][]@B[]> & Cloneable> void foo(T t) {}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " <T extends Y<@A String @C [][] @B []> & Cloneable>void foo(T t) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0066", expectedUnitToString);
+}
+//check locations
+public void test0067() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @H String @E[] @F[] @G[] field;\n" +
+ " @A Map<@B String, @C List<@D Object>> field2;\n" +
+ " @A Map<@B String, @H String @E[] @F[] @G[]> field3;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @H String @E [] @F [] @G [] field;\n" +
+ " @A Map<@B String, @C List<@D Object>> field2;\n" +
+ " @A Map<@B String, @H String @E [] @F [] @G []> field3;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0067", expectedUnitToString);
+}
+//check locations
+public void test0068() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @H String @E[] @F[] @G[] field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @H String @E [] @F [] @G [] field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0068", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 4, locations.size());
+ assertEquals("Wrong location", null, locations.get("@E"));
+ assertEquals("Wrong location", "{0}", locations.get("@F"));
+ assertEquals("Wrong location", "{1}", locations.get("@G"));
+ assertEquals("Wrong location", "{2}", locations.get("@H"));
+}
+//check locations
+public void test0069() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A Map<@B String, @H String> field3;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A Map<@B String, @H String> field3;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0069", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 3, locations.size());
+ assertEquals("Wrong location", null, locations.get("@A"));
+ assertEquals("Wrong location", "{0}", locations.get("@B"));
+ assertEquals("Wrong location", "{1}", locations.get("@H"));
+}
+//check locations
+public void test0070() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A Map<@B String, @H String @E[] @F[] @G[]> field3;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A Map<@B String, @H String @E [] @F [] @G []> field3;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0070", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 6, locations.size());
+ assertEquals("Wrong location", null, locations.get("@A"));
+ assertEquals("Wrong location", "{0}", locations.get("@B"));
+ assertEquals("Wrong location", "{1}", locations.get("@E"));
+ assertEquals("Wrong location", "{1,0}", locations.get("@F"));
+ assertEquals("Wrong location", "{1,1}", locations.get("@G"));
+ assertEquals("Wrong location", "{1,2}", locations.get("@H"));
+}
+//check locations
+public void test0071() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A Map<@B String, @C List<@H String @E[][] @G[]>> field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A Map<@B String, @C List<@H String @E [][] @G []>> field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0071", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 6, locations.size());
+ assertEquals("Wrong location", null, locations.get("@A"));
+ assertEquals("Wrong location", "{0}", locations.get("@B"));
+ assertEquals("Wrong location", "{1}", locations.get("@C"));
+ assertEquals("Wrong location", "{1,0,2}", locations.get("@H"));
+ assertEquals("Wrong location", "{1,0}", locations.get("@E"));
+ assertEquals("Wrong location", "{1,0,1}", locations.get("@G"));
+}
+//check locations
+public void test0072() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A Map<@B String, @C List<@H String @E[][] @G[]>>[] @I[] @J[] field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A Map<@B String, @C List<@H String @E [][] @G []>>[] @I [] @J [] field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0072", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 8, locations.size());
+ assertEquals("Wrong location", "{0}", locations.get("@I"));
+ assertEquals("Wrong location", "{1}", locations.get("@J"));
+ assertEquals("Wrong location", "{2}", locations.get("@A"));
+ assertEquals("Wrong location", "{2,0}", locations.get("@B"));
+ assertEquals("Wrong location", "{2,1}", locations.get("@C"));
+ assertEquals("Wrong location", "{2,1,0,2}", locations.get("@H"));
+ assertEquals("Wrong location", "{2,1,0}", locations.get("@E"));
+ assertEquals("Wrong location", "{2,1,0,1}", locations.get("@G"));
+}
+//check locations
+public void test0073() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A Map<@B String, @C List<@H String @E[][] @G[]>> @I[][] @J[] field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A Map<@B String, @C List<@H String @E [][] @G []>> @I [][] @J [] field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0073", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 8, locations.size());
+ assertEquals("Wrong location", null, locations.get("@I"));
+ assertEquals("Wrong location", "{1}", locations.get("@J"));
+ assertEquals("Wrong location", "{2}", locations.get("@A"));
+ assertEquals("Wrong location", "{2,0}", locations.get("@B"));
+ assertEquals("Wrong location", "{2,1}", locations.get("@C"));
+ assertEquals("Wrong location", "{2,1,0,2}", locations.get("@H"));
+ assertEquals("Wrong location", "{2,1,0}", locations.get("@E"));
+ assertEquals("Wrong location", "{2,1,0,1}", locations.get("@G"));
+}
+//check locations
+public void test0074() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A Map<@C List<@H String @E[][] @G[]>, String @B[] @D[]> @I[] @F[] @J[] field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A Map<@C List<@H String @E [][] @G []>, String @B [] @D []> @I [] @F [] @J [] field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0074", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 10, locations.size());
+ assertEquals("Wrong location", null, locations.get("@I"));
+ assertEquals("Wrong location", "{0}", locations.get("@F"));
+ assertEquals("Wrong location", "{1}", locations.get("@J"));
+ assertEquals("Wrong location", "{2}", locations.get("@A"));
+ assertEquals("Wrong location", "{2,0}", locations.get("@C"));
+ assertEquals("Wrong location", "{2,0,0}", locations.get("@E"));
+ assertEquals("Wrong location", "{2,0,0,1}", locations.get("@G"));
+ assertEquals("Wrong location", "{2,0,0,2}", locations.get("@H"));
+ assertEquals("Wrong location", "{2,1,0}", locations.get("@D"));
+ assertEquals("Wrong location", "{2,1}", locations.get("@B"));
+}
+//check locations
+public void test0075() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A Map<@C List<@H String @E[][] @G[]>, @B List<String [] @D[]>> [] @I[] @F[] @J[] field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A Map<@C List<@H String @E [][] @G []>, @B List<String[] @D []>>[] @I [] @F [] @J [] field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0075", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 10, locations.size());
+ assertEquals("Wrong location", "{0}", locations.get("@I"));
+ assertEquals("Wrong location", "{1}", locations.get("@F"));
+ assertEquals("Wrong location", "{2}", locations.get("@J"));
+ assertEquals("Wrong location", "{3}", locations.get("@A"));
+ assertEquals("Wrong location", "{3,0}", locations.get("@C"));
+ assertEquals("Wrong location", "{3,0,0}", locations.get("@E"));
+ assertEquals("Wrong location", "{3,0,0,1}", locations.get("@G"));
+ assertEquals("Wrong location", "{3,0,0,2}", locations.get("@H"));
+ assertEquals("Wrong location", "{3,1}", locations.get("@B"));
+ assertEquals("Wrong location", "{3,1,0,0}", locations.get("@D"));
+}
+//check locations
+public void test0076() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A Map<@B String, @C List<@D Object>> field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A Map<@B String, @C List<@D Object>> field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0076", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 4, locations.size());
+ assertEquals("Wrong location", null, locations.get("@A"));
+ assertEquals("Wrong location", "{0}", locations.get("@B"));
+ assertEquals("Wrong location", "{1}", locations.get("@C"));
+ assertEquals("Wrong location", "{1,0}", locations.get("@D"));
+}
+//check locations
+public void test0077() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @H String @E[] @F[] @G[] field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @H String @E [] @F [] @G [] field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0077", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 4, locations.size());
+ assertEquals("Wrong location", null, locations.get("@E"));
+ assertEquals("Wrong location", "{0}", locations.get("@F"));
+ assertEquals("Wrong location", "{1}", locations.get("@G"));
+ assertEquals("Wrong location", "{2}", locations.get("@H"));
+}
+//check locations
+public void test0078() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A Map<@B Comparable<@C Object @D[] @E[] @F[]>, @G List<@H Document>> field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A Map<@B Comparable<@C Object @D [] @E [] @F []>, @G List<@H Document>> field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0078", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 8, locations.size());
+ assertEquals("Wrong location", null, locations.get("@A"));
+ assertEquals("Wrong location", "{0}", locations.get("@B"));
+ assertEquals("Wrong location", "{0,0,2}", locations.get("@C"));
+ assertEquals("Wrong location", "{0,0}", locations.get("@D"));
+ assertEquals("Wrong location", "{0,0,0}", locations.get("@E"));
+ assertEquals("Wrong location", "{0,0,1}", locations.get("@F"));
+ assertEquals("Wrong location", "{1}", locations.get("@G"));
+ assertEquals("Wrong location", "{1,0}", locations.get("@H"));
+}
+//check locations
+public void test0079() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A java.util.Map<@B Comparable<@C Object @D[] @E[] @F[]>, @G List<@H Document>> field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A java.util.Map<@B Comparable<@C Object @D [] @E [] @F []>, @G List<@H Document>> field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0079", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 8, locations.size());
+ assertEquals("Wrong location", null, locations.get("@A"));
+ assertEquals("Wrong location", "{0}", locations.get("@B"));
+ assertEquals("Wrong location", "{0,0,2}", locations.get("@C"));
+ assertEquals("Wrong location", "{0,0}", locations.get("@D"));
+ assertEquals("Wrong location", "{0,0,0}", locations.get("@E"));
+ assertEquals("Wrong location", "{0,0,1}", locations.get("@F"));
+ assertEquals("Wrong location", "{1}", locations.get("@G"));
+ assertEquals("Wrong location", "{1,0}", locations.get("@H"));
+}
+//check locations
+public void test0080() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @B Map<? extends Z, ? extends @A Z> field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @B Map<? extends Z, ? extends @A Z> field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0080", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 2, locations.size());
+ assertEquals("Wrong location", null, locations.get("@B"));
+ assertEquals("Wrong location", "{1}", locations.get("@A"));
+}
+//check locations
+public void test0081() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @H java.lang.String @E[] @F[] @G[] field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @H java.lang.String @E [] @F [] @G [] field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0081", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 4, locations.size());
+ assertEquals("Wrong location", null, locations.get("@E"));
+ assertEquals("Wrong location", "{0}", locations.get("@F"));
+ assertEquals("Wrong location", "{1}", locations.get("@G"));
+ assertEquals("Wrong location", "{2}", locations.get("@H"));
+}
+//check locations
+public void test0082() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A Map<@B java.lang.String, @H java.lang.String @E[] @F[] @G[]> field3;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A Map<@B java.lang.String, @H java.lang.String @E [] @F [] @G []> field3;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0082", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 6, locations.size());
+ assertEquals("Wrong location", null, locations.get("@A"));
+ assertEquals("Wrong location", "{0}", locations.get("@B"));
+ assertEquals("Wrong location", "{1}", locations.get("@E"));
+ assertEquals("Wrong location", "{1,0}", locations.get("@F"));
+ assertEquals("Wrong location", "{1,1}", locations.get("@G"));
+ assertEquals("Wrong location", "{1,2}", locations.get("@H"));
+}
+public void test0083() throws IOException {
+ String source =
+ "@Marker class A {}\n;" +
+ "@Marker class B extends @Marker A {}\n" +
+ "@Marker class C extends @Marker @SingleMember(0) A {}\n" +
+ "@Marker class D extends @Marker @SingleMember(0) @Normal(value = 0) A {}\n" +
+ "@Marker class E extends B {}\n;";
+
+ String expectedUnitToString =
+ "@Marker class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class B extends @Marker A {\n" +
+ " B() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class C extends @Marker @SingleMember(0) A {\n" +
+ " C() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class D extends @Marker @SingleMember(0) @Normal(value = 0) A {\n" +
+ " D() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class E extends B {\n" +
+ " E() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0083", expectedUnitToString);
+}
+
+// To test Parser.consumeAdditionalBound() with Type annotations
+public void test0084() throws IOException {
+ String source =
+ "@Marker interface I<@Negative T> {}\n" +
+ "@SingleMember(0) interface J<@Positive T> {}\n" +
+ "@Marker class A implements I<@SingleMember(0) A>, J<@Marker A> {}\n" +
+ "@Normal(value = 1) class X<E extends @Positive A & @Marker I<A> & @Marker @SingleMember(1) J<@Readonly A>> {\n" +
+ "}";
+ String expectedUnitToString =
+ "@Marker interface I<@Negative T> {\n" +
+ "}\n" +
+ "@SingleMember(0) interface J<@Positive T> {\n" +
+ "}\n" +
+ "@Marker class A implements I<@SingleMember(0) A>, J<@Marker A> {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Normal(value = 1) class X<E extends @Positive A & @Marker I<A> & @Marker @SingleMember(1) J<@Readonly A>> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0084", expectedUnitToString );
+}
+
+// To test Parser.consumeAdditionalBound() with Type annotations
+public void test0085() throws IOException {
+ String source =
+ "import java.io.Serializable;\n" +
+ "\n" +
+ "@SingleMember(10) class X<T extends @Marker Serializable & @Normal(value = 10) Runnable, V extends @Marker T> {\n" +
+ " @Negative T t;\n" +
+ " @Marker X(@Readonly T t) {\n" +
+ " this.t = t;\n" +
+ " }\n" +
+ " void foo(@Marker X this) {\n" +
+ " (this == null ? t : t).run();\n" +
+ " ((@Marker V) t).run();\n" +
+ " }\n" +
+ " public static void main(@Readonly String @Marker [] args) {\n" +
+ " new @Marker X<@Marker A, @Negative A>(new @Marker A()).foo();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class A implements @Marker Serializable, @SingleMember(1) Runnable {\n" +
+ " public void run() {\n" +
+ " System.out.print(\"AA\");\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "import java.io.Serializable;\n" +
+ "@SingleMember(10) class X<T extends @Marker Serializable & @Normal(value = 10) Runnable, V extends @Marker T> {\n" +
+ " @Negative T t;\n" +
+ " @Marker X(@Readonly T t) {\n" +
+ " super();\n" +
+ " this.t = t;\n" +
+ " }\n" +
+ " void foo(@Marker X this) {\n" +
+ " ((this == null) ? t : t).run();\n" +
+ " ((@Marker V) t).run();\n" +
+ " }\n" +
+ " public static void main(@Readonly String @Marker [] args) {\n" +
+ " new @Marker X<@Marker A, @Negative A>(new @Marker A()).foo();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class A implements @Marker Serializable, @SingleMember(1) Runnable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void run() {\n" +
+ " System.out.print(\"AA\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0085", expectedUnitToString );
+}
+
+// To test Parser.classInstanceCreation() with type annotations
+public void test0086() throws IOException {
+ String source =
+ "class X {\n" +
+ " @Marker X() {\n" +
+ " System.out.print(\"new X created\");\n" +
+ " }\n" +
+ " void f() throws @Marker InstantiationException {\n" +
+ " X testX;\n" +
+ " testX = new @Readonly @Negative X();\n" +
+ " Double d;\n" +
+ " d = new @Marker @Positive Double(1.1);\n" +
+ " throw new @Positive @Normal(value = 10) InstantiationException(\"test\");\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " @Marker X() {\n" +
+ " super();\n" +
+ " System.out.print(\"new X created\");\n" +
+ " }\n" +
+ " void f() throws @Marker InstantiationException {\n" +
+ " X testX;\n" +
+ " testX = new @Readonly @Negative X();\n" +
+ " Double d;\n" +
+ " d = new @Marker @Positive Double(1.1);\n" +
+ " throw new @Positive @Normal(value = 10) InstantiationException(\"test\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0086", expectedUnitToString );
+}
+
+// To test Parser.classInstanceCreation() with type annotations
+public void test0087() throws IOException {
+ String source =
+ "class X {\n" +
+ " @Marker X() {\n" +
+ " System.out.print(\"new X created\");\n" +
+ " }\n" +
+ " @Marker class Inner {\n" +
+ " @Normal(value = 10) Inner(){\n" +
+ " System.out.print(\"X.Inner created\");\n" +
+ " }\n" +
+ " }\n" +
+ " public String getString(){\n" +
+ " return \"hello\";\n" +
+ " }\n" +
+ " void f(@Marker X this) {\n" +
+ " String testString;\n" +
+ " testString = new @Readonly @Negative X().getString();\n" +
+ " X.Inner testInner;\n" +
+ " testInner = new @Readonly X.Inner();\n" +
+ " int i;\n" +
+ " for(i = 0; i < 10; i++)\n" +
+ " System.out.print(\"test\");\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " @Marker class Inner {\n" +
+ " @Normal(value = 10) Inner() {\n" +
+ " super();\n" +
+ " System.out.print(\"X.Inner created\");\n" +
+ " }\n" +
+ " }\n" +
+ " @Marker X() {\n" +
+ " super();\n" +
+ " System.out.print(\"new X created\");\n" +
+ " }\n" +
+ " public String getString() {\n" +
+ " return \"hello\";\n" +
+ " }\n" +
+ " void f(@Marker X this) {\n" +
+ " String testString;\n" +
+ " testString = new @Readonly @Negative X().getString();\n" +
+ " X.Inner testInner;\n" +
+ " testInner = new @Readonly X.Inner();\n" +
+ " int i;\n" +
+ " for (i = 0; (i < 10); i ++) \n" +
+ " System.out.print(\"test\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0087", expectedUnitToString );
+}
+
+// To test Parser.classInstanceCreation() with type annotations
+public void test0088() throws IOException {
+ String source =
+ "import java.io.Serializable;\n" +
+ "class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker Serializable() {\n" +
+ " };\n" +
+ " new @Positive @Marker Serializable() {\n" +
+ " public long serialVersion;\n" +
+ " };\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.io.Serializable;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker Serializable() {\n" +
+ " };\n" +
+ " new @Positive @Marker Serializable() {\n" +
+ " public long serialVersion;\n" +
+ " };\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0088", expectedUnitToString );
+}
+
+// To test Parser.classInstanceCreation() with type annotations
+public void test0089() throws IOException {
+ String source =
+ "import java.io.Serializable;\n" +
+ "class X<T>{\n" +
+ " public void f() {\n" +
+ " X testX;\n" +
+ " testX = new @Marker @SingleMember(10) X<@Negative Integer>();\n" +
+ " System.out.print(\"object created\");\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.io.Serializable;\n" +
+ "class X<T> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void f() {\n" +
+ " X testX;\n" +
+ " testX = new @Marker @SingleMember(10) X<@Negative Integer>();\n" +
+ " System.out.print(\"object created\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0089", expectedUnitToString );
+}
+
+// To test Parser.classInstanceCreation() with type annotations
+public void test0090() throws IOException {
+ String source =
+ "class X <@Marker T extends @Readonly String> {\n" +
+ " T foo(T t) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Readonly X<String>().baz(\"SUCCESS\");\n" + // Parser.classInstanceCreation called
+ " }\n" +
+ " void baz(final T t) {\n" +
+ " new @Readonly @Marker Object() {\n" + // Parser.classInstanceCreation called
+ " void print() {\n" +
+ " }\n" +
+ " }.print();\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<@Marker T extends @Readonly String> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " T foo(T t) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Readonly X<String>().baz(\"SUCCESS\");\n" +
+ " }\n" +
+ " void baz(final T t) {\n" +
+ " new @Readonly @Marker Object() {\n" +
+ " void print() {\n" +
+ " }\n" +
+ "}.print();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0090", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithInitializer() with Type Annotations
+public void test0091() throws IOException {
+ String source =
+ "class X <@Marker T extends @Readonly String> {\n" +
+ " public static void main(String[] args) {\n" +
+ " int [] x1;\n" +
+ " x1 = new int @Marker @SingleMember(2) [] {-1, -2};\n" +
+ " Integer [][] x2;\n" +
+ " x2 = new @Positive Integer @Marker @SingleMember(3) [] @SingleMember(3) [] {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<@Marker T extends @Readonly String> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " int[] x1;\n" +
+ " x1 = new int @Marker @SingleMember(2) []{(- 1), (- 2)};\n" +
+ " Integer[][] x2;\n" +
+ " x2 = new @Positive Integer @Marker @SingleMember(3) [] @SingleMember(3) []{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0091", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithInitializer() with Type Annotations
+public void test0092() throws IOException {
+ String source =
+ "class X {\n" +
+ " static class T {\n" +
+ " public @Readonly Object @Normal(value = 10) [] f() {\n" +
+ " return new @Readonly Object @Normal(value = 10) [] {this, T.this};\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " static class T {\n" +
+ " T() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Readonly Object @Normal(value = 10) [] f() {\n" +
+ " return new @Readonly Object @Normal(value = 10) []{this, T.this};\n" +
+ " }\n" +
+ " }\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0092", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithInitializer() with Type Annotations
+public void test0093() throws IOException {
+ String source =
+ "class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " java.util.Arrays.asList(new @Readonly Object @SingleMember(1) [] {\"1\"});\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " java.util.Arrays.asList(new @Readonly Object @SingleMember(1) []{\"1\"});\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0093", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithInitializer() with Type Annotations
+public void test0094() throws IOException {
+ String source =
+ "class X {\n" +
+ " public boolean test() {\n" +
+ " String[] s;\n" +
+ " s = foo(new @Marker String @SingleMember(1) []{\"hello\"});\n" +
+ " return s != null;\n" +
+ " }\n" +
+ " public <@Marker F> F @SingleMember(1) [] foo(F[] f) {\n" +
+ " return f;\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public boolean test() {\n" +
+ " String[] s;\n" +
+ " s = foo(new @Marker String @SingleMember(1) []{\"hello\"});\n" +
+ " return (s != null);\n" +
+ " }\n" +
+ " public <@Marker F>F @SingleMember(1) [] foo(F[] f) {\n" +
+ " return f;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0094", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithInitializer() with Type Annotations
+public void test0095() throws IOException {
+ String source =
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "@Marker class Deejay {\n" +
+ " @Marker class Counter<@Marker T> {}\n" +
+ " public void f(String[] args) {\n" +
+ " Counter<@Positive Integer> songCounter;\n" +
+ " songCounter = new Counter<@Positive Integer>();\n" +
+ " Counter<@Readonly String> genre;\n" +
+ " genre = new Counter<@Readonly String>();\n" +
+ " List<@Marker Counter<?>> list1;\n" +
+ " list1 = Arrays.asList(new @Marker Counter<?> @Normal(value = 2) @Marker [] {songCounter, genre});\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "@Marker class Deejay {\n" +
+ " @Marker class Counter<@Marker T> {\n" +
+ " Counter() {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " Deejay() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void f(String[] args) {\n" +
+ " Counter<@Positive Integer> songCounter;\n" +
+ " songCounter = new Counter<@Positive Integer>();\n" +
+ " Counter<@Readonly String> genre;\n" +
+ " genre = new Counter<@Readonly String>();\n" +
+ " List<@Marker Counter<?>> list1;\n" +
+ " list1 = Arrays.asList(new @Marker Counter<?> @Normal(value = 2) @Marker []{songCounter, genre});\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0095", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithoutInitializer() with Type Annotations
+public void test0096() throws IOException {
+ String source =
+ "class X <@Marker T extends @Readonly String> {\n" +
+ " public static void main(String[] args) {\n" +
+ " int [] x1;\n" +
+ " x1 = new int @Marker @SingleMember(10) [10];\n" +
+ " Integer [][] x2;\n" +
+ " x2 = new @Positive Integer @Marker [10] @Normal(value = 10) [10];\n" +
+ " char[][] tokens;\n" +
+ " tokens = new char @SingleMember(0) [0] @Normal(value = 10) @Marker [];\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<@Marker T extends @Readonly String> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " int[] x1;\n" +
+ " x1 = new int @Marker @SingleMember(10) [10];\n" +
+ " Integer[][] x2;\n" +
+ " x2 = new @Positive Integer @Marker [10] @Normal(value = 10) [10];\n" +
+ " char[][] tokens;\n" +
+ " tokens = new char @SingleMember(0) [0] @Normal(value = 10) @Marker [];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0096", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithoutInitializer() with Type Annotations
+public void test0097() throws IOException {
+ String source =
+ "class X {\n" +
+ " public @Readonly Object @Normal(value = 10) [] f(@Marker X this) {\n" +
+ " return new @Readonly Object @Normal(value = 10) [10];\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Readonly Object @Normal(value = 10) [] f(@Marker X this) {\n" +
+ " return new @Readonly Object @Normal(value = 10) [10];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0097", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithoutInitializer() with Type Annotations
+public void test0098() throws IOException {
+ String source =
+ "class X {\n" +
+ " public boolean test() {\n" +
+ " String[] s;\n" +
+ " s = foo(new @Marker String @SingleMember(1) [10]);\n" +
+ " return s != null;\n" +
+ " }\n" +
+ " public <@Marker F> F @SingleMember(1) [] foo(F[] f) {\n" +
+ " return f;\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public boolean test() {\n" +
+ " String[] s;\n" +
+ " s = foo(new @Marker String @SingleMember(1) [10]);\n" +
+ " return (s != null);\n" +
+ " }\n" +
+ " public <@Marker F>F @SingleMember(1) [] foo(F[] f) {\n" +
+ " return f;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0098", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithoutInitializer() with Type Annotations
+public void test0099() throws IOException {
+ String source =
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "class X<@Marker T> {\n" +
+ " public void test() {\n" +
+ " List<@Marker X<?>> a;\n" +
+ " a = Arrays.asList(new @Marker X<?> @SingleMember(0) [0]);\n" +
+ " String @Marker [] @SingleMember(1) [] x;\n" +
+ " x = new @Readonly String @Normal(value = 5) [5] @SingleMember(1) [1];\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "class X<@Marker T> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void test() {\n" +
+ " List<@Marker X<?>> a;\n" +
+ " a = Arrays.asList(new @Marker X<?> @SingleMember(0) [0]);\n" +
+ " String @Marker [] @SingleMember(1) [] x;\n" +
+ " x = new @Readonly String @Normal(value = 5) [5] @SingleMember(1) [1];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0099", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithoutInitializer() with Type Annotations
+public void test0100() throws IOException {
+ String source =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " public Integer[] getTypes() {\n" +
+ " List<@Positive Integer> list;\n" +
+ " list = new ArrayList<@Positive Integer>();\n" +
+ " return list == null \n" +
+ " ? new @Positive Integer @SingleMember(0) [0] \n" +
+ " : list.toArray(new @Positive Integer @Marker [list.size()]);\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public Integer[] getTypes() {\n" +
+ " List<@Positive Integer> list;\n" +
+ " list = new ArrayList<@Positive Integer>();\n" +
+ " return ((list == null) ? new @Positive Integer @SingleMember(0) [0] : list.toArray(new @Positive Integer @Marker [list.size()]));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0100", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithGenericsArray() with Type Annotations
+public void test0101() throws IOException {
+ String source =
+ "import java.util.*;\n" +
+ "\n" +
+ "@Marker class X {\n" +
+ " Vector<Object> data;\n" +
+ " public void t() {\n" +
+ " Vector<@Readonly Object> v;\n" +
+ " v = (@Marker @SingleMember(0) Vector<@Readonly Object>) data.elementAt(0);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "import java.util.*;\n" +
+ "@Marker class X {\n" +
+ " Vector<Object> data;\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void t() {\n" +
+ " Vector<@Readonly Object> v;\n" +
+ " v = (@Marker @SingleMember(0) Vector<@Readonly Object>) data.elementAt(0);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0101", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithGenericsArray() with Type Annotations
+// To test Parser.consumeClassHeaderExtends() with Type Annotations
+public void test0102() throws IOException {
+ String source =
+ "class X<E> {\n" +
+ " X<@Readonly String> bar() {\n" +
+ " return (@Marker AX<@Readonly String>) new X<@Readonly String>();\n" +
+ " }\n" +
+ " X<@Readonly String> bar(Object o) {\n" +
+ " return (@Marker AX<@Readonly String>) o;\n" +
+ " }\n" +
+ " X<@Negative E> foo(Object o) {\n" +
+ " return (@Marker @Normal(value = 10) AX<@Negative E>) o;\n" +
+ " } \n" +
+ " X<E> baz(Object o) {\n" +
+ " return (@Marker AX<E>) null;\n" +
+ " }\n" +
+ " X<String> baz2(BX bx) {\n" +
+ " return (@Marker @SingleMember(10) X<String>) bx;\n" +
+ " }\n" +
+ "}\n" +
+ "@Normal(value = 1) class AX<@Marker F> extends @Marker X<@SingleMember(10)F> {}\n" +
+ "@Normal(value = 2) class BX extends @Marker @SingleMember(1) AX<@Readonly String> {}\n";
+ String expectedUnitToString =
+ "class X<E> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " X<@Readonly String> bar() {\n" +
+ " return (@Marker AX<@Readonly String>) new X<@Readonly String>();\n" +
+ " }\n" +
+ " X<@Readonly String> bar(Object o) {\n" +
+ " return (@Marker AX<@Readonly String>) o;\n" +
+ " }\n" +
+ " X<@Negative E> foo(Object o) {\n" +
+ " return (@Marker @Normal(value = 10) AX<@Negative E>) o;\n" +
+ " }\n" +
+ " X<E> baz(Object o) {\n" +
+ " return (@Marker AX<E>) null;\n" +
+ " }\n" +
+ " X<String> baz2(BX bx) {\n" +
+ " return (@Marker @SingleMember(10) X<String>) bx;\n" +
+ " }\n" +
+ "}\n" +
+ "@Normal(value = 1) class AX<@Marker F> extends @Marker X<@SingleMember(10) F> {\n" +
+ " AX() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Normal(value = 2) class BX extends @Marker @SingleMember(1) AX<@Readonly String> {\n" +
+ " BX() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0102", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithGenericsArray() with Type Annotations
+public void test0103() throws IOException {
+ String source =
+ "import java.lang.reflect.Array;\n" +
+ "@Marker class X<@Readonly T> {\n" +
+ " T @SingleMember(0) [] theArray;\n" +
+ " public X(Class<T> clazz) {\n" +
+ " theArray = (@Marker @SingleMember(0) T @Normal(value = 10) []) Array.newInstance(clazz, 10); // Compiler warning\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.lang.reflect.Array;\n" +
+ "@Marker class X<@Readonly T> {\n" +
+ " T @SingleMember(0) [] theArray;\n" +
+ " public X(Class<T> clazz) {\n" +
+ " super();\n" +
+ " theArray = (@Marker @SingleMember(0) T @Normal(value = 10) []) Array.newInstance(clazz, 10);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0103", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithGenericsArray() with Type Annotations
+public void test0104() throws IOException {
+ String source =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " void method(Object o) {\n" +
+ " if (o instanceof String[]){\n" +
+ " String[] s;\n" +
+ " s = (@Marker @Readonly String @Marker []) o;\n" +
+ " }\n" +
+ " if (o instanceof @Readonly List<?>[]) {\n" +
+ " List<?>[] es;\n" +
+ " es = (@Marker List<?> @SingleMember(0) []) o;\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void method(Object o) {\n" +
+ " if ((o instanceof String[]))\n" +
+ " {\n" +
+ " String[] s;\n" +
+ " s = (@Marker @Readonly String @Marker []) o;\n" +
+ " }\n" +
+ " if ((o instanceof @Readonly List<?>[]))\n" +
+ " {\n" +
+ " List<?>[] es;\n" +
+ " es = (@Marker List<?> @SingleMember(0) []) o;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0104", expectedUnitToString );
+}
+
+
+// To test Parser.consumeCastExpressionWithPrimitiveType() with Type Annotations
+public void test0105() throws IOException {
+ String source =
+ "import java.util.HashMap;\n" +
+ "class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " HashMap<Byte, Byte> subst;\n" +
+ " subst = new HashMap<Byte, Byte>();\n" +
+ " subst.put((@Marker byte)1, (@Positive byte)1);\n" +
+ " if (1 + subst.get((@Positive @Normal(value = 10) byte)1) > 0.f) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " } \n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "import java.util.HashMap;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " HashMap<Byte, Byte> subst;\n" +
+ " subst = new HashMap<Byte, Byte>();\n" +
+ " subst.put((@Marker byte) 1, (@Positive byte) 1);\n" +
+ " if (((1 + subst.get((@Positive @Normal(value = 10) byte) 1)) > 0.f))\n" +
+ " {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0105", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithPrimitiveType() with Type Annotations
+public void test0106() throws IOException {
+ String source =
+ "class X{\n" +
+ " private float x, y, z;\n" +
+ " float magnitude () {\n" +
+ " return (@Marker @Positive float) Math.sqrt((x*x) + (y*y) + (z*z));\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X {\n" +
+ " private float x;\n" +
+ " private float y;\n" +
+ " private float z;\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " float magnitude() {\n" +
+ " return (@Marker @Positive float) Math.sqrt((((x * x) + (y * y)) + (z * z)));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0106", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithQualifiedGenericsArray() with Type Annotations
+// Javac version b76 crashes on type annotations on type arguments to parameterized classes
+// in a qualified generic reference
+public void test0107() throws IOException {
+ String source =
+ "class C1<T> {\n" +
+ " class C11 { }\n" +
+ " @Marker class C12 {\n" +
+ " T t;\n" +
+ " C1<@Readonly T>.C11 m() {\n" +
+ " C1<@Readonly T>.C11[] ts;\n" +
+ " ts = (@Marker C1<@Readonly T>.C11[]) new @Marker C1<?>.C11 @Normal(value = 5) [5];\n" +
+ " return ts;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class C1<T> {\n" +
+ " class C11 {\n" +
+ " C11() {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " @Marker class C12 {\n" +
+ " T t;\n" +
+ " C12() {\n" +
+ " super();\n" +
+ " }\n" +
+ " C1<@Readonly T>.C11 m() {\n" +
+ " C1<@Readonly T>.C11[] ts;\n" +
+ " ts = ( @Marker C1<@Readonly T>.C11[]) new @Marker C1<?>.C11 @Normal(value = 5) [5];\n" +
+ " return ts;\n" +
+ " }\n" +
+ " }\n" +
+ " C1() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0107", expectedUnitToString );
+}
+
+// To test Parser.consumeFormalParameter() with Type Annotations
+public void test0108() throws IOException {
+ String source =
+ "class X {\n" +
+ " int field;" +
+ " public void test(@Marker X x,@Positive int i){\n" +
+ " x.field = i;\n" +
+ " }\n" +
+ " public static void main(@Readonly String args @Normal(10) []){" +
+ " System.exit(0);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X {\n" +
+ " int field;\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void test(@Marker X x, @Positive int i) {\n" +
+ " x.field = i;\n" +
+ " }\n" +
+ " public static void main(@Readonly String @Normal(10) [] args) {\n" +
+ " System.exit(0);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0108", expectedUnitToString );
+}
+
+// To test Parser.consumeFormalParameter() with Type Annotations
+public void test0109() throws IOException {
+ String source =
+ "class X<@Marker T> {\n" +
+ " T field;" +
+ " public void test(@Marker @SingleMember(1) X<? extends @Marker Object> x,@Positive T i){\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<@Marker T> {\n" +
+ " T field;\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void test(@Marker @SingleMember(1) X<? extends @Marker Object> x, @Positive T i) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0109", expectedUnitToString );
+}
+
+// To test Parser.consumeClassInstanceCreationExpressionQualifiedWithTypeArguments()
+// with Type Annotations
+// Javac b76 crashes with type annotations in qualified class instance creation expression
+public void test0110() throws IOException {
+ String source =
+ "class X {\n" +
+ " class MX {\n" +
+ " @Marker <T> MX(T t){\n" +
+ " System.out.println(t);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X().new <@Readonly String> @Marker MX(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X {\n" +
+ " class MX {\n" +
+ " @Marker <T>MX(T t) {\n" +
+ " super();\n" +
+ " System.out.println(t);\n" +
+ " }\n" +
+ " }\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X().new <@Readonly String>@Marker MX(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0110", expectedUnitToString);
+}
+
+// To test Parser.consumeClassInstanceCreationExpressionWithTypeArguments()
+// with Type Annotations
+public void test0111() throws IOException {
+ String source =
+ "class X {\n" +
+ " public <T> X(T t){\n" +
+ " System.out.println(t);\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new <@Readonly String> @Marker @SingleMember(0) X(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X {\n" +
+ " public <T>X(T t) {\n" +
+ " super();\n" +
+ " System.out.println(t);\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new <@Readonly String>@Marker @SingleMember(0) X(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0111", expectedUnitToString);
+}
+
+// To test Parser.consumeEnhancedForStatementHeaderInit() with Type Annotations
+public void test0112() throws IOException {
+ String source =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " List list() { return null; }\n" +
+ " void m2() { for (@SingleMember(10) Iterator<@Marker X> i = list().iterator(); i.hasNext();); }\n" +
+ " void m3() {\n" +
+ " Integer [] array;\n" +
+ " array = new Integer [] {1, 2, 3};\n" +
+ " List<List<X>> xList;\n" +
+ " xList = null;\n" +
+ " for(@Positive @SingleMember(10) Integer i: array) {}\n" +
+ " for(@Marker @Normal(value = 5) List<@Readonly X> x: xList) {}\n" +
+ " }" +
+ "}\n";
+ String expectedUnitToString =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " List list() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " void m2() {\n" +
+ " for (@SingleMember(10) Iterator<@Marker X> i = list().iterator();; i.hasNext(); ) \n" +
+ " ;\n" +
+ " }\n" +
+ " void m3() {\n" +
+ " Integer[] array;\n" +
+ " array = new Integer[]{1, 2, 3};\n" +
+ " List<List<X>> xList;\n" +
+ " xList = null;\n" +
+ " for (@Positive @SingleMember(10) Integer i : array) \n" +
+ " {\n" +
+ " }\n" +
+ " for (@Marker @Normal(value = 5) List<@Readonly X> x : xList) \n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_COMPLETION_PARSER & ~CHECK_SELECTION_PARSER & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0112", expectedUnitToString );
+ expectedUnitToString =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " List list() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " void m2() {\n" +
+ " for (@SingleMember(10) Iterator<@Marker X> i;; i.hasNext(); ) \n" +
+ " ;\n" +
+ " }\n" +
+ " void m3() {\n" +
+ " Integer[] array;\n" +
+ " array = new Integer[]{1, 2, 3};\n" +
+ " List<List<X>> xList;\n" +
+ " xList = null;\n" +
+ " for (@Positive @SingleMember(10) Integer i : array) \n" +
+ " {\n" +
+ " }\n" +
+ " for (@Marker @Normal(value = 5) List<@Readonly X> x : xList) \n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_COMPLETION_PARSER & CHECK_SELECTION_PARSER, source.toCharArray(), null, "test0112", expectedUnitToString );
+}
+
+// To test Parser.consumeEnterAnonymousClassBody() with Type Annotations
+public void test0113() throws IOException {
+ String source =
+ "@Marker class X {\n" +
+ " void f(@Normal(value = 5) X this) {\n" +
+ " new @Marker @SingleMember(10) Object() {\n" +
+ " void foo(){\n" +
+ " System.out.println(\"test\");\n" +
+ " }\n" +
+ " }.foo();\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "@Marker class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void f(@Normal(value = 5) X this) {\n" +
+ " new @Marker @SingleMember(10) Object() {\n" +
+ " void foo() {\n" +
+ " System.out.println(\"test\");\n" +
+ " }\n" +
+ "}.foo();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_DOCUMENT_ELEMENT_PARSER, source.toCharArray(), null, "test0113", expectedUnitToString );
+}
+
+// To test Parser.consumeEnterAnonymousClassBody() with Type Annotations
+public void test0114() throws IOException {
+ String source =
+ "class Toplevel2{\n" +
+ " public boolean foo(){\n" +
+ " Toplevel2 o;\n" +
+ " o = new @Marker @Normal(value = 5) Toplevel2() { \n" +
+ " public boolean foo() { return false; } // no copy in fact\n" +
+ " };\n" +
+ " return o.foo();\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class Toplevel2 {\n" +
+ " Toplevel2() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public boolean foo() {\n" +
+ " Toplevel2 o;\n" +
+ " o = new @Marker @Normal(value = 5) Toplevel2() {\n" +
+ " public boolean foo() {\n" +
+ " return false;\n" +
+ " }\n" +
+ "};\n" +
+ " return o.foo();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_DOCUMENT_ELEMENT_PARSER, source.toCharArray(), null, "test0114", expectedUnitToString );
+}
+
+// To test Parser.consumeEnterAnonymousClassBody() with Type Annotations
+public void test0115() throws IOException {
+ String source =
+ "class X <T> {\n" +
+ " T foo(T t) {\n" +
+ " System.out.println(t);\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String @Normal(value = 5) [] args) {\n" +
+ " new @Marker X<@SingleMember(10) @Normal(value = 5) XY>() {\n" +
+ " void run() {\n" +
+ " foo(new @Marker XY());\n" +
+ " }\n" +
+ " }.run();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class XY {\n" +
+ " public String toString() {\n" +
+ " return \"SUCCESS\";\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<T> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " T foo(T t) {\n" +
+ " System.out.println(t);\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String @Normal(value = 5) [] args) {\n" +
+ " new @Marker X<@SingleMember(10) @Normal(value = 5) XY>() {\n" +
+ " void run() {\n" +
+ " foo(new @Marker XY());\n" +
+ " }\n" +
+ "}.run();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class XY {\n" +
+ " XY() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public String toString() {\n" +
+ " return \"SUCCESS\";\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_DOCUMENT_ELEMENT_PARSER, source.toCharArray(), null, "test0115", expectedUnitToString );
+}
+
+// To test Parser.consumeInsideCastExpressionLL1() with Type Annotations
+public void test0116() throws IOException {
+ String source =
+ "class X{\n" +
+ " public void test1(){\n" +
+ " throw (@Marker Error) null; \n" +
+ " } \n" +
+ " public void test2(){\n" +
+ " String s;\n" +
+ " s = (@Marker @SingleMember(10) String) null;\n" +
+ " byte b;\n" +
+ " b = 0;\n" +
+ " Byte i;\n" +
+ " i = (@Positive Byte) b;\n" +
+ " } \n" +
+ " public void test3(java.io.Serializable name) {\n" +
+ " Object temp;\n" +
+ " temp = (Object)name;\n" +
+ " System.out.println( (String)temp );\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void test1() {\n" +
+ " throw (@Marker Error) null;\n" +
+ " }\n" +
+ " public void test2() {\n" +
+ " String s;\n" +
+ " s = (@Marker @SingleMember(10) String) null;\n" +
+ " byte b;\n" +
+ " b = 0;\n" +
+ " Byte i;\n" +
+ " i = (@Positive Byte) b;\n" +
+ " }\n" +
+ " public void test3(java.io.Serializable name) {\n" +
+ " Object temp;\n" +
+ " temp = (Object) name;\n" +
+ " System.out.println((String) temp);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0116", expectedUnitToString );
+}
+
+// To test Parser.consumeInstanceOfExpression() with Type Annotations
+public void test0117() throws IOException {
+ String source =
+ "import java.util.*;\n" +
+ "class X <@NonNull T>{\n" +
+ " public void test1(Object obj) {\n" +
+ " if(obj instanceof @Marker @NonNull X) {\n" +
+ " X newX;\n" +
+ " newX = (@NonNull X) obj;\n" +
+ " }\n" +
+ " }\n" +
+ " @NonNull T foo(@NonNull T t) {\n" +
+ " if (t instanceof @NonNull @Marker List<?> @Normal(value = 10) []) {\n" +
+ " List<?> @SingleMember (10) [] es;\n" +
+ " es = (@Marker List<?> @SingleMember(10) []) t;\n" +
+ " }\n" +
+ " if (t instanceof @Marker @Normal(value = 5) X<?>) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " return t;\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.util.*;\n" +
+ "class X<@NonNull T> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void test1(Object obj) {\n" +
+ " if ((obj instanceof @Marker @NonNull X))\n" +
+ " {\n" +
+ " X newX;\n" +
+ " newX = (@NonNull X) obj;\n" +
+ " }\n" +
+ " }\n" +
+ " @NonNull T foo(@NonNull T t) {\n" +
+ " if ((t instanceof @NonNull @Marker List<?> @Normal(value = 10) []))\n" +
+ " {\n" +
+ " List<?> @SingleMember(10) [] es;\n" +
+ " es = (@Marker List<?> @SingleMember(10) []) t;\n" +
+ " }\n" +
+ " if ((t instanceof @Marker @Normal(value = 5) X<?>))\n" +
+ " {\n" +
+ " return t;\n" +
+ " }\n" +
+ " return t;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER , source.toCharArray(), null, "test0117", expectedUnitToString );
+}
+
+// To test Parser.consumeInstanceOfExpressionWithName() with Type Annotations
+public void test0118() throws IOException {
+ String source =
+ "class Outer<E> {\n" +
+ " Inner inner;\n" +
+ " class Inner {\n" +
+ " E e;\n" +
+ " @NonNull E getOtherElement(Object other) {\n" +
+ " if (!(other instanceof @Marker @SingleMember(10) Outer<?>.Inner))\n" +
+ " throw new @Marker IllegalArgumentException(String.valueOf(other));\n" +
+ " Inner that;\n" +
+ " that = (@Marker Inner) other;\n" +
+ " return that.e;\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class Outer<E> {\n" +
+ " class Inner {\n" +
+ " E e;\n" +
+ " Inner() {\n" +
+ " super();\n" +
+ " }\n" +
+ " @NonNull E getOtherElement(Object other) {\n" +
+ " if ((! (other instanceof @Marker @SingleMember(10) Outer<?>.Inner)))\n" +
+ " throw new @Marker IllegalArgumentException(String.valueOf(other));\n" +
+ " Inner that;\n" +
+ " that = (@Marker Inner) other;\n" +
+ " return that.e;\n" +
+ " }\n" +
+ " }\n" +
+ " Inner inner;\n" +
+ " Outer() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER , source.toCharArray(), null, "test0118", expectedUnitToString );
+}
+
+// To test Parser.consumeTypeArgument() with Type Annotations
+public void test0119() throws IOException {
+ String source =
+ "class X<@SingleMember(1) Xp1 extends @Readonly String, @NonNull Xp2 extends @NonNull Comparable> extends @Marker XS<@SingleMember(10) Xp2> {\n" +
+ "\n" +
+ " public static void main(String @Marker [] args) {\n" +
+ " Integer w;\n" +
+ " w = new @Marker X<@Readonly @SingleMember(10) String,@Positive Integer>().get(new @Positive Integer(12));\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " Xp2 get(@Marker X this, Xp2 t) {\n" +
+ " System.out.print(\"{X::get}\");\n" +
+ " return super.get(t);\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class XS <@NonNull XSp1> {\n" +
+ " XSp1 get(XSp1 t) {\n" +
+ " @NonNull @SingleMember(10) Y.M mObject;\n" +
+ " mObject = new @SingleMember(10) @NonNull Y.M();\n" +
+ " System.out.print(\"{XS::get}\");\n" +
+ " return t;\n" +
+ " }\n" +
+ "}\n" +
+ "class X2<T,E>{}\n" +
+ "@Marker class Y extends @Marker X2<@NonNull Y.M, @NonNull @SingleMember(1) Y.N> {\n" +
+ " static class M{}\n" +
+ " static class N extends M{}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<@SingleMember(1) Xp1 extends @Readonly String, @NonNull Xp2 extends @NonNull Comparable> extends @Marker XS<@SingleMember(10) Xp2> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String @Marker [] args) {\n" +
+ " Integer w;\n" +
+ " w = new @Marker X<@Readonly @SingleMember(10) String, @Positive Integer>().get(new @Positive Integer(12));\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " Xp2 get(@Marker X this, Xp2 t) {\n" +
+ " System.out.print(\"{X::get}\");\n" +
+ " return super.get(t);\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class XS<@NonNull XSp1> {\n" +
+ " XS() {\n" +
+ " super();\n" +
+ " }\n" +
+ " XSp1 get(XSp1 t) {\n" +
+ " @NonNull @SingleMember(10) Y.M mObject;\n" +
+ " mObject = new @SingleMember(10) @NonNull Y.M();\n" +
+ " System.out.print(\"{XS::get}\");\n" +
+ " return t;\n" +
+ " }\n" +
+ "}\n" +
+ "class X2<T, E> {\n" +
+ " X2() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class Y extends @Marker X2<@NonNull Y.M, @NonNull @SingleMember(1) Y.N> {\n" +
+ " static class M {\n" +
+ " M() {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " static class N extends M {\n" +
+ " N() {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0119", expectedUnitToString );
+}
+
+// To test Parser.consumeTypeArgument() with Type Annotations
+public void test0120() throws IOException {
+ String source =
+ "class X<A1, A2, A3, A4, A5, A6, A7, A8> {\n" +
+ "}\n" +
+ "class Y {\n" +
+ " @Marker X<int @Marker [], short @SingleMember(1) [] @Marker [], long[] @NonNull [][], float[] @Marker [] @Normal(value = 5) [][], double[][]@Marker [] @SingleMember(10) [][], boolean[][][][][][], char[] @Marker [][][][][][], Object[][]@Marker [] @SingleMember(10) [] @Normal(value = 5) [][][][][]> x;\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<A1, A2, A3, A4, A5, A6, A7, A8> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " @Marker X<int @Marker [], short @SingleMember(1) [] @Marker [], long[] @NonNull [][], float[] @Marker [] @Normal(value = 5) [][], double[][] @Marker [] @SingleMember(10) [][], boolean[][][][][][], char[] @Marker [][][][][][], Object[][] @Marker [] @SingleMember(10) [] @Normal(value = 5) [][][][][]> x;\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0120", expectedUnitToString );
+}
+
+// To test Parser.consumeTypeArgumentReferenceType1() with Type Annotations
+public void test0121() throws IOException {
+ String source =
+ "@Marker class X <@NonNull T> {\n" +
+ " protected T t;\n" +
+ " @Marker X(@NonNull T t) {\n" +
+ " this.t = t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X<@Marker X<@Readonly @NonNull String>> xs;\n" +
+ " xs = new @Marker X<@Marker X<@Readonly @NonNull String>>(new @Marker X<@Readonly @NonNull @SingleMember(10) String>(\"SUCCESS\"));\n" +
+ " System.out.println(xs.t.t);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class X<@NonNull T> {\n" +
+ " protected T t;\n" +
+ " @Marker X(@NonNull T t) {\n" +
+ " super();\n" +
+ " this.t = t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X<@Marker X<@Readonly @NonNull String>> xs;\n" +
+ " xs = new @Marker X<@Marker X<@Readonly @NonNull String>>(new @Marker X<@Readonly @NonNull @SingleMember(10) String>(\"SUCCESS\"));\n" +
+ " System.out.println(xs.t.t);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0121", expectedUnitToString );
+}
+
+// To test Parser.consumeTypeParameter1WithExtendsAndBounds() and Parser.consumeWildcardBoundsSuper() with
+// Type Annotations
+public void test0122() throws IOException {
+ String source =
+ "@Marker class Foo extends @Marker Foo1 implements @Marker @SingleMember(10) Comparable<@Marker Foo1> {\n" +
+ " public int compareTo(Foo1 arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n" +
+ "class Foo1 {}\n" +
+ "@Marker class X<@NonNull T extends @NonNull @Normal (value = 5) Object & @Marker Comparable<? super @NonNull T>> {\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X<@Marker Foo>();\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class Foo extends @Marker Foo1 implements @Marker @SingleMember(10) Comparable<@Marker Foo1> {\n" +
+ " Foo() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public int compareTo(Foo1 arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n" +
+ "class Foo1 {\n" +
+ " Foo1() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class X<@NonNull T extends @NonNull @Normal(value = 5) Object & @Marker Comparable<? super @NonNull T>> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X<@Marker Foo>();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0122", expectedUnitToString );
+}
+
+// To test Parser.consumeTypeParameter1WithExtendsAndBounds() with Type Annotations
+public void test0123() throws IOException {
+ String source =
+ "@Marker class Foo extends @Marker Foo1 implements @Marker @SingleMember(10) Comparable {\n" +
+ " public int compareTo(Object arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n" +
+ "class Foo1 {}\n" +
+ "@Marker class X<@NonNull T extends @NonNull @Normal (value = 5) Object & @Marker Comparable, @NonNull V extends @Readonly Object> {\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X<@Marker Foo, @SingleMember(0) Foo1>();\n" +
+ " Class <@NonNull Foo> c;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class Foo extends @Marker Foo1 implements @Marker @SingleMember(10) Comparable {\n" +
+ " Foo() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public int compareTo(Object arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n" +
+ "class Foo1 {\n" +
+ " Foo1() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class X<@NonNull T extends @NonNull @Normal(value = 5) Object & @Marker Comparable, @NonNull V extends @Readonly Object> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X<@Marker Foo, @SingleMember(0) Foo1>();\n" +
+ " Class<@NonNull Foo> c;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0123", expectedUnitToString );
+}
+//To test type annotations on static class member access in a declaration
+public void test0125() throws IOException {
+ String source =
+ "public class X extends @A(\"Hello, World!\") Y<@B @C('(') String[] @D[]> {}";
+ String expectedUnitToString =
+ "public class X extends @A(\"Hello, World!\") Y<@B @C(\'(\') String[] @D []> {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0125", expectedUnitToString );
+}
+//To test type annotations on static class member access in a declaration
+public void test0126() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A(\"Hello, World!\") @B @C('(') String@E[] @D[] f;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A(\"Hello, World!\") @B @C(\'(\') String @E [] @D [] f;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0126", expectedUnitToString );
+}
+//To test type annotations on static class member access in a declaration
+public void test0127() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A(\"Hello, World!\") Y<@B @C('(') String[] @D[]> f;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A(\"Hello, World!\") Y<@B @C(\'(\') String[] @D []> f;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0127", expectedUnitToString );
+}
+//type class literal expression
+public void test0128() throws IOException {
+ String source =
+ "public class X {\n" +
+ " public boolean foo(String s) {\n" +
+ " return (s instanceof @C('_') Object[]);\n" +
+ " }\n" +
+ " public Object foo1(String s) {\n" +
+ " return new @B(3) @A(\"new Object\") Object[] {};\n" +
+ " }\n" +
+ " public Class foo2(String s) {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public Class foo3(String s) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public boolean foo(String s) {\n" +
+ " return (s instanceof @C(\'_\') Object[]);\n" +
+ " }\n" +
+ " public Object foo1(String s) {\n" +
+ " return new @B(3) @A(\"new Object\") Object[]{};\n" +
+ " }\n" +
+ " public Class foo2(String s) {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public Class foo3(String s) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0128", expectedUnitToString );
+}
+//instanceof checks
+public void test0129() throws IOException {
+ String source = "public class Clazz {\n" +
+ "public static void main(Object o) {\n" +
+ "if (o instanceof @Readonly String) {\n" +
+ "}\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class Clazz {\n" +
+ " public Clazz() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(Object o) {\n" +
+ " if ((o instanceof @Readonly String))\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0129", expectedUnitToString);
+}
+//instanceof checks
+public void test0130() throws IOException {
+ String source = "public class Clazz {\n" +
+ "public static void foo() {\n" +
+ " if (o instanceof @Readonly String[]) {}" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class Clazz {\n" +
+ " public Clazz() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void foo() {\n" +
+ " if ((o instanceof @Readonly String[]))\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+//cast
+public void test0131() throws IOException {
+ String source =
+ "public class X {\n" +
+ " public void foo(Object o) {\n" +
+ " if (o instanceof String[][]) {\n" +
+ " String[][] tab = (@C('_') @B(3) String[] @A[]) o;\n" +
+ " System.out.println(tab.length);\n" +
+ " }\n" +
+ " System.out.println(o);\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo(Object o) {\n" +
+ " if ((o instanceof String[][]))\n" +
+ " {\n" +
+ " String[][] tab = (@C(\'_\') @B(3) String[] @A []) o;\n" +
+ " System.out.println(tab.length);\n" +
+ " }\n" +
+ " System.out.println(o);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+//cast
+public void test0132() throws IOException {
+ String source =
+ "public class X {\n" +
+ " public void foo(Object o) {\n" +
+ " if (o instanceof String[][]) {\n" +
+ " String[][] tab = (@C('_') @B(3) String@D[] @A[]) o;\n" +
+ " System.out.println(tab.length);\n" +
+ " }\n" +
+ " System.out.println(o);\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo(Object o) {\n" +
+ " if ((o instanceof String[][]))\n" +
+ " {\n" +
+ " String[][] tab = (@C(\'_\') @B(3) String @D [] @A []) o;\n" +
+ " System.out.println(tab.length);\n" +
+ " }\n" +
+ " System.out.println(o);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+//generic type arguments in a generic method invocation
+public void test0133() throws IOException {
+ String source =
+ "public class X {\n" +
+ " static <T, U> T foo(T t, U u) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(X.<@D() @A(value = \"hello\") String, @B X>foo(\"SUCCESS\", null));\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static <T, U>T foo(T t, U u) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(X.<@D() @A(value = \"hello\") String, @B X>foo(\"SUCCESS\", null));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+//generic type arguments in a generic method invocation
+public void test0134() throws IOException {
+ String source =
+ "public class X {\n" +
+ "\n" +
+ " <T, U> T foo(T t, U u) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X x = new X();\n" +
+ " System.out.println(x.<@D() @A(value = \"hello\") String, @B X>foo(\"SUCCESS\", null));\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " <T, U>T foo(T t, U u) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X x = new X();\n" +
+ " System.out.println(x.<@D() @A(value = \"hello\") String, @B X>foo(\"SUCCESS\", null));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+//generic type arguments in a generic constructor invocation
+public void test0135() throws IOException {
+ String source =
+ "public class X {\n" +
+ " <T, U> X(T t, U u) {\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X x = new <@D() @A(value = \"hello\") String, @B X> X();\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " <T, U>X(T t, U u) {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X x = new <@D() @A(value = \"hello\") String, @B X>X();\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383600 -- Receiver annotation - new syntax.
+public void test0136() throws IOException {
+ String source =
+ "public class X<T> {\n" +
+ " public class Y<K> {\n" +
+ " void foo(@Marker X<T> this) {\n" +
+ " }\n" +
+ " public class Z {\n" +
+ " Z(@D() @A(value = \"hello\") X<T>.Y<K> X.Y.this) {\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X<String>().new Y<Integer>().new Z();\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class X<T> {\n" +
+ " public class Y<K> {\n" +
+ " public class Z {\n" +
+ " Z(@D() @A(value = \"hello\") X<T>.Y<K> X.Y.this) {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " public Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(@Marker X<T> this) {\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X<String>().new Y<Integer>().new Z();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+// Support type annotations for wildcard
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=388085
+public void test0137() throws IOException {
+ String source =
+ "class X {\n" +
+ " public void main(Four<@Marker ? super String, @Marker ? extends Object> param) {\n" +
+ " One<@Marker ? extends Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String,@Marker ? extends Object>>>> one = null;\n" +
+ " Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String,@Marker ? extends Object>>> two = null;\n" +
+ " Three<@Marker ? extends Four<@Marker ? super String,@Marker ? extends Object>> three = null;\n" +
+ " Four<@Marker ? super String,@Marker ? extends Object> four = param;\n" +
+ " }\n" +
+ "}\n" +
+ "class One<R> {}\n" +
+ "class Two<S> {}\n" +
+ "class Three<T> {}\n" +
+ "class Four<U, V> {}\n" +
+ "@interface Marker {}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void main(Four<@Marker ? super String, @Marker ? extends Object> param) {\n" +
+ " One<@Marker ? extends Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;\n" +
+ " Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String, @Marker ? extends Object>>> two = null;\n" +
+ " Three<@Marker ? extends Four<@Marker ? super String, @Marker ? extends Object>> three = null;\n" +
+ " Four<@Marker ? super String, @Marker ? extends Object> four = param;\n" +
+ " }\n" +
+ "}\n" +
+ "class One<R> {\n" +
+ " One() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class Two<S> {\n" +
+ " Two() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class Three<T> {\n" +
+ " Three() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class Four<U, V> {\n" +
+ " Four() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@interface Marker {\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0137", expectedUnitToString);
+}
+public void test0138() throws IOException {
+ String source =
+ "import java.lang.annotation.Target;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "public class X {\n" +
+ " public void foo() {\n" +
+ " int @Marker [][][] i = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [bar()] @Marker @Marker2 [];\n" +
+ " int @Marker [][][] j = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [X.bar2(2)] @Marker @Marker2 [];\n" +
+ " }\n" +
+ " public int bar() {\n" +
+ " return 2;\n" +
+ " }\n" +
+ " public static int bar2(int k) {\n" +
+ " return k;\n" +
+ " }\n" +
+ "}\n" +
+ "@Target (java.lang.annotation.ElementType.TYPE_USE)\n" +
+ "@interface Marker {}\n" +
+ "@Target (java.lang.annotation.ElementType.TYPE_USE)\n" +
+ "@interface Marker2 {}\n";
+ String expectedUnitToString =
+ "import java.lang.annotation.Target;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " int @Marker [][][] i = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [bar()] @Marker @Marker2 [];\n" +
+ " int @Marker [][][] j = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [X.bar2(2)] @Marker @Marker2 [];\n" +
+ " }\n" +
+ " public int bar() {\n" +
+ " return 2;\n" +
+ " }\n" +
+ " public static int bar2(int k) {\n" +
+ " return k;\n" +
+ " }\n" +
+ "}\n" +
+ "@Target(java.lang.annotation.ElementType.TYPE_USE) @interface Marker {\n" +
+ "}\n" +
+ "@Target(java.lang.annotation.ElementType.TYPE_USE) @interface Marker2 {\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0137", expectedUnitToString);
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java
new file mode 100644
index 0000000..719ba65
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 GK Software AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * Stephan Herrmann - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.io.File;
+import java.util.Map;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.JavaCore;
+
+public abstract class AbstractNullAnnotationTest extends AbstractComparableTest {
+
+ // class libraries including our default null annotation types:
+ String[] LIBS;
+
+ // names and content of custom annotations used in a few tests:
+ static final String CUSTOM_NONNULL_NAME = "org/foo/NonNull.java";
+ static final String CUSTOM_NONNULL_CONTENT =
+ "package org.foo;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({METHOD,PARAMETER,LOCAL_VARIABLE})\n" +
+ "public @interface NonNull {\n" +
+ "}\n";
+ static final String CUSTOM_NONNULL_CONTENT_JSR308 =
+ "package org.foo;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({METHOD,PARAMETER,LOCAL_VARIABLE,TYPE_USE})\n" +
+ "public @interface NonNull {\n" +
+ "}\n";
+ static final String CUSTOM_NULLABLE_NAME = "org/foo/Nullable.java";
+ static final String CUSTOM_NULLABLE_CONTENT = "package org.foo;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({METHOD,PARAMETER,LOCAL_VARIABLE})\n" +
+ "public @interface Nullable {\n" +
+ "}\n";
+ static final String CUSTOM_NULLABLE_CONTENT_JSR308 = "package org.foo;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({METHOD,PARAMETER,LOCAL_VARIABLE,TYPE_USE})\n" +
+ "public @interface Nullable {\n" +
+ "}\n";
+
+ public AbstractNullAnnotationTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ if (this.LIBS == null) {
+ String[] defaultLibs = getDefaultClassPaths();
+ int len = defaultLibs.length;
+ this.LIBS = new String[len+1];
+ System.arraycopy(defaultLibs, 0, this.LIBS, 0, len);
+ File bundleFile = FileLocator.getBundleFile(Platform.getBundle("org.eclipse.jdt.annotation"));
+ if (bundleFile.isDirectory())
+ this.LIBS[len] = bundleFile.getPath()+"/bin";
+ else
+ this.LIBS[len] = bundleFile.getPath();
+ }
+ }
+
+ // Conditionally augment problem detection settings
+ static boolean setNullRelatedOptions = true;
+
+ protected Map getCompilerOptions() {
+ Map defaultOptions = super.getCompilerOptions();
+ if (setNullRelatedOptions) {
+ defaultOptions.put(JavaCore.COMPILER_PB_NULL_REFERENCE, JavaCore.ERROR);
+ defaultOptions.put(JavaCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE, JavaCore.ERROR);
+ defaultOptions.put(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK, JavaCore.ERROR);
+ defaultOptions.put(JavaCore.COMPILER_PB_INCLUDE_ASSERTS_IN_NULL_ANALYSIS, JavaCore.ENABLED);
+
+ defaultOptions.put(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION_FOR_INTERFACE_METHOD_IMPLEMENTATION, JavaCore.DISABLED);
+
+ // enable null annotations:
+ defaultOptions.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
+ // leave other new options at these defaults:
+// defaultOptions.put(CompilerOptions.OPTION_ReportNullContractViolation, JavaCore.ERROR);
+// defaultOptions.put(CompilerOptions.OPTION_ReportPotentialNullContractViolation, JavaCore.ERROR);
+// defaultOptions.put(CompilerOptions.OPTION_ReportNullContractInsufficientInfo, CompilerOptions.WARNING);
+
+// defaultOptions.put(CompilerOptions.OPTION_NullableAnnotationName, "org.eclipse.jdt.annotation.Nullable");
+// defaultOptions.put(CompilerOptions.OPTION_NonNullAnnotationName, "org.eclipse.jdt.annotation.NonNull");
+ }
+ return defaultOptions;
+ }
+ void runNegativeTestWithLibs(String[] testFiles, String expectedErrorLog) {
+ runNegativeTest(
+ testFiles,
+ expectedErrorLog,
+ this.LIBS,
+ false /*shouldFlush*/);
+ }
+ void runNegativeTestWithLibs(boolean shouldFlushOutputDirectory, String[] testFiles, Map customOptions, String expectedErrorLog) {
+ runNegativeTest(
+ shouldFlushOutputDirectory,
+ testFiles,
+ this.LIBS,
+ customOptions,
+ expectedErrorLog,
+ // runtime options
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+ }
+ void runNegativeTestWithLibs(String[] testFiles, Map customOptions, String expectedErrorLog) {
+ runNegativeTestWithLibs(false /* flush output directory */, testFiles, customOptions, expectedErrorLog);
+ }
+ void runConformTestWithLibs(String[] testFiles, Map customOptions, String expectedCompilerLog) {
+ runConformTestWithLibs(false /* flush output directory */, testFiles, customOptions, expectedCompilerLog);
+ }
+ void runConformTestWithLibs(boolean shouldFlushOutputDirectory, String[] testFiles, Map customOptions, String expectedCompilerLog) {
+ runConformTest(
+ shouldFlushOutputDirectory,
+ testFiles,
+ this.LIBS,
+ customOptions,
+ expectedCompilerLog,
+ "",/* expected output */
+ "",/* expected error */
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+ }
+ void runConformTest(String[] testFiles, Map customOptions, String expectedOutputString) {
+ runConformTest(
+ testFiles,
+ expectedOutputString,
+ null /*classLibraries*/,
+ true /*shouldFlushOutputDirectory*/,
+ null /*vmArguments*/,
+ customOptions,
+ null /*customRequestor*/);
+
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
index 4e4c52e..dfccffd 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
@@ -1,14 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Stephan Herrmann - Contribution for bug 335093 - [compiler][null] minimal hook for future null annotation support
* Technical University Berlin - adapted for Object Teams
+ * Stephan Herrmann - Contribution for
+ * bug 335093 - [compiler][null] minimal hook for future null annotation support
+ * bug 388800 - [1.8] adjust tests to 1.8 JRE
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -65,6 +71,117 @@
import org.eclipse.jdt.internal.core.search.indexing.BinaryIndexer;
public abstract class AbstractRegressionTest extends AbstractCompilerTest implements StopableTestCase {
+
+ // for compiling against JRE 8:
+ static final boolean IS_JRE_8;
+ static final String COMPARATOR_IMPL_JRE8;
+ static final String COMPARATOR_RAW_IMPL_JRE8;
+ static final String COLLECTION_IMPL_JRE8;
+ static final String COLLECTION_RAW_IMPL_JRE8;
+ static final String LIST_IMPL_JRE8;
+ static final String LIST_RAW_IMPL_JRE8;
+ static final String ITERABLE_IMPL_JRE8;
+ static final String ITERABLE_RAW_IMPL_JRE8;
+ static final String ITERATOR_IMPL_JRE8;
+ static final String ITERATOR_RAW_IMPL_JRE8;
+ static final String MAP_IMPL_JRE8;
+ static final String MAP_RAW_IMPL_JRE8;
+
+ static {
+ String javaVersion = System.getProperty("java.specification.version");
+ IS_JRE_8 = "1.8".equals(javaVersion);
+ if (IS_JRE_8) { // TODO(stephan) accommodate future versions ...
+ COMPARATOR_IMPL_JRE8 = // replace '*' with T, '%' with U
+ " public java.util.Comparator<*> reverseOrder() { return null;}\n" +
+ " public java.util.Comparator<*> thenComparing(java.util.Comparator<? super *> other) { return null;}\n" +
+ " public <% extends java.lang.Comparable<? super %>> java.util.Comparator<*> thenComparing(java.util.function.Function<? super *, ? extends %> keyExtractor) { return null;}\n" +
+ " public java.util.Comparator<*> thenComparing(java.util.function.IntFunction<? super *> keyExtractor) { return null;}\n" +
+ " public java.util.Comparator<*> thenComparing(java.util.function.LongFunction<? super *> keyExtractor) { return null;}\n" +
+ " public java.util.Comparator<*> thenComparing(java.util.function.DoubleFunction<? super *> keyExtractor) { return null;}\n";
+ COMPARATOR_RAW_IMPL_JRE8 =
+ " public java.util.Comparator reverseOrder() { return null;}\n" +
+ " public java.util.Comparator thenComparing(java.util.Comparator other) { return null;}\n" +
+ " public java.util.Comparator thenComparing(java.util.function.Function keyExtractor) { return null;}\n" +
+ " public java.util.Comparator thenComparing(java.util.function.IntFunction keyExtractor) { return null;}\n" +
+ " public java.util.Comparator thenComparing(java.util.function.LongFunction keyExtractor) { return null;}\n" +
+ " public java.util.Comparator thenComparing(java.util.function.DoubleFunction keyExtractor) { return null;}\n";
+ COLLECTION_IMPL_JRE8 =
+ " public boolean removeAll(java.util.function.Predicate<? super *> filter) { return false;}\n" +
+ " public java.util.stream.Stream<*> stream() { return null;}\n" +
+ " public java.util.stream.Stream<*> parallelStream() { return null;}\n";
+ COLLECTION_RAW_IMPL_JRE8 =
+ " public @SuppressWarnings(\"rawtypes\") boolean removeAll(java.util.function.Predicate filter) { return false;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") java.util.stream.Stream stream() { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") java.util.stream.Stream parallelStream() { return null;}\n";
+ LIST_IMPL_JRE8 =// replace '*' with your concrete type argument
+ " public void sort(java.util.Comparator<? super *> comparator) {}\n" +
+ " public void parallelSort(java.util.Comparator<? super *> comparator) {}\n" +
+ " public void replaceAll(java.util.function.UnaryOperator<*> operator) {}\n";
+ LIST_RAW_IMPL_JRE8 =
+ " public @SuppressWarnings(\"rawtypes\") void sort(java.util.Comparator comparator) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void parallelSort(java.util.Comparator comparator) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void replaceAll(java.util.function.UnaryOperator operator) {}\n";
+ ITERABLE_IMPL_JRE8 = // replace '*' with your concrete type argument
+ " public void forEach(java.util.function.Block<? super *> block){}\n";
+ ITERABLE_RAW_IMPL_JRE8 =
+ " public @SuppressWarnings(\"rawtypes\") void forEach(java.util.function.Block block) {}\n";
+ ITERATOR_IMPL_JRE8 = // replace '*' with your concrete type argument
+ " public void forEach(java.util.function.Block<? super *> block){}\n";
+ ITERATOR_RAW_IMPL_JRE8 =
+ " public void forEach(java.util.function.Block block){}\n";
+ MAP_IMPL_JRE8 = // '*' for 'K', '%' for 'V'
+ " public boolean remove(Object key, Object value) { return false;}\n" +
+ " public void forEach(java.util.function.BiBlock<? super *, ? super %> block) {}\n" +
+ " public void replaceAll(java.util.function.BiFunction<*, %, %> function) {}\n" +
+ " public % putIfAbsent(* key, % value) { return null;}\n" +
+ " public boolean replace(* key, % oldValue, % newValue) { return false;}\n" +
+ " public % replace(* key, % value) { return null;}\n" +
+ " public % computeIfAbsent(* key, java.util.function.Function<? super *, ? extends %> mappingFunction) { return null;}\n" +
+ " public % computeIfPresent(* key, java.util.function.BiFunction<? super *, ? super %, ? extends %> remappingFunction) { return null;}\n" +
+ " public % compute(* key, java.util.function.BiFunction<? super *, ? super %, ? extends %> remappingFunction) { return null;}\n" +
+ " public % merge(* key, % value, java.util.function.BiFunction<? super %, ? super %, ? extends %> remappingFunction) { return null;}\n";
+ MAP_RAW_IMPL_JRE8 =
+ " public boolean remove(Object key, Object value) { return false;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void forEach(java.util.function.BiBlock block) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void replaceAll(java.util.function.BiFunction function) {}\n" +
+ " public Object putIfAbsent(Object key, Object value) { return null;}\n" +
+ " public boolean replace(Object key, Object oldValue, Object newValue) { return false;}\n" +
+ " public Object replace(Object key, Object value) { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object computeIfAbsent(Object key, java.util.function.Function mappingFunction) { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object computeIfPresent(Object key, java.util.function.BiFunction remappingFunction) { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object compute(Object key, java.util.function.BiFunction remappingFunction) { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object merge(Object key, Object value, java.util.function.BiFunction remappingFunction) { return null;}\n";
+ } else {
+ COMPARATOR_IMPL_JRE8 = "";
+ COMPARATOR_RAW_IMPL_JRE8 = "";
+ COLLECTION_IMPL_JRE8 = "";
+ COLLECTION_RAW_IMPL_JRE8 = "";
+ LIST_IMPL_JRE8 = "";
+ LIST_RAW_IMPL_JRE8 = "";
+ ITERABLE_IMPL_JRE8 = "";
+ ITERABLE_RAW_IMPL_JRE8 = "";
+ ITERATOR_IMPL_JRE8 = "\n";
+ ITERATOR_RAW_IMPL_JRE8 = "\n";
+ MAP_IMPL_JRE8 = "";
+ MAP_RAW_IMPL_JRE8 = "";
+ }
+ }
+ String getListRawImplJRE8() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return LIST_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", "");
+ return LIST_RAW_IMPL_JRE8;
+ }
+ String getIterableRawImplJRE8() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return ITERABLE_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", "");
+ return ITERABLE_RAW_IMPL_JRE8;
+ }
+ String getCollectionRawImplJRE8() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return COLLECTION_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", "");
+ return COLLECTION_RAW_IMPL_JRE8;
+ }
+
// javac comparison related types, fields and methods - see runJavac for
// details
static class JavacCompiler {
@@ -490,7 +607,10 @@
}
Excuse excuseFor(JavacCompiler compiler) {
if (this.minorsFixed != null) {
- if (compiler.compliance == ClassFileConstants.JDK1_7) {
+ if (compiler.compliance == ClassFileConstants.JDK1_8) {
+ return this.minorsFixed[5] > compiler.minor || this.minorsFixed[5] < 0 ?
+ this : null;
+ } else if (compiler.compliance == ClassFileConstants.JDK1_7) {
return this.minorsFixed[4] > compiler.minor || this.minorsFixed[4] < 0 ?
this : null;
} else if (compiler.compliance == ClassFileConstants.JDK1_6) {
@@ -842,6 +962,8 @@
buffer.append("\" -1.6 -proc:none");
} else if (this.complianceLevel == ClassFileConstants.JDK1_7) {
buffer.append("\" -1.7 -proc:none");
+ } else if (this.complianceLevel == ClassFileConstants.JDK1_8) {
+ buffer.append("\" -1.8 -proc:none");
}
buffer
.append(" -preserveAllLocals -nowarn -g -classpath \"")
@@ -1814,6 +1936,33 @@
// javac options
JavacTestOptions.DEFAULT /* default javac test options */);
}
+protected void runNegativeTest(String[] testFiles, String expectedCompilerLog, boolean performStatementRecovery) {
+ runTest(
+ // test directory preparation
+ true /* flush output directory */,
+ testFiles /* test files */,
+ // compiler options
+ null /* no class libraries */,
+ null /* no custom options */,
+ performStatementRecovery,
+ new Requestor( /* custom requestor */
+ false,
+ null /* no custom requestor */,
+ false,
+ false),
+ // compiler results
+ expectedCompilerLog == null || /* expecting compiler errors */
+ expectedCompilerLog.indexOf("ERROR") != -1,
+ expectedCompilerLog /* expected compiler log */,
+ // runtime options
+ false /* do not force execution */,
+ null /* no vm arguments */,
+ // runtime results
+ null /* do not check output string */,
+ null /* do not check error string */,
+ // javac options
+ JavacTestOptions.DEFAULT /* default javac test options */);
+}
// WORK potential elimination candidate (24 calls) - else clean up inline
protected void runNegativeTest(
String[] testFiles,
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
index 0c6446f..d2c356a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
@@ -1,12 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stephan Herrmann - Contribution for
+ * bug 388739 - [1.8][compiler] consider default methods when detecting whether a class needs to be declared abstract
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -115,7 +121,7 @@
"1. ERROR in X.java (at line 4)\n" +
" static interface I3<E3, E4> extends I1<E3>, I2<E4> {}\n" +
" ^^\n" +
- "Name clash: The method method(E1) of type X.I1<E1> has the same erasure as method(E2) of type X.I2<E2> but does not override it\n" +
+ "Name clash: The method method(E2) of type X.I2<E2> has the same erasure as method(E1) of type X.I1<E1> but does not override it\n" +
"----------\n");
}
}
@@ -492,7 +498,7 @@
);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=123943 - case 2
- public void test009() {
+ public void _test009() {
this.runConformTest(
new String[] {
"T.java",
@@ -2485,7 +2491,7 @@
"1. ERROR in X.java (at line 1)\n" +
" public class X<T extends I & J> {\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods J.method(), I.method()\n" +
+ "The return types are incompatible for the inherited methods I.method(), J.method()\n" +
"----------\n",
// javac options
JavacTestOptions.JavacHasABug.JavacBug5061359 /* javac test options */);
@@ -2517,7 +2523,7 @@
"1. ERROR in X.java (at line 1)\n" +
" public class X<T extends I & J> {\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods J.method(), I.method()\n" +
+ "The return types are incompatible for the inherited methods I.method(), J.method()\n" +
"----------\n" +
"2. ERROR in X.java (at line 3)\n" +
" t.method();\n" +
@@ -3176,12 +3182,12 @@
"1. ERROR in X.java (at line 3)\n" +
" interface C extends B, A {}\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods A.foo(), B.foo()\n" +
+ "The return types are incompatible for the inherited methods B.foo(), A.foo()\n" +
"----------\n" +
"2. ERROR in X.java (at line 4)\n" +
" interface D extends A, B {}\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods B.foo(), A.foo()\n" +
+ "The return types are incompatible for the inherited methods A.foo(), B.foo()\n" +
"----------\n" +
"3. ERROR in X.java (at line 8)\n" +
" X<? extends B> c_b = c.foo();\n" +
@@ -3307,7 +3313,7 @@
"3. ERROR in Y.java (at line 13)\n" +
" abstract class Y extends X implements I, J {\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods J.a(), I.a()\n" +
+ "The return types are incompatible for the inherited methods I.a(), J.a()\n" +
"----------\n" +
"4. ERROR in Y.java (at line 20)\n" +
" abstract class Y2 extends X implements J, I {\n" +
@@ -3322,7 +3328,7 @@
"6. ERROR in Y.java (at line 20)\n" +
" abstract class Y2 extends X implements J, I {\n" +
" ^^\n" +
- "The return types are incompatible for the inherited methods I.a(), J.a()\n" +
+ "The return types are incompatible for the inherited methods J.a(), I.a()\n" +
"----------\n"
);
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
index 9608c05..acf4695 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
@@ -4,6 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
@@ -1030,6 +1034,30 @@
"----------\n");
}
+ // check annotation member modifiers (validity unchanged despite grammar change from JSR 335 - default methods)
+ // and https://bugs.eclipse.org/bugs/show_bug.cgi?id=3383968
+ public void test039a() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public @interface X {\n" +
+ " strictfp double val() default 0.1;\n" +
+ " synchronized String id() default \"zero\";\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " strictfp double val() default 0.1;\n" +
+ " ^^^^^\n" +
+ "Illegal modifier for the annotation attribute X.val; only public & abstract are permitted\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " synchronized String id() default \"zero\";\n" +
+ " ^^^^\n" +
+ "Illegal modifier for the annotation attribute X.id; only public & abstract are permitted\n" +
+ "----------\n");
+ }
+
// check annotation array field initializer
public void test040() {
this.runNegativeTest(
@@ -9907,40 +9935,51 @@
"----------\n" +
"7. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
- " ^^^^^^^^^^^^^^^^\n" +
- "Syntax error on tokens, delete these tokens\n" +
+ " ^^^^\n" +
+ "Syntax error, insert \"Identifier (\" to complete MethodHeaderName\n" +
"----------\n" +
"8. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
- " ^^^^\n" +
- "Syntax error, insert \"enum Identifier\" to complete EnumHeaderName\n" +
+ " ^^^^\n" +
+//{ObjectTeams: starting from here the OT/J grammar produces different errors:
+// different:
+ "Syntax error, insert \")\" to complete MethodSpecLong\n" +
"----------\n" +
"9. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^\n" +
- "Syntax error, insert \"EnumBody\" to complete EnumDeclaration\n" +
+ "Syntax error, insert \"<-\" to complete CallinBindingLeft\n" +
+//
"----------\n" +
"10. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^\n" +
+// new
+ "Syntax error, insert \"MethodSpecsLong EmptyParameterMappings\" to complete InvalidCallinBinding\n" +
+ "----------\n" +
+// number changes beyond this point
+ "11. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+ " org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
+ " ^^^^\n" +
"Syntax error, insert \"}\" to complete ClassBody\n" +
"----------\n" +
- "11. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+ "12. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Return type for the method is missing\n" +
"----------\n" +
- "12. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+ "13. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^\n" +
"NonNull cannot be resolved to a type\n" +
"----------\n" +
- "13. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+ "14. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^^\n" +
"Nullable cannot be resolved to a type\n" +
"----------\n" +
- "14. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+ "15. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+// SH}
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^\n" +
"Syntax error, insert \";\" to complete ConstructorDeclaration\n" +
@@ -9993,40 +10032,51 @@
"----------\n" +
"6. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
- " ^^^^^^^^^^^^^^^^\n" +
- "Syntax error on tokens, delete these tokens\n" +
+ " ^^^^\n" +
+ "Syntax error, insert \"Identifier (\" to complete MethodHeaderName\n" +
"----------\n" +
"7. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^\n" +
- "Syntax error, insert \"enum Identifier\" to complete EnumHeaderName\n" +
+//{ObjectTeams: starting from here the OT/J grammar produces different errors:
+// different:
+ "Syntax error, insert \")\" to complete MethodSpecLong\n" +
"----------\n" +
"8. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^\n" +
- "Syntax error, insert \"EnumBody\" to complete EnumDeclaration\n" +
+ "Syntax error, insert \"<-\" to complete CallinBindingLeft\n" +
+//
"----------\n" +
+// new
"9. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^\n" +
+ "Syntax error, insert \"MethodSpecsLong EmptyParameterMappings\" to complete InvalidCallinBinding\n" +
+// number changes beyond this point
+ "----------\n" +
+ "10. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+ " org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
+ " ^^^^\n" +
"Syntax error, insert \"}\" to complete ClassBody\n" +
"----------\n" +
- "10. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+ "11. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Return type for the method is missing\n" +
"----------\n" +
- "11. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+ "12. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^\n" +
"NonNull cannot be resolved to a type\n" +
"----------\n" +
- "12. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+ "13. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^^\n" +
"Nullable cannot be resolved to a type\n" +
"----------\n" +
- "13. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+ "14. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+// SH}
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^\n" +
"Syntax error, insert \";\" to complete ConstructorDeclaration\n" +
@@ -10048,34 +10098,45 @@
"1. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^^^\n" +
- "Syntax error on token \"org\", delete this token\n" +
+ "Syntax error, insert \"Identifier (\" to complete MethodHeaderName\n" +
"----------\n" +
"2. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
- " ^^^\n" +
- "Syntax error, insert \"enum Identifier\" to complete EnumHeaderName\n" +
+ " ^^^\n" +
+//{ObjectTeams: starting from here the OT/J grammar produces different errors:
+// different:
+ "Syntax error, insert \")\" to complete MethodSpecLong\n" +
"----------\n" +
"3. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^^^\n" +
- "Syntax error, insert \"EnumBody\" to complete EnumDeclaration\n" +
- "----------\n" +
+ "Syntax error, insert \"<-\" to complete CallinBindingLeft\n" +
+//
+ "----------\n" +
+// new
"4. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^^^\n" +
+ "Syntax error, insert \"MethodSpecsLong EmptyParameterMappings\" to complete InvalidCallinBinding\n" +
+// number changes beyond this point
+ "----------\n" +
+ "5. ERROR in snippet\\Bug366003.java (at line 5)\n" +
+ " org.User(@Bla String a)\n" +
+ " ^^^\n" +
"Syntax error, insert \"}\" to complete ClassBody\n" +
"----------\n" +
- "5. ERROR in snippet\\Bug366003.java (at line 5)\n" +
+ "6. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^^^^^^^^^^^^^^^^^^^\n" +
"Return type for the method is missing\n" +
"----------\n" +
- "6. ERROR in snippet\\Bug366003.java (at line 5)\n" +
+ "7. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^^^\n" +
"Bla cannot be resolved to a type\n" +
- "----------\n" +
- "7. ERROR in snippet\\Bug366003.java (at line 5)\n" +
+ "----------\n" +
+// SH}
+ "8. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^\n" +
"Syntax error, insert \";\" to complete ConstructorDeclaration\n" +
@@ -10097,26 +10158,26 @@
" }\n" +
"}\n"
},
- "----------\n" +
- "1. ERROR in snippet\\Bug366003.java (at line 7)\n" +
- " e } catch (@Blah Exception eSecond) {\n" +
- " ^\n" +
- "Syntax error, insert \"AssignmentOperator Expression\" to complete Assignment\n" +
- "----------\n" +
- "2. ERROR in snippet\\Bug366003.java (at line 7)\n" +
- " e } catch (@Blah Exception eSecond) {\n" +
- " ^\n" +
- "Syntax error, insert \";\" to complete BlockStatements\n" +
- "----------\n" +
- "3. ERROR in snippet\\Bug366003.java (at line 8)\n" +
- " e }\n" +
- " ^\n" +
- "Syntax error, insert \"AssignmentOperator Expression\" to complete Expression\n" +
- "----------\n" +
- "4. ERROR in snippet\\Bug366003.java (at line 8)\n" +
- " e }\n" +
- " ^\n" +
- "Syntax error, insert \";\" to complete BlockStatements\n" +
+ "----------\n" +
+ "1. ERROR in snippet\\Bug366003.java (at line 7)\n" +
+ " e } catch (@Blah Exception eSecond) {\n" +
+ " ^\n" +
+ "Syntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration\n" +
+ "----------\n" +
+ "2. ERROR in snippet\\Bug366003.java (at line 7)\n" +
+ " e } catch (@Blah Exception eSecond) {\n" +
+ " ^\n" +
+ "Syntax error, insert \";\" to complete BlockStatements\n" +
+ "----------\n" +
+ "3. ERROR in snippet\\Bug366003.java (at line 8)\n" +
+ " e }\n" +
+ " ^\n" +
+ "Syntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration\n" +
+ "----------\n" +
+ "4. ERROR in snippet\\Bug366003.java (at line 8)\n" +
+ " e }\n" +
+ " ^\n" +
+ "Syntax error, insert \";\" to complete BlockStatements\n" +
"----------\n");
}
public void testBug366003e() {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
index 656bac1..c7fa688 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
@@ -4,6 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
@@ -1580,8 +1584,9 @@
" -1.5 -5 -5.0 use 1.5 compliance (-source 1.5 -target 1.5)\n" +
" -1.6 -6 -6.0 use 1.6 compliance (-source 1.6 -target 1.6)\n" +
" -1.7 -7 -7.0 use 1.7 compliance (-source 1.7 -target 1.7)\n" +
- " -source <version> set source level: 1.3 to 1.7 (or 5, 5.0, etc)\n" +
- " -target <version> set classfile target: 1.1 to 1.7 (or 5, 5.0, etc)\n" +
+ " -1.8 -8 -8.0 use 1.8 compliance (-source 1.8 -target 1.8)\n" +
+ " -source <version> set source level: 1.3 to 1.8 (or 5, 5.0, etc)\n" +
+ " -target <version> set classfile target: 1.1 to 1.8 (or 5, 5.0, etc)\n" +
" cldc1.1 can also be used to generate the StackMap\n" +
" attribute\n" +
" \n" +
@@ -12838,7 +12843,7 @@
new String[] {
"X1.java",
"public class X1 {\n" +
- " Zork;\n" +
+ " Zork z;\n" +
"}\n",
"org/eclipse/jdt/annotation/NonNull.java",
NONNULL_ANNOTATION_CONTENT,
@@ -12859,9 +12864,9 @@
"A default nullness annotation has not been specified for the type X1\n" +
"----------\n" +
"2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X1.java (at line 2)\n" +
- " Zork;\n" +
+ " Zork z;\n" +
" ^^^^\n" +
- "Syntax error on token \"Zork\", VariableDeclarator expected after this token\n" +
+ "Zork cannot be resolved to a type\n" +
"----------\n" +
"2 problems (1 error, 1 warning)",
true);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
index f81c551..458e1a6 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 IBM Corporation and others.
+ * Copyright (c) 2006, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Benjamin Muskalla - Contribution for bug 239066
@@ -16,11 +20,16 @@
* bug 365662 - [compiler][null] warn on contradictory and redundant null annotations
* bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
* bug 374605 - Unreasonable warning for enum-based switch statements
+ * bug 382353 - [1.8][compiler] Implementation property modifiers should be accepted on default methods.
+ * bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
* bug 388281 - [compiler][null] inheritance of null annotations as an option
* bug 381443 - [compiler][null] Allow parameter widening from @NonNull to unannotated
* bug 331649 - [compiler][null] consider null annotations for fields
* bug 382789 - [compiler][null] warn when syntactically-nonnull expression is compared against null
- *******************************************************************************/
+ * bug 392862 - [1.8][compiler][null] Evaluate null annotations on array types
+ * Jesper S Moller - Contributions for
+ * bug 382701 - [1.8][compiler] Implement semantic analysis of Lambda expressions & Reference expression
+*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
import java.lang.reflect.Field;
@@ -368,6 +377,7 @@
expectedProblemAttributes.put("ArgumentTypeNotFound", DEPRECATED);
expectedProblemAttributes.put("ArgumentTypeNotVisible", DEPRECATED);
expectedProblemAttributes.put("ArrayConstantsOnlyInArrayInitializers", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("ArrayReferencePotentialNullReference", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("ArrayReferenceRequired", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("AssignmentHasNoEffect", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("AssignmentToMultiCatchParameter", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
@@ -413,12 +423,17 @@
expectedProblemAttributes.put("ConflictingImport", new ProblemAttributes(CategorizedProblem.CAT_IMPORT));
expectedProblemAttributes.put("ConflictingNullAnnotations", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("ConflictingInheritedNullAnnotations", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("ConstructorReferenceNotBelow18", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("ConstructorVarargsArgumentNeedCast", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("CorruptedSignature", new ProblemAttributes(CategorizedProblem.CAT_BUILDPATH));
expectedProblemAttributes.put("DeadCode", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("DefaultMethodNotBelow18", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("DefaultMethodOverridesObjectMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("DereferencingNullableExpression", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("DiamondNotBelow17", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("DirectInvocationOfAbstractMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("DisallowedTargetForAnnotation", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("DisallowedExplicitThisParameter", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("DiscouragedReference", new ProblemAttributes(CategorizedProblem.CAT_RESTRICTION));
expectedProblemAttributes.put("DuplicateAnnotation", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("DuplicateAnnotationMember", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
@@ -458,10 +473,13 @@
expectedProblemAttributes.put("ExceptionTypeInternalNameProvided", DEPRECATED);
expectedProblemAttributes.put("ExceptionTypeNotFound", DEPRECATED);
expectedProblemAttributes.put("ExceptionTypeNotVisible", DEPRECATED);
+ expectedProblemAttributes.put("ExplicitThisParameterNotInLambda", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("ExplicitThisParameterNotBelow18", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("ExplicitlyClosedAutoCloseable", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
expectedProblemAttributes.put("ExpressionShouldBeAVariable", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("ExternalProblemFixable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("ExternalProblemNotFixable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
+ expectedProblemAttributes.put("ExplicitAnnotationTargetRequired", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("FallthroughCase", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("FieldHidingField", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT));
expectedProblemAttributes.put("FieldHidingLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT));
@@ -489,6 +507,7 @@
expectedProblemAttributes.put("IllegalAnnotationForBaseType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalCast", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalClassLiteralForTypeVariable", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("IllegalDeclarationOfThisParameter", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("IllegalDefinitionToNonNullParameter", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("IllegalDimension", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("IllegalEnclosingInstanceSpecification", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
@@ -514,6 +533,7 @@
expectedProblemAttributes.put("IllegalModifierForInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalModifierForInterfaceField", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalModifierForInterfaceMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("IllegalModifierForInterfaceDefaultMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalModifierForLocalClass", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalModifierForLocalEnum", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalModifierForMemberClass", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
@@ -521,16 +541,23 @@
expectedProblemAttributes.put("IllegalModifierForMemberInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalModifierForMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalModifierForVariable", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("IllegalModifiersForElidedType", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("IllegalPrimitiveOrArrayTypeForEnclosingInstance", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalQualifiedEnumConstantLabel", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalQualifiedParameterizedTypeAllocation", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("IllegalQualifierForExplicitThis", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("IllegalQualifierForExplicitThis2", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("IllegalReturnNullityRedefinition", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("IllegalRedefinitionToNonNullParameter", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("IllegalStaticModifierForMemberType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("IllegalTypeAnnotationsInStaticMemberAccess", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("IllegalTypeForExplicitThis", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("IllegalTypeVariableSuperReference", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("IllegalUnderscorePosition", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("IllegalUsageOfQualifiedTypeReference", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("IllegalUsageOfTypeAnnotations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("IllegalVararg", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("IllegalVarargInLambda", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForField", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForMemberType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
@@ -557,6 +584,7 @@
expectedProblemAttributes.put("IndirectAccessToStaticField", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
expectedProblemAttributes.put("IndirectAccessToStaticMethod", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
expectedProblemAttributes.put("IndirectAccessToStaticType", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
+ expectedProblemAttributes.put("InheritedDefaultMethodConflictsWithOtherInherited", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("InheritedFieldHidesEnclosingName", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("InheritedIncompatibleReturnType", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("InheritedMethodHidesEnclosingName", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
@@ -591,6 +619,7 @@
expectedProblemAttributes.put("InvalidHighSurrogate", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidInput", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidLowSurrogate", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("InvalidLocationForModifiers", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidNullToSynchronized", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("InvalidOctal", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidOperator", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
@@ -610,6 +639,7 @@
expectedProblemAttributes.put("InvalidUsageOfEnumDeclarations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfForeachStatements", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfStaticImports", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("InvalidUsageOfTypeAnnotations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfTypeArguments", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfTypeParameters", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfTypeParametersForAnnotationDeclaration", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
@@ -686,6 +716,7 @@
expectedProblemAttributes.put("JavadocUsingDeprecatedField", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
expectedProblemAttributes.put("JavadocUsingDeprecatedMethod", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
expectedProblemAttributes.put("JavadocUsingDeprecatedType", new ProblemAttributes(CategorizedProblem.CAT_JAVADOC));
+ expectedProblemAttributes.put("LambdaExpressionNotBelow18", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("LocalVariableCanOnlyBeNull", DEPRECATED);
expectedProblemAttributes.put("LocalVariableCannotBeNull", DEPRECATED);
expectedProblemAttributes.put("LocalVariableHidingField", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT));
@@ -702,9 +733,11 @@
expectedProblemAttributes.put("MethodNameClash", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("MethodNameClashHidden", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("MethodReducesVisibility", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("MethodReferenceNotBelow18", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("MethodRequiresBody", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("MethodReturnsVoid", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("MethodVarargsArgumentNeedCast", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("MisplacedTypeAnnotations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("MissingArgumentsForParameterizedMemberType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("MissingDefaultCase", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("MissingEnclosingInstance", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
@@ -761,6 +794,8 @@
expectedProblemAttributes.put("NullLocalVariableComparisonYieldsFalse", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("NullLocalVariableInstanceofYieldsFalse", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("NullLocalVariableReference", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("NullityMismatchingTypeAnnotation", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("NullityMismatchingTypeAnnotationUnchecked", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("NullSourceString", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("NumericValueOutOfRange", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("ObjectCannotBeGeneric", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
@@ -858,6 +893,7 @@
expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("SwitchOnEnumNotBelow15", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("SwitchOnStringsNotBelow17", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("TargetTypeNotAFunctionalInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("Task", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("ThisInStaticContext", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("ThisSuperDuringConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
@@ -1168,6 +1204,7 @@
expectedProblemAttributes.put("ArgumentTypeNotFound", SKIP);
expectedProblemAttributes.put("ArgumentTypeNotVisible", SKIP);
expectedProblemAttributes.put("ArrayConstantsOnlyInArrayInitializers", SKIP);
+ expectedProblemAttributes.put("ArrayReferencePotentialNullReference", new ProblemAttributes(JavaCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE));
expectedProblemAttributes.put("ArrayReferenceRequired", SKIP);
expectedProblemAttributes.put("AssignmentHasNoEffect", new ProblemAttributes(JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT));
expectedProblemAttributes.put("AssignmentToMultiCatchParameter", SKIP);
@@ -1212,10 +1249,14 @@
expectedProblemAttributes.put("ConflictingImport", SKIP);
expectedProblemAttributes.put("ConflictingNullAnnotations", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
expectedProblemAttributes.put("ConflictingInheritedNullAnnotations", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
+ expectedProblemAttributes.put("ConstructorReferenceNotBelow18", SKIP);
expectedProblemAttributes.put("ContradictoryNullAnnotations", SKIP);
expectedProblemAttributes.put("ConstructorVarargsArgumentNeedCast", new ProblemAttributes(JavaCore.COMPILER_PB_VARARGS_ARGUMENT_NEED_CAST));
expectedProblemAttributes.put("CorruptedSignature", SKIP);
expectedProblemAttributes.put("DeadCode", new ProblemAttributes(JavaCore.COMPILER_PB_DEAD_CODE));
+ expectedProblemAttributes.put("DefaultMethodNotBelow18", SKIP);
+ expectedProblemAttributes.put("DefaultMethodOverridesObjectMethod", SKIP);
+ expectedProblemAttributes.put("DereferencingNullableExpression", new ProblemAttributes(JavaCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE));
expectedProblemAttributes.put("DiamondNotBelow17", SKIP);
expectedProblemAttributes.put("DirectInvocationOfAbstractMethod", SKIP);
expectedProblemAttributes.put("DisallowedTargetForAnnotation", SKIP);
@@ -1258,10 +1299,13 @@
expectedProblemAttributes.put("ExceptionTypeInternalNameProvided", SKIP);
expectedProblemAttributes.put("ExceptionTypeNotFound", SKIP);
expectedProblemAttributes.put("ExceptionTypeNotVisible", SKIP);
+ expectedProblemAttributes.put("ExplicitThisParameterNotInLambda", SKIP);
+ expectedProblemAttributes.put("ExplicitThisParameterNotBelow18", SKIP);
expectedProblemAttributes.put("ExplicitlyClosedAutoCloseable", new ProblemAttributes(JavaCore.COMPILER_PB_EXPLICITLY_CLOSED_AUTOCLOSEABLE));
expectedProblemAttributes.put("ExpressionShouldBeAVariable", SKIP);
expectedProblemAttributes.put("ExternalProblemFixable", SKIP);
expectedProblemAttributes.put("ExternalProblemNotFixable", SKIP);
+ expectedProblemAttributes.put("ExplicitAnnotationTargetRequired", SKIP);
expectedProblemAttributes.put("FallthroughCase", new ProblemAttributes(JavaCore.COMPILER_PB_FALLTHROUGH_CASE));
expectedProblemAttributes.put("FieldHidingField", new ProblemAttributes(JavaCore.COMPILER_PB_FIELD_HIDING));
expectedProblemAttributes.put("FieldHidingLocalVariable", new ProblemAttributes(JavaCore.COMPILER_PB_FIELD_HIDING));
@@ -1289,6 +1333,7 @@
expectedProblemAttributes.put("IllegalAnnotationForBaseType", SKIP);
expectedProblemAttributes.put("IllegalCast", SKIP);
expectedProblemAttributes.put("IllegalClassLiteralForTypeVariable", SKIP);
+ expectedProblemAttributes.put("IllegalDeclarationOfThisParameter", SKIP);
expectedProblemAttributes.put("IllegalDefinitionToNonNullParameter", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
expectedProblemAttributes.put("IllegalDimension", SKIP);
expectedProblemAttributes.put("IllegalEnclosingInstanceSpecification", SKIP);
@@ -1314,6 +1359,7 @@
expectedProblemAttributes.put("IllegalModifierForInterface", SKIP);
expectedProblemAttributes.put("IllegalModifierForInterfaceField", SKIP);
expectedProblemAttributes.put("IllegalModifierForInterfaceMethod", SKIP);
+ expectedProblemAttributes.put("IllegalModifierForInterfaceDefaultMethod", SKIP);
expectedProblemAttributes.put("IllegalModifierForLocalClass", SKIP);
expectedProblemAttributes.put("IllegalModifierForLocalEnum", SKIP);
expectedProblemAttributes.put("IllegalModifierForMemberClass", SKIP);
@@ -1321,16 +1367,23 @@
expectedProblemAttributes.put("IllegalModifierForMemberInterface", SKIP);
expectedProblemAttributes.put("IllegalModifierForMethod", SKIP);
expectedProblemAttributes.put("IllegalModifierForVariable", SKIP);
+ expectedProblemAttributes.put("IllegalModifiersForElidedType", SKIP);
expectedProblemAttributes.put("IllegalPrimitiveOrArrayTypeForEnclosingInstance", SKIP);
expectedProblemAttributes.put("IllegalQualifiedEnumConstantLabel", SKIP);
expectedProblemAttributes.put("IllegalQualifiedParameterizedTypeAllocation", SKIP);
+ expectedProblemAttributes.put("IllegalQualifierForExplicitThis", SKIP);
+ expectedProblemAttributes.put("IllegalQualifierForExplicitThis2", SKIP);
expectedProblemAttributes.put("IllegalRedefinitionToNonNullParameter", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
expectedProblemAttributes.put("IllegalReturnNullityRedefinition", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
expectedProblemAttributes.put("IllegalStaticModifierForMemberType", SKIP);
+ expectedProblemAttributes.put("IllegalTypeAnnotationsInStaticMemberAccess", SKIP);
+ expectedProblemAttributes.put("IllegalTypeForExplicitThis", SKIP);
expectedProblemAttributes.put("IllegalTypeVariableSuperReference", SKIP);
expectedProblemAttributes.put("IllegalUnderscorePosition", SKIP);
expectedProblemAttributes.put("IllegalUsageOfQualifiedTypeReference", SKIP);
+ expectedProblemAttributes.put("IllegalUsageOfTypeAnnotations", SKIP);
expectedProblemAttributes.put("IllegalVararg", SKIP);
+ expectedProblemAttributes.put("IllegalVarargInLambda", SKIP);
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForField", SKIP);
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForMemberType", SKIP);
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForMethod", SKIP);
@@ -1357,6 +1410,7 @@
expectedProblemAttributes.put("IndirectAccessToStaticField", new ProblemAttributes(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS));
expectedProblemAttributes.put("IndirectAccessToStaticMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS));
expectedProblemAttributes.put("IndirectAccessToStaticType", new ProblemAttributes(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS));
+ expectedProblemAttributes.put("InheritedDefaultMethodConflictsWithOtherInherited", SKIP);
expectedProblemAttributes.put("InheritedFieldHidesEnclosingName", SKIP);
expectedProblemAttributes.put("InheritedIncompatibleReturnType", SKIP);
expectedProblemAttributes.put("InheritedMethodHidesEnclosingName", SKIP);
@@ -1391,6 +1445,7 @@
expectedProblemAttributes.put("InvalidHighSurrogate", SKIP);
expectedProblemAttributes.put("InvalidInput", SKIP);
expectedProblemAttributes.put("InvalidLowSurrogate", SKIP);
+ expectedProblemAttributes.put("InvalidLocationForModifiers", SKIP);
expectedProblemAttributes.put("InvalidNullToSynchronized", SKIP);
expectedProblemAttributes.put("InvalidOctal", SKIP);
expectedProblemAttributes.put("InvalidOperator", SKIP);
@@ -1409,7 +1464,9 @@
expectedProblemAttributes.put("InvalidUsageOfAnnotations", SKIP);
expectedProblemAttributes.put("InvalidUsageOfEnumDeclarations", SKIP);
expectedProblemAttributes.put("InvalidUsageOfForeachStatements", SKIP);
+ expectedProblemAttributes.put("InvalidUsageOfReceiverAnnotations", SKIP);
expectedProblemAttributes.put("InvalidUsageOfStaticImports", SKIP);
+ expectedProblemAttributes.put("InvalidUsageOfTypeAnnotations", SKIP);
expectedProblemAttributes.put("InvalidUsageOfTypeArguments", SKIP);
expectedProblemAttributes.put("InvalidUsageOfTypeParameters", SKIP);
expectedProblemAttributes.put("InvalidUsageOfTypeParametersForAnnotationDeclaration", SKIP);
@@ -1486,6 +1543,7 @@
expectedProblemAttributes.put("JavadocUsingDeprecatedField", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
expectedProblemAttributes.put("JavadocUsingDeprecatedMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
expectedProblemAttributes.put("JavadocUsingDeprecatedType", new ProblemAttributes(JavaCore.COMPILER_PB_INVALID_JAVADOC));
+ expectedProblemAttributes.put("LambdaExpressionNotBelow18", SKIP);
expectedProblemAttributes.put("LocalVariableCanOnlyBeNull", SKIP);
expectedProblemAttributes.put("LocalVariableCannotBeNull", SKIP);
expectedProblemAttributes.put("LocalVariableHidingField", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING));
@@ -1502,9 +1560,11 @@
expectedProblemAttributes.put("MethodNameClash", SKIP);
expectedProblemAttributes.put("MethodNameClashHidden", SKIP);
expectedProblemAttributes.put("MethodReducesVisibility", SKIP);
+ expectedProblemAttributes.put("MethodReferenceNotBelow18", SKIP);
expectedProblemAttributes.put("MethodRequiresBody", SKIP);
expectedProblemAttributes.put("MethodReturnsVoid", SKIP);
expectedProblemAttributes.put("MethodVarargsArgumentNeedCast", new ProblemAttributes(JavaCore.COMPILER_PB_VARARGS_ARGUMENT_NEED_CAST));
+ expectedProblemAttributes.put("MisplacedTypeAnnotations", SKIP);
expectedProblemAttributes.put("MissingArgumentsForParameterizedMemberType", SKIP);
expectedProblemAttributes.put("MissingDefaultCase", new ProblemAttributes(JavaCore.COMPILER_PB_SWITCH_MISSING_DEFAULT_CASE));
expectedProblemAttributes.put("MissingEnclosingInstance", SKIP);
@@ -1558,6 +1618,8 @@
expectedProblemAttributes.put("NotVisibleMethod", SKIP);
expectedProblemAttributes.put("NotVisibleType", SKIP);
expectedProblemAttributes.put("NullableFieldReference", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_REFERENCE));
+ expectedProblemAttributes.put("NullityMismatchingTypeAnnotation", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
+ expectedProblemAttributes.put("NullityMismatchingTypeAnnotationUnchecked", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION));
expectedProblemAttributes.put("NullLocalVariableComparisonYieldsFalse", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
expectedProblemAttributes.put("NullLocalVariableInstanceofYieldsFalse", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
expectedProblemAttributes.put("NullLocalVariableReference", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_REFERENCE));
@@ -1658,6 +1720,7 @@
expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT));
expectedProblemAttributes.put("SwitchOnEnumNotBelow15", SKIP);
expectedProblemAttributes.put("SwitchOnStringsNotBelow17", SKIP);
+ expectedProblemAttributes.put("TargetTypeNotAFunctionalInterface", SKIP);
expectedProblemAttributes.put("Task", SKIP);
expectedProblemAttributes.put("ThisInStaticContext", SKIP);
expectedProblemAttributes.put("ThisSuperDuringConstructorInvocation", SKIP);
@@ -1757,6 +1820,7 @@
expectedProblemAttributes.put("WildcardConstructorInvocation", SKIP);
expectedProblemAttributes.put("WildcardFieldAssignment", SKIP);
expectedProblemAttributes.put("WildcardMethodInvocation", SKIP);
+ expectedProblemAttributes.put("DisallowedExplicitThisParameter", SKIP);
expectedProblemAttributes.put("IllegalArrayOfUnionType", SKIP);
//{ObjectTeams: new constants:
expectedProblemAttributes.put("OTJ_RELATED", SKIP);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java
index 4a2bab6..38436e0 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java
@@ -2966,7 +2966,7 @@
"The argument of type null should explicitly be cast to Class[] for the invocation of the varargs method getMethod(String, Class...) from type Class. It could alternatively be cast to Class for a varargs invocation\n" +
"----------\n";
String javaVersion = System.getProperty("java.version");
- if (isJRELevel(AbstractCompilerTest.F_1_6|AbstractCompilerTest.F_1_7)
+ if (isJRELevel(AbstractCompilerTest.F_1_6|AbstractCompilerTest.F_1_7|AbstractCompilerTest.F_1_8)
|| (AbstractCompilerTest.getPossibleComplianceLevels() == AbstractCompilerTest.F_1_5
&& javaVersion.indexOf("1.5") == -1)) {
errorMessage =
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultMethodsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultMethodsTest.java
new file mode 100644
index 0000000..a41fe88
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultMethodsTest.java
@@ -0,0 +1,728 @@
+/*******************************************************************************
+ * Copyright (c) 2013 GK Software AG, IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * Stephan Herrmann - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import junit.framework.Test;
+
+// See https://bugs.eclipse.org/380501
+// Bug 380501 - [1.8][compiler] Add support for default methods (JSR 335)
+public class DefaultMethodsTest extends AbstractComparableTest {
+
+// Static initializer to specify tests subset using TESTS_* static variables
+// All specified tests which do not belong to the class are skipped...
+ static {
+// TESTS_NAMES = new String[] { "testInheritedDefaultOverrides" };
+// TESTS_NUMBERS = new int[] { 561 };
+// TESTS_RANGE = new int[] { 1, 2049 };
+ }
+
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+ }
+
+ public static Class testClass() {
+ return DefaultMethodsTest.class;
+ }
+
+ public DefaultMethodsTest(String name) {
+ super(name);
+ }
+
+ // default methods with various modifiers, positive cases
+ public void testModifiers1() {
+// Inject an unrelated compile error to prevent class file verification. TODO revert
+// (even lambda-enabled JRE doesn't accept now-legal modifier combinations)
+// runConformTest(
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "import java.lang.annotation.*;\n" +
+ "@Target(ElementType.METHOD) @interface Annot{}\n" +
+ "public interface I {\n" +
+ " void foo1() default {}\n" +
+ " public synchronized void foo2() default { System.exit(0); }\n" +
+ " strictfp void foo3() default {}\n" +
+ " public strictfp synchronized void foo4() default {}\n" +
+ " public strictfp synchronized @Annot void foo5() default {}\n" +
+ "}\n" +
+ "public class Wrong{}\n"}, // TODO remove me
+ // TODO remove me:
+ "----------\n" +
+ "1. ERROR in I.java (at line 10)\n" +
+ " public class Wrong{}\n" +
+ " ^^^^^\n" +
+ "The public type Wrong must be defined in its own file\n" +
+ "----------\n");
+ }
+
+ // default methods with various modifiers, simple syntax error blows the parser
+ public void _testModifiers1a() {
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "import java.lang.annotation.*;\n" +
+ "@Target(ElementType.METHOD) @interface Annot{}\n" +
+ "public interface I {\n" +
+ " void foo1() default {}\n" +
+ " public synchronized void foo2() default {}\n" +
+ " stritfp void foo3() default {}\n" + // typo in strictfp
+ " public strictfp synchronized void foo4() default {}\n" +
+ " public strictfp synchronized @Annot void foo5() default {}\n" +
+ "}\n"},
+ "Some nice and few syntax errors - TODO -");
+ }
+
+ // regular interface with illegal modifiers
+ public void testModifiers2() {
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "import java.lang.annotation.*;\n" +
+ "@Target(ElementType.METHOD) @interface Annot{}\n" +
+ "public interface I {\n" +
+ " void foo1();\n" +
+ " public synchronized void foo2();\n" +
+ " strictfp void foo3();\n" +
+ " public strictfp synchronized void foo4();\n" +
+ " public strictfp synchronized @Annot void foo5();\n" +
+ "}\n"},
+ "----------\n" +
+ "1. ERROR in I.java (at line 5)\n" +
+ " public synchronized void foo2();\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo2; only public & abstract are permitted\n" +
+ "----------\n" +
+ "2. ERROR in I.java (at line 6)\n" +
+ " strictfp void foo3();\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo3; only public & abstract are permitted\n" +
+ "----------\n" +
+ "3. ERROR in I.java (at line 7)\n" +
+ " public strictfp synchronized void foo4();\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo4; only public & abstract are permitted\n" +
+ "----------\n" +
+ "4. ERROR in I.java (at line 8)\n" +
+ " public strictfp synchronized @Annot void foo5();\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo5; only public & abstract are permitted\n" +
+ "----------\n");
+ }
+
+ // default & regular methods with modifiers that are illegal even for default methods
+ public void testModifiers3() {
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "public interface I {\n" +
+ " native void foo1();\n" +
+ " static void foo2();\n" +
+ " native void foo3() default {}\n" +
+ " static void foo4() default {}\n" +
+ "}\n"},
+ "----------\n" +
+ "1. ERROR in I.java (at line 2)\n" +
+ " native void foo1();\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo1; only public & abstract are permitted\n" +
+ "----------\n" +
+ "2. ERROR in I.java (at line 3)\n" +
+ " static void foo2();\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo2; only public & abstract are permitted\n" +
+ "----------\n" +
+ "3. ERROR in I.java (at line 4)\n" +
+ " native void foo3() default {}\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo3; only public, abstract, strictfp & synchronized are permitted\n" +
+ "----------\n" +
+ "4. ERROR in I.java (at line 5)\n" +
+ " static void foo4() default {}\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo4; only public, abstract, strictfp & synchronized are permitted\n" +
+ "----------\n");
+ }
+
+ // if an interface methods is explicitly "abstract" it cannot have a (default) body
+ public void testModifiers4() {
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "import java.lang.annotation.*;\n" +
+ "public interface I {\n" +
+ " abstract void foo1();\n" + // OK
+ " public abstract void foo2() default {}\n" +
+ " abstract void foo3() default {}\n" +
+ " void foo4() { }\n" + // implicit "abstract" without "default" doesn't allow a body, either
+ " abstract static void foo5() default {}\n" + // double fault
+ "}\n"},
+ "----------\n" +
+ "1. ERROR in I.java (at line 4)\n" +
+ " public abstract void foo2() default {}\n" +
+ " ^^^^^^\n" +
+ "Abstract methods do not specify a body\n" +
+ "----------\n" +
+ "2. ERROR in I.java (at line 5)\n" +
+ " abstract void foo3() default {}\n" +
+ " ^^^^^^\n" +
+ "Abstract methods do not specify a body\n" +
+ "----------\n" +
+ "3. ERROR in I.java (at line 6)\n" +
+ " void foo4() { }\n" +
+ " ^^^^^^\n" +
+ "Abstract methods do not specify a body\n" +
+ "----------\n" +
+ "4. ERROR in I.java (at line 7)\n" +
+ " abstract static void foo5() default {}\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo5; only public, abstract, strictfp & synchronized are permitted\n" +
+ "----------\n" +
+ "5. ERROR in I.java (at line 7)\n" +
+ " abstract static void foo5() default {}\n" +
+ " ^^^^^^\n" +
+ "Abstract methods do not specify a body\n" +
+ "----------\n");
+ }
+
+ // class implements interface with default method.
+ // - no need to implement this interface method as it is not abstract
+ public void testModifiers5() {
+ runConformTest(
+ new String[] {
+ "C.java",
+ "public class C implements I {\n" +
+ " public static void main(String[] args) {\n" +
+ " new C().foo();\n" +
+ " }\n" +
+ "}\n",
+ "I.java",
+ "public interface I {\n" +
+ " void foo() default {\n" +
+ " System.out.println(\"default\");\n" +
+ " }\n" +
+ "}\n"
+ },
+ "default"
+ );
+ }
+
+ // class implements interface with default method.
+ // - no need to implement this interface method as it is not abstract, but other abstract method exists
+ public void testModifiers6() {
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "public interface I {\n" +
+ " void foo() default {}\n" +
+ " void bar();\n" +
+ "}\n",
+ "C.java",
+ "public class C implements I {}\n"
+ },
+ "----------\n" +
+ "1. ERROR in C.java (at line 1)\n" +
+ " public class C implements I {}\n" +
+ " ^\n" +
+ "The type C must implement the inherited abstract method I.bar()\n" +
+ "----------\n");
+ }
+
+ // JLS 9.4.2 - default method cannot override method from Object
+ // Bug 382355 - [1.8][compiler] Compiler accepts erroneous default method
+ // new error message
+ public void testObjectMethod1() {
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "public interface I {\n" +
+ " public String toString () default { return \"\";}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in I.java (at line 2)\n" +
+ " public String toString () default { return \"\";}\n" +
+ " ^^^^^^^^^^^\n" +
+ "A default method cannot override a method from java.lang.Object \n" +
+ "----------\n");
+ }
+
+ // JLS 9.4.2 - default method cannot override method from Object
+ // Bug 382355 - [1.8][compiler] Compiler accepts erroneous default method
+ // when using a type variable this is already reported as a name clash
+ public void testObjectMethod2() {
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "public interface I<T> {\n" +
+ " public boolean equals (T other) default { return false;}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in I.java (at line 2)\n" +
+ " public boolean equals (T other) default { return false;}\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Name clash: The method equals(T) of type I<T> has the same erasure as equals(Object) of type Object but does not override it\n" +
+ "----------\n");
+ }
+
+ // JLS 9.4.2 - default method cannot override method from Object
+ // Bug 382355 - [1.8][compiler] Compiler accepts erroneous default method
+ // one error for final method is enough
+ public void testObjectMethod3() {
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "public interface I<T> {\n" +
+ " @Override\n" +
+ " public Class<?> getClass() default { return null;}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in I.java (at line 3)\n" +
+ " public Class<?> getClass() default { return null;}\n" +
+ " ^^^^^^^^^^\n" +
+ "Cannot override the final method from Object\n" +
+ "----------\n");
+ }
+
+ // JLS 9.4.1
+ // Bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
+ // an inherited default methods clashes with another inherited method
+ // simple case
+ public void testInheritedDefaultOverrides01() {
+ runNegativeTest(
+ new String[] {
+ "I1.java",
+ "public interface I1 {\n" +
+ " String foo();\n" +
+ "}\n",
+ "I2.java",
+ "public interface I2 {\n" +
+ " String foo() default { return \"\"; }\n" +
+ "}\n",
+ "I3.java",
+ "public interface I3 extends I1, I2 {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in I3.java (at line 1)\n" +
+ " public interface I3 extends I1, I2 {\n" +
+ " ^^\n" +
+ "The default method foo() inherited from I2 conflicts with another method inherited from I1\n" +
+ "----------\n");
+ }
+
+ // JLS 9.4.1
+ // Bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
+ // an inherited default methods clashes with another inherited method
+ // indirect inheritance
+ public void testInheritedDefaultOverrides02() {
+ runNegativeTest(
+ new String[] {
+ "I1.java",
+ "public interface I1 {\n" +
+ " String foo();\n" +
+ "}\n",
+ "I2.java",
+ "public interface I2 {\n" +
+ " String foo() default { return \"\"; }\n" +
+ "}\n",
+ "I1A.java",
+ "public interface I1A extends I1 {\n" +
+ "}\n",
+ "I2A.java",
+ "public interface I2A extends I2 {\n" +
+ "}\n",
+ "I3.java",
+ "public interface I3 extends I1A, I2A {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in I3.java (at line 1)\n" +
+ " public interface I3 extends I1A, I2A {\n" +
+ " ^^\n" +
+ "The default method foo() inherited from I2 conflicts with another method inherited from I1\n" +
+ "----------\n");
+ }
+
+ // JLS 9.4.1
+ // Bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
+ // Parameterized case is already reported as a clash
+ public void testInheritedDefaultOverrides03() {
+ runNegativeTest(
+ new String[] {
+ "I1.java",
+ "import java.util.List;\n" +
+ "public interface I1 {\n" +
+ " String foo(List<String> l);\n" +
+ "}\n",
+ "I2.java",
+ "import java.util.List;\n" +
+ "public interface I2 {\n" +
+ " @SuppressWarnings(\"rawtypes\")\n" +
+ " String foo(List l) default { return \"\"; }\n" +
+ "}\n",
+ "I3.java",
+ "import java.util.List;\n" +
+ "public interface I3 extends I1, I2 {\n" +
+ " @Override\n" +
+ " String foo(List<String> l);\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in I3.java (at line 4)\n" +
+ " String foo(List<String> l);\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "Name clash: The method foo(List<String>) of type I3 has the same erasure as foo(List) of type I2 but does not override it\n" +
+ "----------\n");
+ }
+
+ // JLS 9.4.1
+ // Bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
+ // Parameterized case is already reported as a clash - inverse case of previous
+ public void testInheritedDefaultOverrides04() {
+ runNegativeTest(
+ new String[] {
+ "I1.java",
+ "import java.util.List;\n" +
+ "public interface I1 {\n" +
+ " String foo(List<String> l) default { return \"\"; }\n" +
+ "}\n",
+ "I2.java",
+ "import java.util.List;\n" +
+ "public interface I2 {\n" +
+ " @SuppressWarnings(\"rawtypes\")\n" +
+ " String foo(List l);\n" +
+ "}\n",
+ "I3.java",
+ "import java.util.List;\n" +
+ "public interface I3 extends I1, I2 {\n" +
+ " @Override\n" +
+ " String foo(List<String> l);\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in I3.java (at line 4)\n" +
+ " String foo(List<String> l);\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "Name clash: The method foo(List<String>) of type I3 has the same erasure as foo(List) of type I2 but does not override it\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=390761
+ public void testDefaultNonclash() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public interface X extends Map<String, Object> {\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "\n" +
+ "interface Map<K,V> extends MapStream<K, V> {\n" +
+ " @Override\n" +
+ " Iterable<BiValue<K, V>> asIterable() default {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "interface MapStream<K, V> {\n" +
+ " Iterable<BiValue<K, V>> asIterable();\n" +
+ "}\n" +
+ "\n" +
+ "interface BiValue<T, U> {\n" +
+ " T getKey();\n" +
+ " U getValue();\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=390761
+ public void testDefaultNonclash2() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public interface X extends Map<String, Object> {\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "\n" +
+ "interface Map<K,V> extends MapStream<K, V> {\n" +
+ " @Override\n" +
+ " Iterable<BiValue<K, V>> asIterable();\n" +
+ "}\n" +
+ "interface MapStream<K, V> {\n" +
+ " Iterable<BiValue<K, V>> asIterable() default {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "interface BiValue<T, U> {\n" +
+ " T getKey();\n" +
+ " U getValue();\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+
+ public void testDefaultNonclash3() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public interface X extends Map<String, Object> {\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "\n" +
+ "interface Map<K,V> extends MapStream<K, V> {\n" +
+ " @Override\n" +
+ " Iterable<BiValue<K, V>> asIterable() default {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "interface MapStream<K, V> {\n" +
+ " Iterable<BiValue<K, V>> asIterable() default {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "interface BiValue<T, U> {\n" +
+ " T getKey();\n" +
+ " U getValue();\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=390761
+ public void testDefaultNonclash4() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public interface X extends Map<String, Object> {\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "\n" +
+ "interface Map<K,V> extends MapStream<K, V> {\n" +
+ " @Override\n" +
+ " Iterable<BiValue<K, V>> asIterable();\n" +
+ "}\n" +
+ "interface MapStream<K, V> {\n" +
+ " Iterable<BiValue<K, V>> asIterable();\n" +
+ "}\n" +
+ "\n" +
+ "interface BiValue<T, U> {\n" +
+ " T getKey();\n" +
+ " U getValue();\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+
+ // JLS 9.4.1
+ // Bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
+ // Don't report conflict between the same method inherited on two paths.
+ public void testInheritedDefaultOverrides05() {
+ runConformTest(
+ new String[] {
+ "StringList.java",
+ "import java.util.Collection;\n" +
+ "public abstract class StringList implements Collection<String> {\n" +
+ "}\n"
+ },
+ "");
+ }
+
+ // JLS 9.4.1
+ // Bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
+ // extract from SuperTypeTest.test013():
+ public void testInheritedDefaultOverrides06() {
+ runConformTest(
+ new String[] {
+ "IterableList.java",
+ "import java.util.*;\n" +
+ "public interface IterableList<E> extends Iterable<E>, List<E> {}\n" +
+ "interface ListIterable<E> extends Iterable<E>, List<E> {}\n" +
+ "\n"
+ },
+ "");
+ }
+
+ // JLS 8.1.1.1 abstract Classes
+ // Default method overrides an abstract method from its super interface
+ public void testAbstract01() {
+ runConformTest(
+ new String[] {
+ "I2.java",
+ "public interface I2 {\n" +
+ " void test();\n" +
+ "}\n",
+ "I1.java",
+ "public interface I1 extends I2 {\n" +
+ " void test() default {}\n" +
+ "}\n",
+ "C.java",
+ "public class C implements I1 {\n" +
+ "}\n"
+ });
+ }
+
+ // JLS 8.1.1.1 abstract Classes
+ // Default method overrides independent abstract method
+ public void testAbstract02() {
+ runConformTest(
+ new String[] {
+ "I1.java",
+ "public interface I1 {\n" +
+ " void test();\n" +
+ "}\n",
+ "I2.java",
+ "public interface I2 {\n" +
+ " void test() default {}\n" +
+ "}\n",
+ "C.java",
+ "public class C implements I1, I2 {\n" +
+ "}\n"
+ });
+ }
+
+ // JLS 8.1.1.1 abstract Classes
+ // Default method overrides independent abstract method
+ // same as above except for order of implements list
+ public void testAbstract02a() {
+ runConformTest(
+ new String[] {
+ "I1.java",
+ "public interface I1 {\n" +
+ " void test();\n" +
+ "}\n",
+ "I2.java",
+ "public interface I2 {\n" +
+ " void test() default {}\n" +
+ "}\n",
+ "C.java",
+ "public class C implements I2, I1 {\n" +
+ "}\n"
+ });
+ }
+
+ // JLS 8.1.1.1 abstract Classes
+ // Default method overrides an abstract method from its super interface - class implements both
+ public void testAbstract03() {
+ runConformTest(
+ new String[] {
+ "I1.java",
+ "public interface I1 {\n" +
+ " void test();\n" +
+ "}\n",
+ "I2.java",
+ "public interface I2 extends I1 {\n" +
+ " @Override\n" +
+ " void test() default {}\n" +
+ "}\n",
+ "C.java",
+ "public class C implements I1, I2 {\n" +
+ "}\n"
+ });
+ }
+
+ // JLS 8.1.1.1 abstract Classes
+ // Default method overrides an abstract method from its super interface - class implements both
+ // same as above except for order of implements list
+ public void testAbstract03a() {
+ runConformTest(
+ new String[] {
+ "I1.java",
+ "public interface I1 {\n" +
+ " void test();\n" +
+ "}\n",
+ "I2.java",
+ "public interface I2 extends I1 {\n" +
+ " @Override\n" +
+ " void test() default {}\n" +
+ "}\n",
+ "C.java",
+ "public class C implements I2, I1 {\n" +
+ "}\n"
+ });
+ }
+
+ // JLS 8.1.1.1 abstract Classes
+ // default method is not inherited because a more specific abstract method is.
+ public void testAbstract04() {
+ runNegativeTest(
+ new String[] {
+ "I1.java",
+ "public interface I1 {\n" +
+ " void test() default {}\n" +
+ "}\n",
+ "I2.java",
+ "public interface I2 extends I1 {\n" +
+ " @Override\n" +
+ " void test();\n" +
+ "}\n",
+ "C.java",
+ "public class C implements I2, I1 {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in C.java (at line 1)\n" +
+ " public class C implements I2, I1 {\n" +
+ " ^\n" +
+ "The type C must implement the inherited abstract method I2.test()\n" +
+ "----------\n");
+ }
+
+ // JLS 8.1.1.1 abstract Classes
+ // default method is not inherited because a more specific abstract method is.
+ // same as above except for order of implements list
+ public void testAbstract04a() {
+ runNegativeTest(
+ new String[] {
+ "I1.java",
+ "public interface I1 {\n" +
+ " void test() default {}\n" +
+ "}\n",
+ "I2.java",
+ "public interface I2 extends I1 {\n" +
+ " @Override\n" +
+ " void test();\n" +
+ "}\n",
+ "C.java",
+ "public class C implements I2, I1 {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in C.java (at line 1)\n" +
+ " public class C implements I2, I1 {\n" +
+ " ^\n" +
+ "The type C must implement the inherited abstract method I2.test()\n" +
+ "----------\n");
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
index b6cb60c..aa2bf5b 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
@@ -5,12 +5,17 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contributions for
* Bug 365519 - editorial cleanup after bug 186342 and bug 365387
* Bug 265744 - Enum switch should warn about missing default
* Bug 374605 - Unreasonable warning for enum-based switch statements
+ * bug 388739 - [1.8][compiler] consider default methods when detecting whether a class needs to be declared abstract
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -3007,7 +3012,7 @@
"1. ERROR in X.java (at line 1)\n" +
" public enum X implements I, J { \n" +
" ^\n" +
- "The type X must implement the inherited abstract method I.foo()\n" +
+ "The type X must implement the inherited abstract method J.foo()\n" +
"----------\n");
this.runNegativeTest(
new String[] {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
index 4c1edd5..3f4ff0d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
@@ -1,14 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contribution for
* bug 393719 - [compiler] inconsistent warnings on iteration variables
+ * Bug 388800 - [1.8] adjust tests to 1.8 JRE
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -1103,6 +1108,7 @@
" public Iterator<String> iterator() {\n" +
" return null;\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}\n",
},
"----------\n" +
@@ -1625,11 +1631,13 @@
" }\n" +
" public void remove() {\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "T") +
"}\n" +
"class Bar implements Iterable<String> {\n" +
" public Iterator<String> iterator() {\n" +
" return new ArrayIterator<String>(new String[]{\"a\",\"b\"});\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}\n",
},
"ab");
@@ -1718,6 +1726,7 @@
" }\n" +
" public void remove() {\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "T") +
"}\n" +
"interface IFoo extends Iterable<String> {\n" +
"}\n" +
@@ -1725,6 +1734,7 @@
" public Iterator<String> iterator() {\n" +
" return new ArrayIterator<String>(new String[]{\"a\",\"b\"});\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}\n",
},
"ab");
@@ -1800,6 +1810,7 @@
" X x = new X();\n" +
" x.foo(x);\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}",
},
"ab");
@@ -2013,6 +2024,7 @@
" System.out.println(\"remove\");\n" +
" this.iterator.remove();\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "T") +
" }\n" +
" \n" +
" static Set<Object> initForEach() {\n" +
@@ -2109,6 +2121,7 @@
" System.out.println(\"remove\");\n" +
" this.iterator.remove();\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "T") +
" }\n" +
" \n" +
" static Set<Object> initForEach() {\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
index 7a2739e..c3005a2 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
@@ -1,16 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Technical University Berlin - adapted for Object Teams
* Stephan Herrmann - Contributions for
* bug 383690 - [compiler] location of error re uninitialized final field should be aligned
+ * bug 388800 - [1.8] adjust tests to 1.8 JRE
* bug 388795 - [compiler] detection of name clash depends on order of super interfaces
+ * bug 388739 - [1.8][compiler] consider default methods when detecting whether a class needs to be declared abstract
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -1624,42 +1631,41 @@
"}\n"
},
"----------\n" +
- "1. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^\n" +
- "Syntax error on token \"int\", Dimensions expected after this token\n" +
- "----------\n" +
- "2. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^^\n" +
- "Syntax error on token \"short\", Dimensions expected after this token\n" +
- "----------\n" +
- "3. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^\n" +
- "Syntax error on token \"long\", Dimensions expected after this token\n" +
- "----------\n" +
- "4. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^^\n" +
- "Syntax error on token \"float\", Dimensions expected after this token\n" +
- "----------\n" +
- "5. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^^^\n" +
- "Syntax error on token \"double\", Dimensions expected after this token\n" +
- "----------\n" +
- "6. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^^^^\n" +
- "Syntax error on token \"boolean\", Dimensions expected after this token\n" +
- "----------\n" +
- "7. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^\n" +
- "Syntax error on token \"char\", Dimensions expected after this token\n" +
- "----------\n"
- );
+ "1. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "2. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "3. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "4. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "5. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "6. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "7. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete ReferenceType\n" +
+ "----------\n");
}
// JSR14-v10[2.1,2.2]: Valid multiple parameter types: primitive type arrays
public void test0062() {
@@ -1871,7 +1877,7 @@
// JSR14-V10[2.4]: Not terminated consecutive declaration
// TODO (david) diagnosis message on error 3 sounds strange, doesn't it?
- public void test0068() {
+ public void _test0068() {
this.runNegativeTest(
new String[] {
"test/X1.java",
@@ -1943,8 +1949,14 @@
"----------\n" +
"1. ERROR in test\\X1.java (at line 3)\n" +
" public class X1<A1>> {\n" +
+//{ObjectTeams: our diagnose parser suggests a different correction:
+/* orig:
" ^^\n" +
"Syntax error on token \">>\", > expected\n" +
+ :giro */
+ " ^^\n" +
+ "Syntax error, insert \"< typeAnchor\" to complete AnchoredTypeParameter\n" +
+// SH}
"----------\n"
);
}
@@ -2316,7 +2328,7 @@
);
}
// TODO (david) remove errors: insert dimension to complete array type
- public void test0080() {
+ public void _test0080() {
this.runNegativeTest(
new String[] {
"test/X.java",
@@ -2403,7 +2415,7 @@
);
}
// TODO (david) remove error: insert dimension to complete array type
- public void test0083() {
+ public void _test0083() {
this.runNegativeTest(
new String[] {
"test/X.java",
@@ -2945,12 +2957,13 @@
"class AX<P> {\n" +
"}\n",
},
- "----------\n" +
- "1. ERROR in X.java (at line 1)\n" +
- " public class X <T extends AX<? super int>> {\n" +
- " ^^^\n" +
- "Syntax error on token \"int\", Dimensions expected after this token\n" +
- "----------\n");
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X <T extends AX<? super int>> {\n" +
+ " ^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete ArrayType\n" +
+ "----------\n"
+);
}
// type parameterized with wildcard cannot appear in allocation
@@ -4430,6 +4443,9 @@
" }\n" +
" public int size() { return 0; }\n" +
" public Object get(int index) { return null; }\n" +
+ ITERABLE_RAW_IMPL_JRE8 +
+ COLLECTION_RAW_IMPL_JRE8 +
+ LIST_RAW_IMPL_JRE8 +
"}\n"
},
"SUCCESS");
@@ -6139,6 +6155,7 @@
" public int compare(X x1, X x2) {\n" +
" return comparator.compare(function.eval(x1),function.eval(x2));\n" +
" }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
"}\n",
},
"");
@@ -8839,6 +8856,7 @@
" public Set<Map.Entry<String, V>> entrySet() {\n" +
" return this.backingMap.entrySet();\n" +
" }\n" +
+ MAP_IMPL_JRE8.replaceAll("\\*", "String").replaceAll("\\%", "V")+
"}\n",
},
"----------\n" +
@@ -10798,9 +10816,12 @@
" public boolean hasNext() {return false;}\n" +
" public Entry<String, Integer> next() {return null;}\n" +
" public void remove() {} \n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "Entry<String,Integer>") +
" };\n" +
" }\n" +
" public int size() {return 0;}\n" +
+ COLLECTION_RAW_IMPL_JRE8 +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "Entry<String,Integer>") +
"}"
}
);
@@ -11372,6 +11393,8 @@
" }\n" +
" public Iterator<Runnable> iterator() {return null;}\n" +
" public int size() {return 0;}\n" +
+ COLLECTION_RAW_IMPL_JRE8 +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "Runnable") +
"}"
}
);
@@ -13551,6 +13574,7 @@
" public boolean hasNext() { return false; }\n" +
" public String next() { return null; }\n" +
" public void remove() {}\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "String") +
"}\n",
},
"");
@@ -19888,6 +19912,7 @@
" }\n" +
" public void remove() {\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "U") +
" }\n" +
" }\n" +
"}\n",
@@ -24898,6 +24923,9 @@
" List<String> list = new AbstractList<String>() {\n" +
" @Override public int size() { return 0; }\n" +
" @Override public String get(int i) { return args.get(i); }\n" +
+ COLLECTION_IMPL_JRE8.replaceAll("\\*", "String") +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
+ LIST_IMPL_JRE8.replaceAll("\\*", "String") +
" };\n" +
" }\n" +
" }\n" +
@@ -24909,13 +24937,14 @@
},
"SUCCESS");
+ String constantPoolIdx = IS_JRE_8 ? "67" : "36"; // depends on whether or not stubs for JRE8 default methods are included
String expectedOutput =
" // Method descriptor #31 (I)Ljava/lang/Object;\n" +
" // Stack: 2, Locals: 2\n" +
" public bridge synthetic java.lang.Object get(int arg0);\n" +
" 0 aload_0 [this]\n" +
" 1 iload_1 [arg0]\n" +
- " 2 invokevirtual X$Entry$1.get(int) : java.lang.String [36]\n" +
+ " 2 invokevirtual X$Entry$1.get(int) : java.lang.String ["+constantPoolIdx+"]\n" +
" 5 areturn\n" +
" Line numbers:\n" +
" [pc: 0, line: 1]\n";
@@ -25862,6 +25891,7 @@
" }\n" +
" public void remove() {\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "N") +
"}\n" +
"interface Set3<N extends Node> extends Iterable<N> {\n" +
" SetIterator<N> iterator();\n" +
@@ -25893,27 +25923,27 @@
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 21)\n" +
+ "1. WARNING in X.java (at line 22)\n" +
" void f1(Set1 s) {\n" +
" ^^^^\n" +
"Set1 is a raw type. References to generic type Set1<N> should be parameterized\n" +
"----------\n" +
- "2. ERROR in X.java (at line 22)\n" +
+ "2. ERROR in X.java (at line 23)\n" +
" Node n_ = s.iterator().next();\n" +
" ^^^^^^^^^^^^^^^^^^^\n" +
"Type mismatch: cannot convert from Object to Node\n" +
"----------\n" +
- "3. ERROR in X.java (at line 25)\n" +
+ "3. ERROR in X.java (at line 26)\n" +
" for (Node n : s) {\n" +
" ^\n" +
"Type mismatch: cannot convert from element type Object to Node\n" +
"----------\n" +
- "4. WARNING in X.java (at line 35)\n" +
+ "4. WARNING in X.java (at line 36)\n" +
" void f3(Set3 s) {\n" +
" ^^^^\n" +
"Set3 is a raw type. References to generic type Set3<N> should be parameterized\n" +
"----------\n" +
- "5. ERROR in X.java (at line 38)\n" +
+ "5. ERROR in X.java (at line 39)\n" +
" for (Node n : s) {\n" +
" ^\n" +
"Type mismatch: cannot convert from element type Object to Node\n" +
@@ -28017,6 +28047,8 @@
" // TODO Auto-generated method stub\n" +
" \n" +
" }" +
+ COLLECTION_RAW_IMPL_JRE8 +
+ ITERABLE_RAW_IMPL_JRE8 +
"}",
},
"",
@@ -30419,7 +30451,7 @@
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=119238 - variation
-public void test0932() {
+public void _test0932() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -32457,28 +32489,18 @@
public void test0987() {
String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
? "----------\n" +
- "1. ERROR in X.java (at line 7)\n" +
- " abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" +
- " ^^^^^^^^^^^^^^^^\n" +
- "The return types are incompatible for the inherited methods EditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 11)\n" +
+ "1. ERROR in X.java (at line 11)\n" +
" public ISheetViewer getViewer() { return null; } \n" +
" ^^^^^^^^^^^^\n" +
"The return type is incompatible with EditPart.getViewer()\n" +
"----------\n" +
- "3. ERROR in X.java (at line 11)\n" +
+ "2. ERROR in X.java (at line 11)\n" +
" public ISheetViewer getViewer() { return null; } \n" +
" ^^^^^^^^^^^\n" +
"The method getViewer() of type AbstractLinkView<M> must override a superclass method\n" +
"----------\n"
: "----------\n" +
- "1. ERROR in X.java (at line 7)\n" +
- " abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" +
- " ^^^^^^^^^^^^^^^^\n" +
- "The return types are incompatible for the inherited methods EditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 11)\n" +
+ "1. ERROR in X.java (at line 11)\n" +
" public ISheetViewer getViewer() { return null; } \n" +
" ^^^^^^^^^^^^\n" +
"The return type is incompatible with EditPart.getViewer()\n" +
@@ -32567,12 +32589,7 @@
"}", // =================
},
"----------\n" +
- "1. ERROR in X.java (at line 7)\n" +
- " abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" +
- " ^^^^^^^^^^^^^^^^\n" +
- "The return types are incompatible for the inherited methods EditPart.getViewer(), ILinkViewElement.getViewer(), AbstractLinkView<M>.getViewer()\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 11)\n" +
+ "1. ERROR in X.java (at line 11)\n" +
" public SheetViewer getViewer() { return null; } \n" +
" ^^^^^^^^^^^\n" +
"The return type is incompatible with AbstractEditPart.getViewer()\n" +
@@ -34169,6 +34186,7 @@
" public Iterator<W> iterator() {\n" +
" return theList.iterator();\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replace('*', 'W') +
" }\n" +
"\n" +
" private PointList<Waypoint> waypoints = new PointList<Waypoint>();\n" +
@@ -34413,6 +34431,7 @@
"public int compare(T obj1, T obj2) {\n" +
" return obj1.compareTo(obj2);\n" +
"}\n" +
+ COMPARATOR_IMPL_JRE8.replace('*', 'T').replace('%', 'U') +
"}\n" +
"\n" +
"@SuppressWarnings({\"unchecked\", \"rawtypes\"})\n" +
@@ -34463,6 +34482,7 @@
"public int compare(V obj1, V obj2) {\n" +
" return 0;\n" +
"}\n" +
+ COMPARATOR_IMPL_JRE8.replace('*', 'V').replace('%', 'U') +
"}", // =================
},
@@ -37457,7 +37477,7 @@
null/* do not perform statements recovery */);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=168232
-public void test1097() {
+public void _test1097() {
runNegativeTest(
// test directory preparation
new String[] { /* test files */
@@ -42812,7 +42832,7 @@
"4. ERROR in X.java (at line 13)\n" +
" public interface CombinedSubInterface extends SubInterface, OtherSubInterface {}\n" +
" ^^^^^^^^^^^^^^^^^^^^\n" +
- "The return types are incompatible for the inherited methods X.OtherSubInterface.and(X.SuperInterface), X.SubInterface.and(X.SuperInterface)\n" +
+ "The return types are incompatible for the inherited methods X.SubInterface.and(X.SuperInterface), X.OtherSubInterface.and(X.SuperInterface)\n" +
"----------\n" +
"5. WARNING in X.java (at line 15)\n" +
" public interface OtherSubInterface extends SuperInterface {\n" +
@@ -49726,6 +49746,7 @@
" public boolean hasNext() {\n" +
" return false;\n" +
" }\n" +
+ ITERATOR_RAW_IMPL_JRE8 +
" };\n" +
" }\n" +
" Zork z;\n" +
@@ -49757,7 +49778,7 @@
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Unnecessary cast from Iterator to Iterator<String>\n" +
"----------\n" +
- "6. ERROR in X.java (at line 36)\n" +
+ "6. ERROR in X.java (at line 37)\n" +
" Zork z;\n" +
" ^^^^\n" +
"Zork cannot be resolved to a type\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GrammarCoverageTests308.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GrammarCoverageTests308.java
new file mode 100644
index 0000000..1e7bf37
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GrammarCoverageTests308.java
@@ -0,0 +1,1575 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Stephan Herrmann - Contribution for
+ * bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import junit.framework.Test;
+
+public class GrammarCoverageTests308 extends AbstractRegressionTest {
+
+ static {
+// TESTS_NUMBERS = new int [] { 35 };
+// TESTS_NAMES = new String [] { "testnew" };
+ }
+ public static Class testClass() {
+ return GrammarCoverageTests308.class;
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+ }
+ public GrammarCoverageTests308(String testName){
+ super(testName);
+ }
+ // Lone test to verify that multiple annotations of all three kinds are accepted. All other tests will use only marker annotations
+ public void test000() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X extends @Marker @SingleMember(0) @Normal(Value = 0) Object {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends @Marker @SingleMember(0) @Normal(Value = 0) Object {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X extends @Marker @SingleMember(0) @Normal(Value = 0) Object {\n" +
+ " ^^^^^^^^^^^^\n" +
+ "SingleMember cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public class X extends @Marker @SingleMember(0) @Normal(Value = 0) Object {\n" +
+ " ^^^^^^\n" +
+ "Normal cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
+ public void test001() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @Marker int x;\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " @Marker int x;\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // TYPE: MethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
+ public void test002() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @Marker <T> @Marker int x() { return 10; };\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " @Marker <T> @Marker int x() { return 10; };\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " @Marker <T> @Marker int x() { return 10; };\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // TYPE: MethodHeaderName ::= Modifiersopt Type 'Identifier' '('
+ public void test003() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @Marker int x() { return 10; };\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " @Marker int x() { return 10; };\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // FormalParameter ::= Modifiersopt Type VariableDeclaratorIdOrThis
+ public void test004() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x(@Marker int p) { return 10; };\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int x(@Marker int p) { return 10; };\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // FormalParameter ::= Modifiersopt Type PushZeroTypeAnnotations '...' VariableDeclaratorIdOrThis
+ public void test005() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x(@Marker int ... p) { return 10; };\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int x(@Marker int ... p) { return 10; };\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // FormalParameter ::= Modifiersopt Type @308... TypeAnnotations '...' VariableDeclaratorIdOrThis
+ public void test006() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x(@Marker int [] @Marker ... p) { return 10; };\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int x(@Marker int [] @Marker ... p) { return 10; };\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " int x(@Marker int [] @Marker ... p) { return 10; };\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // UnionType ::= Type
+ // UnionType ::= UnionType '|' Type
+ public void test007() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x() {\n" +
+ " try {\n" +
+ " } catch (@Marker NullPointerException | @Marker ArrayIndexOutOfBoundsException e) {\n" +
+ " }\n" +
+ " return 10;\n" +
+ " }\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " } catch (@Marker NullPointerException | @Marker ArrayIndexOutOfBoundsException e) {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " } catch (@Marker NullPointerException | @Marker ArrayIndexOutOfBoundsException e) {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 8)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators
+ // LocalVariableDeclaration ::= Modifiers Type PushRealModifiers VariableDeclarators
+ public void test008() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x() {\n" +
+ " @Marker int p;\n" +
+ " final @Marker int q;\n" +
+ " @Marker final int r;\n" +
+ " return 10;\n" +
+ " }\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " @Marker int p;\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " final @Marker int q;\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " @Marker final int r;\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 8)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // Resource ::= Type PushModifiers VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
+ // Resource ::= Modifiers Type PushRealModifiers VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
+ public void test009() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x() {\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " }\n" +
+ " return 10;\n" +
+ " }\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The resource type Integer does not implement java.lang.AutoCloseable\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The resource type Integer does not implement java.lang.AutoCloseable\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The resource type Integer does not implement java.lang.AutoCloseable\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 7)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // EnhancedForStatementHeaderInit ::= 'for' '(' Type PushModifiers Identifier Dimsopt
+ // EnhancedForStatementHeaderInit ::= 'for' '(' Modifiers Type PushRealModifiers Identifier Dimsopt
+ public void test010() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x() {\n" +
+ " for (@Marker int i: new int[3]) {}\n" +
+ " for (final @Marker int i: new int[3]) {}\n" +
+ " for (@Marker final int i: new int[3]) {}\n" +
+ " return 10;\n" +
+ " }\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " for (@Marker int i: new int[3]) {}\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " for (final @Marker int i: new int[3]) {}\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " for (@Marker final int i: new int[3]) {}\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 8)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // AnnotationMethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
+ // AnnotationMethodHeaderName ::= Modifiersopt Type 'Identifier' '('
+ public void test011() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public @interface X { \n" +
+ " public @Marker String value(); \n" +
+ " @Marker String value2(); \n" +
+ " @Marker public String value3(); \n" +
+ " public @Marker <T> @Marker String value4(); \n" +
+ " @Marker <T> @Marker String value5(); \n" +
+ " @Marker public <T> @Marker String value6(); \n" +
+ "}\n" +
+
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public @Marker String value(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " @Marker String value2(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " @Marker public String value3(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 5)\n" +
+ " public @Marker <T> @Marker String value4(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 5)\n" +
+ " public @Marker <T> @Marker String value4(); \n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 5)\n" +
+ " public @Marker <T> @Marker String value4(); \n" +
+ " ^^^^^^^^\n" +
+ "Annotation attributes cannot be generic\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 6)\n" +
+ " @Marker <T> @Marker String value5(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 6)\n" +
+ " @Marker <T> @Marker String value5(); \n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "9. ERROR in X.java (at line 6)\n" +
+ " @Marker <T> @Marker String value5(); \n" +
+ " ^^^^^^^^\n" +
+ "Annotation attributes cannot be generic\n" +
+ "----------\n" +
+ "10. ERROR in X.java (at line 7)\n" +
+ " @Marker public <T> @Marker String value6(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "11. ERROR in X.java (at line 7)\n" +
+ " @Marker public <T> @Marker String value6(); \n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "12. ERROR in X.java (at line 7)\n" +
+ " @Marker public <T> @Marker String value6(); \n" +
+ " ^^^^^^^^\n" +
+ "Annotation attributes cannot be generic\n" +
+ "----------\n");
+ }
+ // PrimaryNoNewArray ::= PrimitiveType Dims '.' 'class'
+ // PrimaryNoNewArray ::= PrimitiveType '.' 'class'
+ public void test012() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X { \n" +
+ " public void value() {\n" +
+ " Object o = @Marker int.class;\n" +
+ " Object o2 = @Marker int @Marker[] [] @Marker[].class;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " Object o = @Marker int.class;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Object o2 = @Marker int @Marker[] [] @Marker[].class;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " Object o2 = @Marker int @Marker[] [] @Marker[].class;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 4)\n" +
+ " Object o2 = @Marker int @Marker[] [] @Marker[].class;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n");
+ }
+ // ReferenceExpression ::= PrimitiveType Dims '::' NonWildTypeArgumentsopt IdentifierOrNew
+ public void test013() throws Exception { // WILL FAIL WHEN REFERENCE EXPRESSIONS ARE ANALYZED.
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " Object copy(int [] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = @Marker int @Marker []::<String>clone;\n" +
+ " Zork z;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
+ // ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
+ public void test014() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " int i [] = new @Marker int @Marker [4];\n" +
+ " int j [] = new @Marker int @Marker [] { 10 };\n" +
+ " Zork z;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " int i [] = new @Marker int @Marker [4];\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " int i [] = new @Marker int @Marker [4];\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " int j [] = new @Marker int @Marker [] { 10 };\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 4)\n" +
+ " int j [] = new @Marker int @Marker [] { 10 };\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 5)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN InsideCastExpression UnaryExpression
+ public void test015() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " int i = (@Marker int) 0;\n" +
+ " int j [] = (@Marker int @Marker []) null;\n" +
+ " Zork z;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " int i = (@Marker int) 0;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " int j [] = (@Marker int @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " int j [] = (@Marker int @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 5)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // InstanceofExpression ::= InstanceofExpression 'instanceof' ReferenceType
+ public void test016() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " if (args instanceof @Readonly String) {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " if (args instanceof @Readonly String) {\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible conditional operand types String[] and String\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " if (args instanceof @Readonly String) {\n" +
+ " ^^^^^^^^\n" +
+ "Readonly cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // TypeArgument ::= ReferenceType
+ public void test017() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X extends Y<@Marker Integer, String> {}\n" +
+ "class Y<T, V> {\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends Y<@Marker Integer, String> {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ReferenceType1 ::= ReferenceType '>'
+ public void test018() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X extends Y<@Marker Integer> {}\n" +
+ "class Y<T> {\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends Y<@Marker Integer> {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+
+ // ReferenceType2 ::= ReferenceType '>>'
+ public void test019() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T extends Object & Comparable<? super @Marker String>> {}\n" +
+ "class Y<T> {\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<T extends Object & Comparable<? super @Marker String>> {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ReferenceType3 ::= ReferenceType '>>>'
+ public void test020() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<A extends X<X<X<@Marker String>>>> {}\n" +
+ "class Y<T> {\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<A extends X<X<X<@Marker String>>>> {}\n" +
+ " ^\n" +
+ "Bound mismatch: The type X<X<String>> is not a valid substitute for the bounded parameter <A extends X<X<X<String>>>> of the type X<A>\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X<A extends X<X<X<@Marker String>>>> {}\n" +
+ " ^\n" +
+ "Bound mismatch: The type X<String> is not a valid substitute for the bounded parameter <A extends X<X<X<String>>>> of the type X<A>\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public class X<A extends X<X<X<@Marker String>>>> {}\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "Bound mismatch: The type String is not a valid substitute for the bounded parameter <A extends X<X<X<String>>>> of the type X<A>\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 1)\n" +
+ " public class X<A extends X<X<X<@Marker String>>>> {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // WildcardBounds ::= 'extends' ReferenceType
+ // WildcardBounds ::= 'super' ReferenceType
+ public void test021() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " ^^^\n" +
+ "Map cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 2)\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 2)\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 2)\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 3)\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ " ^^^\n" +
+ "Map cannot be resolved to a type\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 3)\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 3)\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "9. ERROR in X.java (at line 3)\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "10. ERROR in X.java (at line 3)\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // TypeParameter ::= TypeParameterHeader 'extends' ReferenceType
+ public void test022() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ "}\n" +
+ "class Y<T> {}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. WARNING in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^^^^^^^^^^\n" +
+ "The type parameter Q should not be bounded by the final type Integer. Final types cannot be further extended\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // TypeParameter ::= TypeParameterHeader 'extends' ReferenceType AdditionalBoundList
+ // AdditionalBound ::= '&' ReferenceType
+ // TypeParameter1 ::= TypeParameterHeader 'extends' ReferenceType AdditionalBoundList1
+ public void test023() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "I.java",
+ "public interface I<U extends J<? extends I<U>>> {\n" +
+ "}\n" +
+ "interface J<T extends I<? extends J<T>>> {\n" +
+ "}\n" +
+ "class CI<U extends CJ<T, U> & @Marker J<@Marker T>,\n" +
+ " T extends CI<U, T> & @Marker I<U>>\n" +
+ " implements I<U> {\n" +
+ "}\n" +
+ "class CJ<T extends CI<U, T> & @Marker I<@Marker U>,\n" +
+ " U extends CJ<T, U> & J<T>>\n" +
+ " implements J<T> {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in I.java (at line 5)\n" +
+ " class CI<U extends CJ<T, U> & @Marker J<@Marker T>,\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in I.java (at line 5)\n" +
+ " class CI<U extends CJ<T, U> & @Marker J<@Marker T>,\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in I.java (at line 6)\n" +
+ " T extends CI<U, T> & @Marker I<U>>\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in I.java (at line 9)\n" +
+ " class CJ<T extends CI<U, T> & @Marker I<@Marker U>,\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. ERROR in I.java (at line 9)\n" +
+ " class CJ<T extends CI<U, T> & @Marker I<@Marker U>,\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // InstanceofExpression_NotName ::= Name 'instanceof' ReferenceType
+ public void test024() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<E> {\n" +
+ " class Y {\n" +
+ " E e;\n" +
+ " E getOtherElement(Object other) {\n" +
+ " if (!(other instanceof @Marker X<?>.Y)) {};\n" +
+ " return null;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " if (!(other instanceof @Marker X<?>.Y)) {};\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // InstanceofExpression_NotName ::= InstanceofExpression_NotName 'instanceof' ReferenceType
+ public void test025() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<P, C> {\n" +
+ " public X() {\n" +
+ " if (!(this instanceof @Marker X)) {}\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " if (!(this instanceof @Marker X)) {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ReferenceExpressionTypeArgumentsAndTrunk ::= OnlyTypeArguments '.' ClassOrInterfaceType Dimsopt
+ public void test026() throws Exception { // WILL FAIL WHEN REFERENCE EXPRESSIONS ARE ANALYZED.
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(Y<String>.Z z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.@Marker Z::foo;\n" +
+ " i.foo(new Y<String>().new Z(), 10); \n" +
+ " Zork z;\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ArrayCreationWithoutArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
+ // ArrayCreationWithArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializer
+ public void test027() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " X [] x = new @Marker X @Marker [5];\n" +
+ " X [] x2 = new @Marker X @Marker [] { null };\n" +
+ " Zork z;\n" +
+ " }\n" +
+ "}\n" },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " X [] x = new @Marker X @Marker [5];\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " X [] x = new @Marker X @Marker [5];\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " X [] x2 = new @Marker X @Marker [] { null };\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 4)\n" +
+ " X [] x2 = new @Marker X @Marker [] { null };\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 5)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // CastExpression ::= PushLPAREN Name OnlyTypeArgumentsForCastExpression '.' ClassOrInterfaceType Dimsopt PushRPAREN InsideCastExpressionWithQualifiedGenerics UnaryExpressionNotPlusMinus
+ public void test028() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " java.util.Map.Entry [] e = (java.util.Map<String, String>.@Marker Entry []) null;\n" +
+ " }\n" +
+ "}\n" },
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " java.util.Map.Entry [] e = (java.util.Map<String, String>.@Marker Entry []) null;\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "Map.Entry is a raw type. References to generic type Map<K,V>.Entry<K,V> should be parameterized\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " java.util.Map.Entry [] e = (java.util.Map<String, String>.@Marker Entry []) null;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The member type Map<String,String>.Entry cannot be qualified with a parameterized type, since it is static. Remove arguments from qualifying type Map<String,String>\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " java.util.Map.Entry [] e = (java.util.Map<String, String>.@Marker Entry []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ReferenceType1 ::= ClassOrInterface '<' TypeArgumentList2
+ public void test029() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.io.Serializable;\n" +
+ "import java.util.List;\n" +
+ "public class X<T extends Comparable<T> & Serializable> {\n" +
+ " void foo(List<? extends @Marker Comparable<T>> p) {} \n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " void foo(List<? extends @Marker Comparable<T>> p) {} \n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ReferenceType2 ::= ClassOrInterface '<' TypeArgumentList3
+ public void test030() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class Base {\n" +
+ "}\n" +
+ "class Foo<U extends Base, V extends Bar<U, @Marker Foo<U, V>>> {\n" +
+ "}\n" +
+ "class Bar<E extends Base, F extends Foo<E, @Marker Bar<E, F>>> {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " class Foo<U extends Base, V extends Bar<U, @Marker Foo<U, V>>> {\n" +
+ " ^^^^^^^^^^^\n" +
+ "Bound mismatch: The type Foo<U,V> is not a valid substitute for the bounded parameter <F extends Foo<E,Bar<E,F>>> of the type Bar<E,F>\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " class Foo<U extends Base, V extends Bar<U, @Marker Foo<U, V>>> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " class Bar<E extends Base, F extends Foo<E, @Marker Bar<E, F>>> {\n" +
+ " ^^^^^^^^^^^\n" +
+ "Bound mismatch: The type Bar<E,F> is not a valid substitute for the bounded parameter <V extends Bar<U,Foo<U,V>>> of the type Foo<U,V>\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 5)\n" +
+ " class Bar<E extends Base, F extends Foo<E, @Marker Bar<E, F>>> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ClassHeaderExtends ::= 'extends' ClassType
+ public void test031() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X extends @Marker Object {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends @Marker Object {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ClassInstanceCreationExpression ::= 'new' OnlyTypeArguments ClassType EnterInstanceCreationArgumentList '(' ArgumentListopt ')' UnqualifiedClassBodyopt
+ // ClassInstanceCreationExpression ::= 'new' ClassType EnterInstanceCreationArgumentList '(' ArgumentListopt ')' UnqualifiedClassBodyopt
+ public void test032() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " X x = new @Marker X();\n" +
+ " X y = new <String> @Marker X();\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " X x = new @Marker X();\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 3)\n" +
+ " X y = new <String> @Marker X();\n" +
+ " ^^^^^^\n" +
+ "Unused type arguments for the non generic constructor X() of type X; it should not be parameterized with arguments <String>\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " X y = new <String> @Marker X();\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ClassInstanceCreationExpression ::= Primary '.' 'new' OnlyTypeArguments ClassType EnterInstanceCreationArgumentList '(' ArgumentListopt ')' QualifiedClassBodyopt
+ // ClassInstanceCreationExpression ::= Primary '.' 'new' ClassType EnterInstanceCreationArgumentList '(' ArgumentListopt ')' QualifiedClassBodyopt
+ public void test033() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " class Y {\n" +
+ " }\n" +
+ " Y y1 = new @Marker X().new @Marker Y();\n" +
+ " Y y2 = new @Marker X().new <String> @Marker Y();\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " Y y1 = new @Marker X().new @Marker Y();\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Y y1 = new @Marker X().new @Marker Y();\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " Y y2 = new @Marker X().new <String> @Marker Y();\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. WARNING in X.java (at line 5)\n" +
+ " Y y2 = new @Marker X().new <String> @Marker Y();\n" +
+ " ^^^^^^\n" +
+ "Unused type arguments for the non generic constructor X.Y() of type X.Y; it should not be parameterized with arguments <String>\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 5)\n" +
+ " Y y2 = new @Marker X().new <String> @Marker Y();\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' ClassType EnterInstanceCreationArgumentList '(' ArgumentListopt ')' QualifiedClassBodyopt
+ // ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' OnlyTypeArguments ClassType EnterInstanceCreationArgumentList '(' ArgumentListopt ')' QualifiedClassBodyopt
+ public void test034() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " X x;\n" +
+ " class Y {\n" +
+ " }\n" +
+ " Y y1 = @Marker x.new @Marker Y();\n" +
+ " Y y2 = @Marker x.new <String> @Marker Y();\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " Y y1 = @Marker x.new @Marker Y();\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " Y y1 = @Marker x.new @Marker Y();\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 6)\n" +
+ " Y y2 = @Marker x.new <String> @Marker Y();\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "4. WARNING in X.java (at line 6)\n" +
+ " Y y2 = @Marker x.new <String> @Marker Y();\n" +
+ " ^^^^^^\n" +
+ "Unused type arguments for the non generic constructor X.Y() of type X.Y; it should not be parameterized with arguments <String>\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 6)\n" +
+ " Y y2 = @Marker x.new <String> @Marker Y();\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // MethodHeaderThrowsClause ::= 'throws' ClassTypeList
+ // ClassTypeList -> ClassTypeElt
+ // ClassTypeList ::= ClassTypeList ',' ClassTypeElt
+ // ClassTypeElt ::= ClassType
+ public void test035() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo() throws @Marker NullPointerException, @Marker ArrayIndexOutOfBoundsException {}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " void foo() throws @Marker NullPointerException, @Marker ArrayIndexOutOfBoundsException {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " void foo() throws @Marker NullPointerException, @Marker ArrayIndexOutOfBoundsException {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ClassHeaderImplements ::= 'implements' InterfaceTypeList
+ // InterfaceHeaderExtends ::= 'extends' InterfaceTypeList
+ // InterfaceTypeList -> InterfaceType
+ // InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType
+ // InterfaceType ::= ClassOrInterfaceType
+ public void test036() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {}\n" +
+ "interface J {}\n" +
+ "interface K extends @Marker I, @Marker J {}\n" +
+ "interface L {}\n" +
+ "public class X implements @Marker K, @Marker L {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " interface K extends @Marker I, @Marker J {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " interface K extends @Marker I, @Marker J {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " public class X implements @Marker K, @Marker L {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 5)\n" +
+ " public class X implements @Marker K, @Marker L {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ReferenceExpression ::= Name Dimsopt '::' NonWildTypeArgumentsopt IdentifierOrNew
+ public void test037() throws Exception { // WILL FAIL WHEN REFERENCE EXPRESSIONS ARE ANALYZED.
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = @Marker Y. @Marker Z @Marker [] [] @Marker [] ::foo;\n" +
+ " i.foo(10); \n" +
+ " Zork z;\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " static class Z {\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ReferenceExpression ::= Name BeginTypeArguments ReferenceExpressionTypeArgumentsAndTrunk '::' NonWildTypeArgumentsopt IdentifierOrNew
+ public void test038() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " Y foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " class Z extends Y {\n" +
+ " public Z(int x) {\n" +
+ " super(x);\n" +
+ " System.out.println();\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " i = @Marker W<@Marker Integer>::<@Marker String> new;\n" +
+ " }\n" +
+ "}\n" +
+ "class W<T> extends Y {\n" +
+ " public W(T x) {\n" +
+ " super(0);\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public Y(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n"
+
+
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 12)\n" +
+ " i = @Marker W<@Marker Integer>::<@Marker String> new;\n" +
+ " ^\n" +
+ "i cannot be resolved to a variable\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 12)\n" +
+ " i = @Marker W<@Marker Integer>::<@Marker String> new;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The target type of this expression must be a functional interface\n" +
+ "----------\n"
+ );
+ }
+ // CastExpression ::= PushLPAREN Name PushRPAREN InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
+ // CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
+ // CastExpression ::= PushLPAREN Name OnlyTypeArgumentsForCastExpression Dimsopt PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
+ // CastExpression ::= PushLPAREN Name OnlyTypeArgumentsForCastExpression '.' ClassOrInterfaceType Dimsopt PushRPAREN InsideCastExpressionWithQualifiedGenerics UnaryExpressionNotPlusMinus
+ public void test039() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " Object o = (@Marker X) null;\n" +
+ " Object p = (@Marker X @Marker []) null;\n" +
+ " Object q = (@Marker java. @Marker util. @Marker List<@Marker String> []) null;\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " Object o = (@Marker X) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Object p = (@Marker X @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " Object p = (@Marker X @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 4)\n" +
+ " Object q = (@Marker java. @Marker util. @Marker List<@Marker String> []) null;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 4)\n" +
+ " Object q = (@Marker java. @Marker util. @Marker List<@Marker String> []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 4)\n" +
+ " Object q = (@Marker java. @Marker util. @Marker List<@Marker String> []) null;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 4)\n" +
+ " Object q = (@Marker java. @Marker util. @Marker List<@Marker String> []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 4)\n" +
+ " Object q = (@Marker java. @Marker util. @Marker List<@Marker String> []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "9. ERROR in X.java (at line 4)\n" +
+ " Object q = (@Marker java. @Marker util. @Marker List<@Marker String> []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "10. ERROR in X.java (at line 5)\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "11. ERROR in X.java (at line 5)\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The member type Map<String,String>.Entry cannot be qualified with a parameterized type, since it is static. Remove arguments from qualifying type Map<String,String>\n" +
+ "----------\n" +
+ "12. ERROR in X.java (at line 5)\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "13. ERROR in X.java (at line 5)\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "14. ERROR in X.java (at line 5)\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "15. ERROR in X.java (at line 5)\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ " ^^^^^^^\n" +
+ "Type annotations are not allowed on type names used to access static members\n" +
+ "----------\n" +
+ "16. ERROR in X.java (at line 5)\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "17. ERROR in X.java (at line 5)\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "18. ERROR in X.java (at line 5)\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "19. ERROR in X.java (at line 5)\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "20. ERROR in X.java (at line 5)\n" +
+ " Object r = (@Marker java. @Marker util.@Marker Map<@Marker String, @Marker String>.@Marker Entry @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java
index 7e127d4..bbb9c35 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java
@@ -1,12 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * Copyright (c) 2006, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stephan Herrmann - Contribution for
+ * Bug 388800 - [1.8] adjust tests to 1.8 JRE
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -6854,6 +6860,7 @@
" compare(yourList != null ? yourList : myList, yourList);\n" +
" return 0;\n" +
" }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
" };\n" +
" System.out.println(\"SUCCESS\");\n" +
" }\n" +
@@ -6884,6 +6891,7 @@
" private int foo(int i, int j) {\n" +
" return i - j;\n" +
" }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
" };\n" +
" System.out.println(\"SUCCESS\");\n" +
" }\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java
index e3004ba..5ca0df1 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -739,7 +743,7 @@
+ "----------\n");
}
- public void test033() {
+ public void _test033() {
runNegativeTest(
new String[] {
"test/X.java",
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java
index f1c0480..aeca3f5 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_3.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -2169,194 +2169,13 @@
* @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=86769"
*/
public void testBug86769() {
- this.reportMissingJavadocComments = CompilerOptions.ERROR;
- runNegativeTest(
- new String[] {
- "E.java",
- "public enum E {\n" +
- " A,\n" +
- " DC{\n" +
- " public void foo() {}\n" +
- " };\n" +
- " E() {}\n" +
- " public void foo() {}\n" +
- " private enum Epriv {\n" +
- " Apriv,\n" +
- " Cpriv {\n" +
- " public void foo() {}\n" +
- " };\n" +
- " Epriv() {}\n" +
- " public void foo() {}\n" +
- " }\n" +
- " enum Edef {\n" +
- " Adef,\n" +
- " Cdef {\n" +
- " public void foo() {}\n" +
- " };\n" +
- " Edef() {}\n" +
- " public void foo() {}\n" +
- " }\n" +
- " protected enum Epro {\n" +
- " Apro,\n" +
- " Cpro {\n" +
- " public void foo() {}\n" +
- " };\n" +
- " Epro() {}\n" +
- " public void foo() {}\n" +
- " }\n" +
- " public enum Epub {\n" +
- " Apub,\n" +
- " Cpub {\n" +
- " public void foo() {}\n" +
- " };\n" +
- " Epub() {}\n" +
- " public void foo() {}\n" +
- " }\n" +
- "}\n"
- },
- "----------\n" +
- "1. ERROR in E.java (at line 1)\n" +
- " public enum E {\n" +
- " ^^^^\n" +
-//{ObjectTeams: our grammar prefers class, so expect "class E implements ..."
-/* orig:
- "Syntax error on token \"enum\", interface expected\n" +
- :giro */
- "Syntax error on token \"enum\", class expected\n" +
-// orig:
- "----------\n" +
- "2. ERROR in E.java (at line 1)\n" +
- " public enum E {\n" +
- " ^\n" +
-/*
- "Syntax error on token \"{\", extends expected\n" +
- :giro */
- "Syntax error on token \"{\", implements expected\n" +
-// SH}
- "----------\n" +
- "3. ERROR in E.java (at line 5)\n" +
- " };\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n" +
- "4. ERROR in E.java (at line 5)\n" +
- " };\n" +
- " E() {}\n" +
- " public void foo() {}\n" +
- " private enum Epriv {\n" +
- " Apriv,\n" +
- " Cpriv {\n" +
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Syntax error on token(s), misplaced construct(s)\n" +
- "----------\n" +
- "5. WARNING in E.java (at line 8)\n" +
- " private enum Epriv {\n" +
- " ^^^^\n" +
- "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" +
- "----------\n" +
- "6. ERROR in E.java (at line 8)\n" +
- " private enum Epriv {\n" +
- " ^^^^^\n" +
- "Syntax error on token \"Epriv\", = expected after this token\n" +
- "----------\n" +
- "7. ERROR in E.java (at line 12)\n" +
- " };\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n" +
- "8. WARNING in E.java (at line 16)\n" +
- " enum Edef {\n" +
- " ^^^^\n" +
- "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" +
- "----------\n" +
- "9. ERROR in E.java (at line 16)\n" +
- " enum Edef {\n" +
- " ^^^^\n" +
-//{ObjectTeams: our grammar prefers class, so expect "class E implements ..."
-/* orig:
- "Syntax error on token \"enum\", interface expected\n" +
- :giro */
- "Syntax error on token \"enum\", class expected\n" +
-// orig:
- "----------\n" +
- "10. ERROR in E.java (at line 16)\n" +
- " enum Edef {\n" +
- " ^\n" +
-/*
- "Syntax error on token \"{\", extends expected\n" +
- :giro */
- "Syntax error on token \"{\", implements expected\n" +
-// SH}
- "----------\n" +
- "11. ERROR in E.java (at line 20)\n" +
- " };\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n" +
- "12. WARNING in E.java (at line 24)\n" +
- " protected enum Epro {\n" +
- " ^^^^\n" +
- "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" +
- "----------\n" +
- "13. ERROR in E.java (at line 24)\n" +
- " protected enum Epro {\n" +
- " ^^^^\n" +
-//{ObjectTeams: our grammar prefers class, so expect "class E implements ..."
-/* orig:
- "Syntax error on token \"enum\", interface expected\n" +
- :giro */
- "Syntax error on token \"enum\", class expected\n" +
-// orig:
- "----------\n" +
- "14. ERROR in E.java (at line 24)\n" +
- " protected enum Epro {\n" +
- " ^\n" +
-/*
- "Syntax error on token \"{\", extends expected\n" +
- :giro */
- "Syntax error on token \"{\", implements expected\n" +
-// SH}
- "----------\n" +
- "15. ERROR in E.java (at line 28)\n" +
- " };\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n" +
- "16. WARNING in E.java (at line 32)\n" +
- " public enum Epub {\n" +
- " ^^^^\n" +
- "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" +
- "----------\n" +
- "17. ERROR in E.java (at line 32)\n" +
- " public enum Epub {\n" +
- " ^^^^\n" +
-//{ObjectTeams: our grammar prefers class, so expect "class E implements ..."
-/* orig:
- "Syntax error on token \"enum\", interface expected\n" +
- :giro */
- "Syntax error on token \"enum\", class expected\n" +
-// orig:
- "----------\n" +
- "18. ERROR in E.java (at line 32)\n" +
- " public enum Epub {\n" +
- " ^\n" +
-/*
- "Syntax error on token \"{\", extends expected\n" +
- :giro */
- "Syntax error on token \"{\", implements expected\n" +
-// SH}
- "----------\n" +
- "19. ERROR in E.java (at line 36)\n" +
- " };\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n" +
- "20. ERROR in E.java (at line 40)\n" +
- " }\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n"
- );
+
+ /* Deleted a completely meaningless test that could only serve as a torture test for the parser.
+ The test is still run in 1.5+ modes where it makes sense to run it - The test here was a nuisance
+ failing every time there is some serious grammar change that alters the semi-random behavior in
+ Diagnose Parser.
+ */
+ return;
}
/**
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java
index f656e05..8d8eec6 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTest_1_4.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -665,12 +665,25 @@
"----------\n" +
"4. ERROR in X.java (at line 7)\n" +
" public class X<T, , V> {}\n" +
- " ^^\n" +
+//{ObjectTeams: different position due to different grammar:
+/* orig:
+ " ^^\n" +
+
+ :giro */
+ " ^^^^^^^^^^\n" +
+// SH}
"Syntax error on tokens, delete these tokens\n" +
"----------\n" +
"5. ERROR in X.java (at line 7)\n" +
" public class X<T, , V> {}\n" +
" ^\n" +
+//{ObjectTeams: one more message:
+ "Syntax error, insert \"Identifier\" to complete TypeParameter\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 7)\n" +
+ " public class X<T, , V> {}\n" +
+ " ^\n" +
+// SH}
"Syntax error, insert \"ClassBody\" to complete CompilationUnit\n" +
"----------\n"
);
@@ -709,7 +722,7 @@
/* orig:
" ^^^^^^\n" +
:giro */
- " ^^^^^^^^\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
// SH}
"Syntax error on tokens, delete these tokens\n" +
"----------\n" +
@@ -718,10 +731,11 @@
//{ObjectTeams: changed position due to different grammar
/* orig:
" ^\n" +
+ "Syntax error, insert \"ClassBody\" to complete CompilationUnit\n" +
:giro */
" ^\n" +
+ "Syntax error, insert \"Identifier\" to complete TypeParameter\n" +
// SH}
- "Syntax error, insert \"ClassBody\" to complete CompilationUnit\n" +
"----------\n" +
"6. ERROR in X.java (at line 7)\n" +
" public class X<T, U, V extend Exception> {}\n" +
@@ -734,6 +748,13 @@
"V cannot be resolved to a type\n" +
// SH}
"----------\n"
+//{ObjectTeams: one more message:
+ +"7. ERROR in X.java (at line 7)\n" +
+ " public class X<T, U, V extend Exception> {}\n" +
+ " ^\n" +
+ "Syntax error, insert \"ClassBody\" to complete CompilationUnit\n" +
+ "----------\n"
+// SH}
);
}
@@ -2203,194 +2224,13 @@
* @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=86769"
*/
public void testBug86769() {
- this.reportMissingJavadocComments = CompilerOptions.ERROR;
- runNegativeTest(
- new String[] {
- "E.java",
- "public enum E {\n" +
- " A,\n" +
- " DC{\n" +
- " public void foo() {}\n" +
- " };\n" +
- " E() {}\n" +
- " public void foo() {}\n" +
- " private enum Epriv {\n" +
- " Apriv,\n" +
- " Cpriv {\n" +
- " public void foo() {}\n" +
- " };\n" +
- " Epriv() {}\n" +
- " public void foo() {}\n" +
- " }\n" +
- " enum Edef {\n" +
- " Adef,\n" +
- " Cdef {\n" +
- " public void foo() {}\n" +
- " };\n" +
- " Edef() {}\n" +
- " public void foo() {}\n" +
- " }\n" +
- " protected enum Epro {\n" +
- " Apro,\n" +
- " Cpro {\n" +
- " public void foo() {}\n" +
- " };\n" +
- " Epro() {}\n" +
- " public void foo() {}\n" +
- " }\n" +
- " public enum Epub {\n" +
- " Apub,\n" +
- " Cpub {\n" +
- " public void foo() {}\n" +
- " };\n" +
- " Epub() {}\n" +
- " public void foo() {}\n" +
- " }\n" +
- "}\n"
- },
- "----------\n" +
- "1. ERROR in E.java (at line 1)\n" +
- " public enum E {\n" +
- " ^^^^\n" +
-//{ObjectTeams: our grammar prefers class, so expect "class E implements ..."
-/* orig:
- "Syntax error on token \"enum\", interface expected\n" +
- :giro */
- "Syntax error on token \"enum\", class expected\n" +
-// orig:
- "----------\n" +
- "2. ERROR in E.java (at line 1)\n" +
- " public enum E {\n" +
- " ^\n" +
-/*
- "Syntax error on token \"{\", extends expected\n" +
- :giro */
- "Syntax error on token \"{\", implements expected\n" +
-// SH}
- "----------\n" +
- "3. ERROR in E.java (at line 5)\n" +
- " };\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n" +
- "4. ERROR in E.java (at line 5)\n" +
- " };\n" +
- " E() {}\n" +
- " public void foo() {}\n" +
- " private enum Epriv {\n" +
- " Apriv,\n" +
- " Cpriv {\n" +
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
- "Syntax error on token(s), misplaced construct(s)\n" +
- "----------\n" +
- "5. WARNING in E.java (at line 8)\n" +
- " private enum Epriv {\n" +
- " ^^^^\n" +
- "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" +
- "----------\n" +
- "6. ERROR in E.java (at line 8)\n" +
- " private enum Epriv {\n" +
- " ^^^^^\n" +
- "Syntax error on token \"Epriv\", = expected after this token\n" +
- "----------\n" +
- "7. ERROR in E.java (at line 12)\n" +
- " };\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n" +
- "8. WARNING in E.java (at line 16)\n" +
- " enum Edef {\n" +
- " ^^^^\n" +
- "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" +
- "----------\n" +
- "9. ERROR in E.java (at line 16)\n" +
- " enum Edef {\n" +
- " ^^^^\n" +
-//{ObjectTeams: our grammar prefers class, so expect "class E implements ..."
-/* orig:
- "Syntax error on token \"enum\", interface expected\n" +
- :giro */
- "Syntax error on token \"enum\", class expected\n" +
-// orig:
- "----------\n" +
- "10. ERROR in E.java (at line 16)\n" +
- " enum Edef {\n" +
- " ^\n" +
-/*
- "Syntax error on token \"{\", extends expected\n" +
- :giro */
- "Syntax error on token \"{\", implements expected\n" +
-// SH}
- "----------\n" +
- "11. ERROR in E.java (at line 20)\n" +
- " };\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n" +
- "12. WARNING in E.java (at line 24)\n" +
- " protected enum Epro {\n" +
- " ^^^^\n" +
- "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" +
- "----------\n" +
- "13. ERROR in E.java (at line 24)\n" +
- " protected enum Epro {\n" +
- " ^^^^\n" +
-//{ObjectTeams: our grammar prefers class, so expect "class E implements ..."
-/* orig:
- "Syntax error on token \"enum\", interface expected\n" +
- :giro */
- "Syntax error on token \"enum\", class expected\n" +
-// orig:
- "----------\n" +
- "14. ERROR in E.java (at line 24)\n" +
- " protected enum Epro {\n" +
- " ^\n" +
-/*
- "Syntax error on token \"{\", extends expected\n" +
- :giro */
- "Syntax error on token \"{\", implements expected\n" +
-// SH}
- "----------\n" +
- "15. ERROR in E.java (at line 28)\n" +
- " };\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n" +
- "16. WARNING in E.java (at line 32)\n" +
- " public enum Epub {\n" +
- " ^^^^\n" +
- "\'enum\' should not be used as an identifier, since it is a reserved keyword from source level 1.5 on\n" +
- "----------\n" +
- "17. ERROR in E.java (at line 32)\n" +
- " public enum Epub {\n" +
- " ^^^^\n" +
-//{ObjectTeams: our grammar prefers class, so expect "class E implements ..."
-/* orig:
- "Syntax error on token \"enum\", interface expected\n" +
- :giro */
- "Syntax error on token \"enum\", class expected\n" +
-// orig:
- "----------\n" +
- "18. ERROR in E.java (at line 32)\n" +
- " public enum Epub {\n" +
- " ^\n" +
-/*
- "Syntax error on token \"{\", extends expected\n" +
- :giro */
- "Syntax error on token \"{\", implements expected\n" +
-// SH}
- "----------\n" +
- "19. ERROR in E.java (at line 36)\n" +
- " };\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n" +
- "20. ERROR in E.java (at line 40)\n" +
- " }\n" +
- " ^\n" +
- "Syntax error on token \"}\", delete this token\n" +
- "----------\n"
- );
+
+ /* Deleted a completely meaningless test that could only serve as a torture test for the parser.
+ The test is still run in 1.5+ modes where it makes sense to run it - The test here was a nuisance
+ failing every time there is some serious grammar change that alters the semi-random behavior in
+ Diagnose Parser.
+ */
+ return;
}
/**
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java
index a53b3e5..fd2d7ae 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java
@@ -1,13 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for
+ * bug 185682 - Increment/decrement operators mark local variables as read
+ * bug 388800 - [1.8] adjust tests to 1.8 JRE
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -2561,6 +2567,9 @@
" public int size() {\n" +
" return 0;\n" +
" }\n" +
+ getListRawImplJRE8() +
+ getIterableRawImplJRE8() +
+ getCollectionRawImplJRE8() +
"}", // =================
},
"");
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
index 079991d..8eb18b2 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
@@ -1,14 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contribution for
+ * bug 388800 - [1.8] adjust tests to 1.8 JRE
* bug 388795 - [compiler] detection of name clash depends on order of super interfaces
+ * bug 388739 - [1.8][compiler] consider default methods when detecting whether a class needs to be declared abstract
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -1813,8 +1819,10 @@
this.runConformTest(
new String[] {
"X.java",
+ "import java.util.*;\n" +
"public class X extends java.util.AbstractMap {\n" +
" public java.util.Set entrySet() { return null; }\n" +
+ MAP_RAW_IMPL_JRE8 +
"}\n"
},
""
@@ -2033,7 +2041,7 @@
"1. ERROR in X.java (at line 3)\n" +
" public class X<T extends I&J> {}\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods J.foo(), I.foo()\n" +
+ "The return types are incompatible for the inherited methods I.foo(), J.foo()\n" +
"----------\n"
// types J and I are incompatible; both define foo(), but with unrelated return types
);
@@ -2359,7 +2367,7 @@
"1. ERROR in Y.java (at line 1)\n" +
" abstract class Y implements Equivalent<String>, EqualityComparable<Integer> {\n" +
" ^\n" +
- "Name clash: The method equalTo(T) of type Equivalent<T> has the same erasure as equalTo(T) of type EqualityComparable<T> but does not override it\n" +
+ "Name clash: The method equalTo(T) of type EqualityComparable<T> has the same erasure as equalTo(T) of type Equivalent<T> but does not override it\n" +
"----------\n");
}
}
@@ -2379,29 +2387,29 @@
"1. ERROR in Y.java (at line 2)\n" +
" public abstract boolean equalTo(Object other);\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
- "Name clash: The method equalTo(Object) of type Y has the same erasure as equalTo(T) of type Equivalent<T> but does not override it\n" +
+ "Name clash: The method equalTo(Object) of type Y has the same erasure as equalTo(T) of type EqualityComparable<T> but does not override it\n" +
"----------\n" +
"2. ERROR in Y.java (at line 2)\n" +
" public abstract boolean equalTo(Object other);\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
- "Name clash: The method equalTo(Object) of type Y has the same erasure as equalTo(T) of type EqualityComparable<T> but does not override it\n" +
+ "Name clash: The method equalTo(Object) of type Y has the same erasure as equalTo(T) of type Equivalent<T> but does not override it\n" +
"----------\n" :
// name clash: equalTo(java.lang.Object) in Y and equalTo(T) in Equivalent<java.lang.String> have the same erasure, yet neither overrides the other
"----------\n" +
"1. ERROR in Y.java (at line 1)\n" +
" abstract class Y implements Equivalent<String>, EqualityComparable<Integer> {\n" +
" ^\n" +
- "Name clash: The method equalTo(T) of type Equivalent<T> has the same erasure as equalTo(T) of type EqualityComparable<T> but does not override it\n" +
+ "Name clash: The method equalTo(T) of type EqualityComparable<T> has the same erasure as equalTo(T) of type Equivalent<T> but does not override it\n" +
"----------\n" +
"2. ERROR in Y.java (at line 2)\n" +
" public abstract boolean equalTo(Object other);\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
- "Name clash: The method equalTo(Object) of type Y has the same erasure as equalTo(T) of type Equivalent<T> but does not override it\n" +
+ "Name clash: The method equalTo(Object) of type Y has the same erasure as equalTo(T) of type EqualityComparable<T> but does not override it\n" +
"----------\n" +
"3. ERROR in Y.java (at line 2)\n" +
" public abstract boolean equalTo(Object other);\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
- "Name clash: The method equalTo(Object) of type Y has the same erasure as equalTo(T) of type EqualityComparable<T> but does not override it\n" +
+ "Name clash: The method equalTo(Object) of type Y has the same erasure as equalTo(T) of type Equivalent<T> but does not override it\n" +
"----------\n"
);
}
@@ -6870,6 +6878,9 @@
" public boolean hasNext() { return false; }\n" +
" public Object next() { return null; }\n" +
" public void remove() {}\n" +
+ ITERABLE_RAW_IMPL_JRE8 +
+ COLLECTION_RAW_IMPL_JRE8 +
+ LIST_RAW_IMPL_JRE8 +
"}\n", // =================
},
"----------\n" +
@@ -6990,6 +7001,9 @@
" public boolean hasNext() { return false; }\n" +
" public Object next() { return null; }\n" +
" public void remove() {}\n" +
+ ITERABLE_RAW_IMPL_JRE8 +
+ COLLECTION_RAW_IMPL_JRE8 +
+ LIST_RAW_IMPL_JRE8 +
"}\n", // =================
},
"----------\n" +
@@ -7100,6 +7114,9 @@
" public boolean hasNext() { return false; }\n" +
" public Object next() { return null; }\n" +
" public void remove() {}\n" +
+ ITERABLE_RAW_IMPL_JRE8 +
+ COLLECTION_RAW_IMPL_JRE8 +
+ LIST_RAW_IMPL_JRE8 +
"}\n", // =================
},
"----------\n" +
@@ -9084,7 +9101,7 @@
"1. ERROR in X.java (at line 1)\n" +
" public abstract class X implements J, K {}\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods K.foo(Number), J.foo(Number)\n" +
+ "The return types are incompatible for the inherited methods J.foo(Number), K.foo(Number)\n" +
"----------\n" +
"2. WARNING in X.java (at line 6)\n" +
" XX foo(Number n);\n" +
@@ -9698,7 +9715,7 @@
"1. ERROR in X.java (at line 9)\n" +
" public abstract class X implements I, J {\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods J.foo(), I.foo()\n" +
+ "The return types are incompatible for the inherited methods I.foo(), J.foo()\n" +
"----------\n"
);
}
@@ -9723,7 +9740,7 @@
"1. ERROR in X.java (at line 10)\n" +
" public abstract class X implements I, J {\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods J.foo(), I.foo()\n" +
+ "The return types are incompatible for the inherited methods I.foo(), J.foo()\n" +
"----------\n"
);
}
@@ -9750,7 +9767,7 @@
"1. ERROR in X.java (at line 7)\n" +
" interface C extends A, B {}\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods B.foo(), A.foo()\n" +
+ "The return types are incompatible for the inherited methods A.foo(), B.foo()\n" +
"----------\n"
);
}
@@ -9782,7 +9799,7 @@
"1. ERROR in X.java (at line 17)\n" +
" public abstract class X extends Root implements AFoo, BFoo {\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods BFoo.bar(), AFoo.bar()\n" +
+ "The return types are incompatible for the inherited methods AFoo.bar(), BFoo.bar()\n" +
"----------\n"
);
}
@@ -9813,17 +9830,17 @@
"1. ERROR in X.java (at line 15)\n" +
" public abstract class X extends Root implements AFoo, BFoo {}\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods BFoo.bar(), AFoo.bar()\n" +
+ "The return types are incompatible for the inherited methods AFoo.bar(), BFoo.bar()\n" +
"----------\n" +
"2. ERROR in X.java (at line 16)\n" +
" abstract class Y extends X {}\n" +
" ^\n" +
- "The return types are incompatible for the inherited methods BFoo.bar(), AFoo.bar()\n" +
+ "The return types are incompatible for the inherited methods AFoo.bar(), BFoo.bar()\n" +
"----------\n" +
"3. ERROR in X.java (at line 17)\n" +
" class Z extends X {}\n" +
" ^\n" +
- "The type Z must implement the inherited abstract method AFoo.bar()\n" +
+ "The type Z must implement the inherited abstract method BFoo.bar()\n" +
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=208010
@@ -10793,7 +10810,7 @@
"1. ERROR in A.java (at line 3)\n" +
" class A implements I, J {}\n" +
" ^\n" +
- "The type A must implement the inherited abstract method I.hello()\n" +
+ "The type A must implement the inherited abstract method J.hello()\n" +
"----------\n"
);
}
@@ -11385,6 +11402,7 @@
" return compare((I) o1, (I) o2);\n" +
" }\n" +
" public int compare(I o1, I o2) { return 0; }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
"}"
},
""
@@ -12297,6 +12315,7 @@
" public int compare(Object o1, Object o2) {\n" +
" return 0;\n" +
" }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
" };\n" +
" Test.assertEquals(\"Test\", comparator, new ArrayList(), new ArrayList());\n" +
" }\n" +
@@ -12367,6 +12386,7 @@
" public int compare(Object o1, Object o2) {\n" +
" return 0;\n" +
" }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
" };\n" +
" Test.assertEquals(\"Test\", comparator, new ArrayList(), new ArrayList());\n" +
" }\n" +
@@ -13375,11 +13395,6 @@
" Zork z;\n" +
" ^^^^\n" +
"Zork cannot be resolved to a type\n" +
- "----------\n" +
- "5. ERROR in X.java (at line 7)\n" +
- " class ChildX<Z> extends X<Z>{}\n" +
- " ^^^^^^\n" +
- "Duplicate methods named forAccountSet with the parameters (List<R>) and (List) are defined by the type X<Z>\n" +
"----------\n":
"----------\n" +
"1. ERROR in X.java (at line 3)\n" +
@@ -13714,7 +13729,7 @@
"1. ERROR in X.java (at line 8)\n" +
" interface C extends A, B { \n" +
" ^\n" +
- "Name clash: The method get(List<String>) of type A has the same erasure as get(List<Integer>) of type B but does not override it\n" +
+ "Name clash: The method get(List<Integer>) of type B has the same erasure as get(List<String>) of type A but does not override it\n" +
"----------\n" +
"2. ERROR in X.java (at line 10)\n" +
" Zork z;\n" +
@@ -13780,7 +13795,7 @@
"1. ERROR in X.java (at line 7)\n" +
" interface E extends X, Y {\n" +
" ^\n" +
- "Name clash: The method e(Action<T>) of type X has the same erasure as e(Action<S>) of type Y but does not override it\n" +
+ "Name clash: The method e(Action<S>) of type Y has the same erasure as e(Action<T>) of type X but does not override it\n" +
"----------\n" +
"2. ERROR in X.java (at line 10)\n" +
" Zork z;\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java
new file mode 100644
index 0000000..6ff31fb
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java
@@ -0,0 +1,414 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jesper S Moller - Contributions for
+ * bug 382701 - [1.8][compiler] Implement semantic analysis of Lambda expressions & Reference expression
+
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import junit.framework.Test;
+public class NegativeLambdaExpressionsTest extends AbstractRegressionTest {
+
+static {
+// TESTS_NAMES = new String[] { "test380112e"};
+// TESTS_NUMBERS = new int[] { 50 };
+// TESTS_RANGE = new int[] { 11, -1 };
+}
+public NegativeLambdaExpressionsTest(String name) {
+ super(name);
+}
+public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=382818, ArrayStoreException while compiling lambda
+public void test001() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(int x, int y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " int x, y;\n" +
+ " I i = () -> {\n" +
+ " int z = 10;\n" +
+ " };\n" +
+ " i++;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " i++;\n" +
+ " ^^^\n" +
+ "Type mismatch: cannot convert from I to int\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=382841, ClassCastException while compiling lambda
+public void test002() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(int x, int y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " int x, y;\n" +
+ " I i = (p, q) -> {\n" +
+ " int r = 10;\n" +
+ " };\n" +
+ " i++;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " i++;\n" +
+ " ^^^\n" +
+ "Type mismatch: cannot convert from I to int\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=382841, ClassCastException while compiling lambda
+public void test003() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(int x, int y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " int x, y;\n" +
+ " I i = null, i2 = (p, q) -> {\n" +
+ " int r = 10;\n" +
+ " }, i3 = null;\n" +
+ " i++;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " i++;\n" +
+ " ^^^\n" +
+ "Type mismatch: cannot convert from I to int\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383046, syntax error reported incorrectly on syntactically valid lambda expression
+public void test004() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface IX {\n" +
+ " public void foo();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " IX i = () -> 42;\n" +
+ " int x\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " int x\n" +
+ " ^\n" +
+ "Syntax error, insert \";\" to complete FieldDeclaration\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383085 super::identifier not accepted.
+public void test005() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface IX{\n" +
+ " public void foo();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " IX i = super::toString;\n" +
+ " Zork z;\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383046, syntax error reported incorrectly on *syntactically* valid reference expression
+public void test006() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface IX{\n" +
+ " public void foo();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " IX i = Outer<One, Two>.Inner<Three, Four>.Deeper<Five, Six<String>>.Leaf::<Blah, Blah>method;\n" +
+ " int x\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " int x\n" +
+ " ^\n" +
+ "Syntax error, insert \";\" to complete FieldDeclaration\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383096, NullPointerException with a wrong lambda code snippet
+public void _test007() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {}\n" +
+ "public class X {\n" +
+ " void foo() {\n" +
+ " I t1 = f -> {{};\n" +
+ " I t2 = () -> 42;\n" +
+ " } \n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " int\n" +
+ " ^^^\n" +
+ "Syntax error on token \"int\", delete this token\n" +
+ "----------\n" /* expected compiler log */,
+ true /* perform statement recovery */);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383949, Explicit this parameter illegal in lambda expressions
+public void test008() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " int foo(X x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = (X this) -> 10; \n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " I i = (X this) -> 10; \n" +
+ " ^^^^\n" +
+ "Lambda expressions cannot declare a this parameter\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383949, Explicit this parameter illegal in lambda expressions
+public void test009() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.awt.event.ActionListener;\n" +
+ "interface I {\n" +
+ " void doit(String s1, String s2);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public void test1(int x) {\n" +
+ " ActionListener al = (public xyz) -> System.out.println(xyz); \n" +
+ " I f = (abstract final s, @Nullable t) -> System.out.println(s + t); \n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " ActionListener al = (public xyz) -> System.out.println(xyz); \n" +
+ " ^^^\n" +
+ "Syntax error, modifiers and annotations are not allowed for the lambda parameter xyz as its type is elided\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " I f = (abstract final s, @Nullable t) -> System.out.println(s + t); \n" +
+ " ^\n" +
+ "Syntax error, modifiers and annotations are not allowed for the lambda parameter s as its type is elided\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 8)\n" +
+ " I f = (abstract final s, @Nullable t) -> System.out.println(s + t); \n" +
+ " ^\n" +
+ "Syntax error, modifiers and annotations are not allowed for the lambda parameter t as its type is elided\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=381121, [] should be accepted in reference expressions.
+public void test010() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " Object foo(int [] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I i = (int [] ia) -> {\n" +
+ " return ia.clone();\n" +
+ " };\n" +
+ " I i2 = int[]::clone;\n" +
+ " Zork z;\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=382701, [1.8][compiler] Implement semantic analysis of Lambda expressions & Reference expressions.
+public void test011() {
+ // This test checks that common semantic checks are indeed
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " Object foo(int [] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I i = (int [] ia) -> {\n" +
+ " Zork z;\n" + // Error: No such type
+ " unknown = 0;\n;" + // Error: No such variable
+ " int a = 42 + ia;\n" + // Error: int + int[] is wrong
+ " return ia.clone();\n" +
+ " };\n" +
+ " static void staticLambda() {\n" +
+ " I i = (int [] ia) -> this;\n" + // 'this' is static
+ " }\n" +
+ " I j = array -> {\n" +
+ " int a = array[2] + 3;\n" + // No error, ia must be correctly identifies as int[]
+ " int b = 42 + array;\n" + // Error: int + int[] is wrong - yes it is!
+ " System.out.println(\"i(array) = \" + i.foo(array));\n" + // fields are accessible!
+ " return;\n" + // Error here, expecting Object, not void
+ " };\n" +
+ " Runnable r = () -> { return 42; };\n" + // Runnable.run not expecting return value
+ " void anotherLambda() {\n" +
+ " final int beef = 0;\n" +
+ " I k = (int [] a) -> a.length + beef;\n" + // No error, beef is in scope
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " unknown = 0;\n" +
+ " ^^^^^^^\n" +
+ "unknown cannot be resolved to a variable\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 8)\n" +
+ " ; int a = 42 + ia;\n" +
+ " ^^^^^^^\n" +
+ "The operator + is undefined for the argument type(s) int, int[]\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 12)\n" +
+ " I i = (int [] ia) -> this;\n" +
+ " ^^^^\n" +
+ "Cannot use this in a static context\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 16)\n" +
+ " int b = 42 + array;\n" +
+ " ^^^^^^^^^^\n" +
+ "The operator + is undefined for the argument type(s) int, int[]\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 18)\n" +
+ " return;\n" +
+ " ^^^^^^^\n" +
+ "This method must return a result of type Object\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 20)\n" +
+ " Runnable r = () -> { return 42; };\n" +
+ " ^^^^^^^^^^\n" +
+ "Void methods cannot return a value\n" +
+ "----------\n"
+);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=384600, [1.8] 'this' should not be allowed in lambda expressions in contexts that don't allow it
+public void test012() {
+ // This test checks that common semantic checks are indeed
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static void foo() {\n" +
+ " I i = () -> {\n" +
+ " System.out.println(this);\n" +
+ " I j = () -> {\n" +
+ " System.out.println(this);\n" +
+ " I k = () -> {\n" +
+ " System.out.println(this);\n" +
+ " };\n" +
+ " };\n" +
+ " };\n" +
+ " }\n" +
+ "}\n" ,
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " System.out.println(this);\n" +
+ " ^^^^\n" +
+ "Cannot use this in a static context\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " System.out.println(this);\n" +
+ " ^^^^\n" +
+ "Cannot use this in a static context\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 11)\n" +
+ " System.out.println(this);\n" +
+ " ^^^^\n" +
+ "Cannot use this in a static context\n" +
+ "----------\n"
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=384600, [1.8] 'this' should not be allowed in lambda expressions in contexts that don't allow it
+public void test013() {
+ // This test checks that common semantic checks are indeed
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " void foo(Zork z) {\n" +
+ " I i = () -> {\n" +
+ " System.out.println(this);\n" +
+ " I j = () -> {\n" +
+ " System.out.println(this);\n" +
+ " I k = () -> {\n" +
+ " System.out.println(this);\n" +
+ " };\n" +
+ " };\n" +
+ " };\n" +
+ " }\n" +
+ "}\n" ,
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " void foo(Zork z) {\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n"
+ );
+}
+public static Class testClass() {
+ return NegativeLambdaExpressionsTest.class;
+}
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java
new file mode 100644
index 0000000..692f21e
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java
@@ -0,0 +1,3156 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.io.File;
+
+import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
+import junit.framework.Test;
+
+public class NegativeTypeAnnotationTest extends AbstractRegressionTest {
+
+ static {
+// TESTS_NUMBERS = new int [] { 35 };
+ }
+ public static Class testClass() {
+ return NegativeTypeAnnotationTest.class;
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+ }
+ public NegativeTypeAnnotationTest(String testName){
+ super(testName);
+ }
+ public void test001() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X extends @Marker2 Object {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends @Marker2 Object {}\n" +
+ " ^^^^^^^\n" +
+ "Marker2 cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ public void test002() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.io.Serializable;\n" +
+ "public class X implements @Marker2 Serializable {\n" +
+ " private static final long serialVersionUID = 1L;\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public class X implements @Marker2 Serializable {\n" +
+ " ^^^^^^^\n" +
+ "Marker2 cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ public void test003() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X extends @Marker Object {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends @Marker Object {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ public void test004() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<@Marker T> {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<@Marker T> {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ public void test005() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<@Marker T> {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<@Marker T> {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ public void test006() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "Y.java",
+ "class Y {}\n",
+ "X.java",
+ "public class X extends @A(id=\"Hello, World!\") @B @C('(') Y {\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends @A(id=\"Hello, World!\") @B @C(\'(\') Y {\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X extends @A(id=\"Hello, World!\") @B @C(\'(\') Y {\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public class X extends @A(id=\"Hello, World!\") @B @C(\'(\') Y {\n" +
+ " ^\n" +
+ "C cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ public void test007() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "I.java",
+ "interface I {}\n",
+ "J.java",
+ "interface J {}\n",
+ "X.java",
+ "public class X implements @A(id=\"Hello, World!\") I, @B @C('(') J {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X implements @A(id=\"Hello, World!\") I, @B @C(\'(\') J {}\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X implements @A(id=\"Hello, World!\") I, @B @C(\'(\') J {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public class X implements @A(id=\"Hello, World!\") I, @B @C(\'(\') J {}\n" +
+ " ^\n" +
+ "C cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ public void test010() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "Y.java",
+ "class Y<T> {}\n",
+ "X.java",
+ "public class X extends @A(\"Hello, World!\") Y<@B @C('(') String> {\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends @A(\"Hello, World!\") Y<@B @C(\'(\') String> {\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X extends @A(\"Hello, World!\") Y<@B @C(\'(\') String> {\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public class X extends @A(\"Hello, World!\") Y<@B @C(\'(\') String> {\n" +
+ " ^\n" +
+ "C cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ public void test011() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "I.java",
+ "interface I<T> {}\n",
+ "J.java",
+ "interface J<T> {}\n",
+ "X.java",
+ "public class X implements I<@A(\"Hello, World!\") String>, @B J<@C('(') Integer> {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X implements I<@A(\"Hello, World!\") String>, @B J<@C(\'(\') Integer> {}\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X implements I<@A(\"Hello, World!\") String>, @B J<@C(\'(\') Integer> {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public class X implements I<@A(\"Hello, World!\") String>, @B J<@C(\'(\') Integer> {}\n" +
+ " ^\n" +
+ "C cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // throws
+ public void test012() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "E.java",
+ "class E extends RuntimeException {\n" +
+ " private static final long serialVersionUID = 1L;\n" +
+ "}\n",
+ "E1.java",
+ "class E1 extends RuntimeException {\n" +
+ " private static final long serialVersionUID = 1L;\n" +
+ "}\n",
+ "E2.java",
+ "class E2 extends RuntimeException {\n" +
+ " private static final long serialVersionUID = 1L;\n" +
+ "}\n",
+ "X.java",
+ "public class X {\n" +
+ " void foo() throws @A(\"Hello, World!\") E, E1, @B @C('(') E2 {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " void foo() throws @A(\"Hello, World!\") E, E1, @B @C(\'(\') E2 {}\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " void foo() throws @A(\"Hello, World!\") E, E1, @B @C(\'(\') E2 {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 2)\n" +
+ " void foo() throws @A(\"Hello, World!\") E, E1, @B @C(\'(\') E2 {}\n" +
+ " ^\n" +
+ "C cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // method receiver
+ public void test013() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo(@B(3) X this) {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " void foo(@B(3) X this) {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // method return type
+ public void test014() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @B(3) int foo() {\n" +
+ " return 1;\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " @B(3) int foo() {\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // field type
+ public void test015() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @B(3) int field;\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " @B(3) int field;\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // method parameter
+ public void test016() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int foo(@B(3) String s) {\n" +
+ " return s.length();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int foo(@B(3) String s) {\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // method parameter generic or array
+ public void test017() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int foo(String @B(3) [] s) {\n" +
+ " return s.length;\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int foo(String @B(3) [] s) {\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // field type generic or array
+ public void test018() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int @B(3) [] field;\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int @B(3) [] field;\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // class type parameter
+ public void test019() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<@A @B(3) T> {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<@A @B(3) T> {}\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X<@A @B(3) T> {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // method type parameter
+ public void test020() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " <@A @B(3) T> void foo(T t) {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " <@A @B(3) T> void foo(T t) {}\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " <@A @B(3) T> void foo(T t) {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // class type parameter bound
+ public void test021() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "Z.java",
+ "public class Z {}",
+ "X.java",
+ "public class X<T extends @A Z & @B(3) Cloneable> {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<T extends @A Z & @B(3) Cloneable> {}\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X<T extends @A Z & @B(3) Cloneable> {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // class type parameter bound generic or array
+ public void test022() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "Y.java",
+ "public class Y<T> {}",
+ "X.java",
+ "public class X<T extends Y<@A String @C[][]@B[]> & @B(3) Cloneable> {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<T extends Y<@A String @C[][]@B[]> & @B(3) Cloneable> {}\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X<T extends Y<@A String @C[][]@B[]> & @B(3) Cloneable> {}\n" +
+ " ^\n" +
+ "C cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public class X<T extends Y<@A String @C[][]@B[]> & @B(3) Cloneable> {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 1)\n" +
+ " public class X<T extends Y<@A String @C[][]@B[]> & @B(3) Cloneable> {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // method type parameter bound
+ public void test023() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "Z.java",
+ "public class Z {}",
+ "X.java",
+ "public class X {\n" +
+ " <T extends @A Z & @B(3) Cloneable> void foo(T t) {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " <T extends @A Z & @B(3) Cloneable> void foo(T t) {}\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " <T extends @A Z & @B(3) Cloneable> void foo(T t) {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // class type parameter bound generic or array
+ public void test024() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "Z.java",
+ "public class Z {}",
+ "Y.java",
+ "public class Y<T> {}",
+ "X.java",
+ "public class X {\n" +
+ " <T extends Y<@A Z @C[][]@B[]> & @B(3) Cloneable> void foo(T t) {}\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " <T extends Y<@A Z @C[][]@B[]> & @B(3) Cloneable> void foo(T t) {}\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " <T extends Y<@A Z @C[][]@B[]> & @B(3) Cloneable> void foo(T t) {}\n" +
+ " ^\n" +
+ "C cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 2)\n" +
+ " <T extends Y<@A Z @C[][]@B[]> & @B(3) Cloneable> void foo(T t) {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 2)\n" +
+ " <T extends Y<@A Z @C[][]@B[]> & @B(3) Cloneable> void foo(T t) {}\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // local variable + generic or array
+ public void test025() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo(String s) {\n" +
+ " @C int i;\n" +
+ " @A String [] @B(3)[] tab = new String[][] {};\n" +
+ " if (tab != null) {\n" +
+ " i = 0;\n" +
+ " System.out.println(i + tab.length);\n" +
+ " } else {\n" +
+ " System.out.println(tab.length);\n" +
+ " }\n" +
+ " i = 4;\n" +
+ " System.out.println(-i + tab.length);\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " @C int i;\n" +
+ " ^\n" +
+ "C cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " @A String [] @B(3)[] tab = new String[][] {};\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " @A String [] @B(3)[] tab = new String[][] {};\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // type argument constructor call
+ public void test026() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " <T> X(T t) {\n" +
+ " }\n" +
+ " public Object foo() {\n" +
+ " X x = new <@A @B(1) String>X(null);\n" +
+ " return x;\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " X x = new <@A @B(1) String>X(null);\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " X x = new <@A @B(1) String>X(null);\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // type argument constructor call generic or array
+ public void test027() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " <T> X(T t) {\n" +
+ " }\n" +
+ " public Object foo() {\n" +
+ " X x = new <@A @B(1) String>X(null);\n" +
+ " return x;\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " X x = new <@A @B(1) String>X(null);\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " X x = new <@A @B(1) String>X(null);\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // type argument method call and generic or array
+ public void test028() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ "\n" +
+ " static <T, U> T foo(T t, U u) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(X.<@A @B(1) String[], @C('-') X>foo(new String[]{\"SUCCESS\"}, null)[0]);\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " System.out.println(X.<@A @B(1) String[], @C(\'-\') X>foo(new String[]{\"SUCCESS\"}, null)[0]);\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " System.out.println(X.<@A @B(1) String[], @C(\'-\') X>foo(new String[]{\"SUCCESS\"}, null)[0]);\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 7)\n" +
+ " System.out.println(X.<@A @B(1) String[], @C(\'-\') X>foo(new String[]{\"SUCCESS\"}, null)[0]);\n" +
+ " ^\n" +
+ "C cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ public void test029() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X extends @Marker2 Object {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends @Marker2 Object {}\n" +
+ " ^^^^^^^\n" +
+ "Marker2 cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ public void test030() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.io.Serializable;\n" +
+ "public class X implements @Marker2 Serializable {\n" +
+ " private static final long serialVersionUID = 1L;\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public class X implements @Marker2 Serializable {\n" +
+ " ^^^^^^^\n" +
+ "Marker2 cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ public void test031() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "Marker.java",
+ "import java.lang.annotation.Target;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "@Target(TYPE)\n" +
+ "@interface Marker {}",
+ "X.java",
+ "public class X<@Marker T> {}",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n" +
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<@Marker T> {}\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n");
+ }
+ public void test032() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "Marker.java",
+ "@interface Marker {}",
+ "X.java",
+ "public class X<@Marker T> {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<@Marker T> {}\n" +
+ " ^^^^^^^\n" +
+ "Annotation types that do not specify explicit target element types cannot be applied here\n" +
+ "----------\n");
+ }
+ public void test033() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "Marker.java",
+ "@interface Marker {}",
+ "Y.java",
+ "public class Y {}",
+ "X.java",
+ "public class X extends @Marker Y {}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends @Marker Y {}\n" +
+ " ^^^^^^^\n" +
+ "Annotation types that do not specify explicit target element types cannot be applied here\n" +
+ "----------\n");
+ }
+ // check locations
+ public void test034() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.Map;\n" +
+ "import java.util.List;\n" +
+ "public class X {\n" +
+ " @H String @E[] @F[] @G[] field;\n" +
+ " @A Map<@B String, @C List<@D Object>> field2;\n" +
+ " @A Map<@B String, @H String @E[] @F[] @G[]> field3;\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " @H String @E[] @F[] @G[] field;\n" +
+ " ^\n" +
+ "H cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " @H String @E[] @F[] @G[] field;\n" +
+ " ^\n" +
+ "E cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " @H String @E[] @F[] @G[] field;\n" +
+ " ^\n" +
+ "F cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 4)\n" +
+ " @H String @E[] @F[] @G[] field;\n" +
+ " ^\n" +
+ "G cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 5)\n" +
+ " @A Map<@B String, @C List<@D Object>> field2;\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 5)\n" +
+ " @A Map<@B String, @C List<@D Object>> field2;\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 5)\n" +
+ " @A Map<@B String, @C List<@D Object>> field2;\n" +
+ " ^\n" +
+ "C cannot be resolved to a type\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 5)\n" +
+ " @A Map<@B String, @C List<@D Object>> field2;\n" +
+ " ^\n" +
+ "D cannot be resolved to a type\n" +
+ "----------\n" +
+ "9. ERROR in X.java (at line 6)\n" +
+ " @A Map<@B String, @H String @E[] @F[] @G[]> field3;\n" +
+ " ^\n" +
+ "A cannot be resolved to a type\n" +
+ "----------\n" +
+ "10. ERROR in X.java (at line 6)\n" +
+ " @A Map<@B String, @H String @E[] @F[] @G[]> field3;\n" +
+ " ^\n" +
+ "B cannot be resolved to a type\n" +
+ "----------\n" +
+ "11. ERROR in X.java (at line 6)\n" +
+ " @A Map<@B String, @H String @E[] @F[] @G[]> field3;\n" +
+ " ^\n" +
+ "H cannot be resolved to a type\n" +
+ "----------\n" +
+ "12. ERROR in X.java (at line 6)\n" +
+ " @A Map<@B String, @H String @E[] @F[] @G[]> field3;\n" +
+ " ^\n" +
+ "E cannot be resolved to a type\n" +
+ "----------\n" +
+ "13. ERROR in X.java (at line 6)\n" +
+ " @A Map<@B String, @H String @E[] @F[] @G[]> field3;\n" +
+ " ^\n" +
+ "F cannot be resolved to a type\n" +
+ "----------\n" +
+ "14. ERROR in X.java (at line 6)\n" +
+ " @A Map<@B String, @H String @E[] @F[] @G[]> field3;\n" +
+ " ^\n" +
+ "G c