Bug 384992 - [java8] adopt grammar changes for Java 8 from JDT/Core
2. Full source merge - grammar adjusted to be LALR(1)
JDT tests look good, OTJLD tests: 625 Err, 36 Fail
Notably LiftingTypeReference cannot yet be created by the Parser
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..fff9960 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_7) {
+ this.runNegativeTest(testFiles, expected17ProblemLog);
+ }
+ }
public void test0001() {
String[] testFiles = new String[] {
"X.java",
@@ -1289,7 +1312,7 @@
expected15ProblemLog
);
}
-public void test0029() {
+public void _test0029() {
String[] testFiles = new String[] {
"X.java",
"public class X {\n" +
@@ -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" +
@@ -1750,7 +1773,7 @@
expected15ProblemLog
);
}
-public void test0038() {
+public void _test0038() {
String[] testFiles = new String[] {
"X.java",
"public class X {\n" +
@@ -1832,7 +1855,7 @@
expected15ProblemLog
);
}
-public void test0040() {
+public void _test0040() {
String[] testFiles = new String[] {
"X.java",
"public class X {\n" +
@@ -1875,7 +1898,7 @@
expected15ProblemLog
);
}
-public void test0041() {
+public void _test0041() {
String[] testFiles = new String[] {
"X.java",
"public class X {\n" +
@@ -2646,4 +2669,207 @@
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
+ );
+}
}
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..1ebb661 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,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
@@ -2500,7 +2500,7 @@
* Should recover from method with missing argument names
*/
-public void test32() {
+public void _test32() {
String s =
"public class WB2 { \n"+
@@ -4580,7 +4580,7 @@
* Bunch of syntax errors
*/
-public void test75() {
+public void _test75() {
String s =
"package ZKentTest;\n"+
@@ -4776,7 +4776,7 @@
* Should not recover duplicate field numberOfDisks
*/
-public void test77() {
+public void _test77() {
String s =
"package p; \n"+
@@ -5951,7 +5951,7 @@
expectedCompletionDietUnitToString, testName);
}
-public void test99() {
+public void _test99() {
String s =
"import ;\n"+
"class X {\n"+
@@ -7585,7 +7585,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/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..ab933a1
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java
@@ -0,0 +1,706 @@
+/*******************************************************************************
+ * 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);
+ }
+}
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..fa46308 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,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
@@ -61,7 +61,7 @@
"----------\n"
);
}
-public void test003() {
+public void _test003() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -120,7 +120,7 @@
"----------\n"
);
}
-public void test006() {
+public void _test006() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -228,7 +228,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..212eb3d
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java
@@ -0,0 +1,911 @@
+/*******************************************************************************
+ * 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);
+ }
+}
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..cef2b72 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,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
@@ -150,7 +150,7 @@
/*
* Should diagnose parenthesis mismatch
*/
-public void test03() {
+public void _test03() {
String s =
"public class X { // should complain \n"+
@@ -260,7 +260,7 @@
testName);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=61189
-public void test06() {
+public void _test06() {
String s =
"public class X { \n"+
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..07e8c82
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java
@@ -0,0 +1,3777 @@
+/*******************************************************************************
+ * 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.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";
+
+ 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 expectedUnitToString =
+ "class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\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";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0026", expectedUnitToString);
+}
+// 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 expectedUnitToString =
+ "class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\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";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0027", expectedUnitToString);
+}
+//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 expectedUnitToString =
+ "class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\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";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0028", expectedUnitToString);
+}
+// 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 expectedUnitToString =
+ "class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\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";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0029", expectedUnitToString);
+}
+//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 expectedUnitToString =
+ "class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\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";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0030", expectedUnitToString);
+}
+//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 expectedUnitToString =
+ "class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\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";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0031", expectedUnitToString);
+}
+// 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 expectedUnitToString =
+ "class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\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";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0032", expectedUnitToString);
+}
+//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 expectedUnitToString =
+ "class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\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";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0033", expectedUnitToString);
+}
+// 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_ALL & ~CHECK_JAVAC_PARSER & ~CHECK_DOCUMENT_ELEMENT_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_ALL & ~CHECK_DOCUMENT_ELEMENT_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);
+}
+}
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 8c518e8..12883dc 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,9 +1,13 @@
/*******************************************************************************
- * 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
@@ -490,7 +494,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 +849,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 \"")
@@ -1812,6 +1821,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/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
index 875c58e..fcf0e9d 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
@@ -9852,7 +9852,7 @@
}
// Bug 366003 - CCE in ASTNode.resolveAnnotations(ASTNode.java:639)
// many syntax errors fixed, does not trigger CCE
-public void testBug366003() {
+public void _testBug366003() {
runNegativeTest(
new String[] {
"snippet/Bug366003.java",
@@ -9945,7 +9945,7 @@
}
// Bug 366003 - CCE in ASTNode.resolveAnnotations(ASTNode.java:639)
// code is garbage, triggers CCE
-public void testBug366003b() {
+public void _testBug366003b() {
runNegativeTest(
new String[] {
"snippet/Bug366003.java",
@@ -10031,7 +10031,7 @@
}
// Bug 366003 - CCE in ASTNode.resolveAnnotations(ASTNode.java:639)
// minimal syntax error to trigger CCE
-public void testBug366003c() {
+public void _testBug366003c() {
runNegativeTest(
new String[] {
"snippet/Bug366003.java",
@@ -10079,7 +10079,7 @@
"----------\n");
}
// unfinished attempt to trigger the same CCE via catch formal parameters
-public void testBug366003d() {
+public void _testBug366003d() {
runNegativeTest(
new String[] {
"snippet/Bug366003.java",
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 f69d3b2..3418aa9 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
@@ -1576,8 +1580,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" +
@@ -12751,7 +12756,7 @@
new String[] {
"X1.java",
"public class X1 {\n" +
- " Zork;\n" +
+ " Zork z;\n" +
"}\n",
"org/eclipse/jdt/annotation/NonNull.java",
NONNULL_ANNOTATION_CONTENT,
@@ -12772,9 +12777,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 d9d4a26..ccefc66 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
@@ -16,6 +16,12 @@
* 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.
+ *
+ * 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.
+ *
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -407,9 +413,11 @@
expectedProblemAttributes.put("ContradictoryNullAnnotations", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("ComparingIdentical", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("ConflictingImport", new ProblemAttributes(CategorizedProblem.CAT_IMPORT));
+ 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("DiamondNotBelow17", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("DirectInvocationOfAbstractMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("DisallowedTargetForAnnotation", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
@@ -452,10 +460,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));
@@ -483,6 +494,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));
@@ -508,6 +520,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));
@@ -515,6 +528,7 @@
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));
@@ -524,6 +538,7 @@
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("IllegalVisibilityModifierCombinationForField", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForMemberType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
@@ -585,6 +600,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));
@@ -603,7 +619,9 @@
expectedProblemAttributes.put("InvalidUsageOfAnnotations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfEnumDeclarations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfForeachStatements", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("InvalidUsageOfReceiverAnnotations", 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));
@@ -680,6 +698,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));
@@ -696,9 +715,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));
@@ -1193,10 +1214,12 @@
expectedProblemAttributes.put("CodeSnippetMissingMethod", SKIP);
expectedProblemAttributes.put("ComparingIdentical", new ProblemAttributes(JavaCore.COMPILER_PB_COMPARING_IDENTICAL));
expectedProblemAttributes.put("ConflictingImport", SKIP);
+ 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("DiamondNotBelow17", SKIP);
expectedProblemAttributes.put("DirectInvocationOfAbstractMethod", SKIP);
expectedProblemAttributes.put("DisallowedTargetForAnnotation", SKIP);
@@ -1239,10 +1262,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));
@@ -1270,6 +1296,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);
@@ -1295,6 +1322,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);
@@ -1302,6 +1330,7 @@
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);
@@ -1311,6 +1340,7 @@
expectedProblemAttributes.put("IllegalTypeVariableSuperReference", SKIP);
expectedProblemAttributes.put("IllegalUnderscorePosition", SKIP);
expectedProblemAttributes.put("IllegalUsageOfQualifiedTypeReference", SKIP);
+ expectedProblemAttributes.put("IllegalUsageOfTypeAnnotations", SKIP);
expectedProblemAttributes.put("IllegalVararg", SKIP);
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForField", SKIP);
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForMemberType", SKIP);
@@ -1372,6 +1402,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);
@@ -1390,7 +1421,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);
@@ -1467,6 +1500,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));
@@ -1483,9 +1517,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);
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..5a4e83b
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultMethodsTest.java
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * Copyright (c) 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 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[] { "testModifiers1" };
+// 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
+// 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() {
+// Inject an unrelated compile error to prevent class file verification. TODO revert
+// runConformTest(
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "public interface I {\n" +
+ " void foo() default {}\n" +
+ "}\n",
+ "C.java",
+ "public class C implements I {}\n" +
+// TODO remove me:
+ "public class Wrong{}\n"
+ },
+ "----------\n" +
+ "1. ERROR in C.java (at line 2)\n" +
+ " public class Wrong{}\n" +
+ " ^^^^^\n" +
+ "The public type Wrong must be defined in its own file\n" +
+ "----------\n");
+ }
+
+ // 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");
+ }
+}
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 3278e91..113e80c 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
@@ -5,6 +5,11 @@
* 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
@@ -1867,7 +1872,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",
@@ -1939,8 +1944,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"
);
}
@@ -2312,7 +2323,7 @@
);
}
// TODO (david) remove errors: insert dimension to complete array type
- public void test0080() {
+ public void _test0080() {
this.runNegativeTest(
new String[] {
"test/X.java",
@@ -2399,7 +2410,7 @@
);
}
// TODO (david) remove error: insert dimension to complete array type
- public void test0083() {
+ public void _test0083() {
this.runNegativeTest(
new String[] {
"test/X.java",
@@ -30415,7 +30426,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",
@@ -37453,7 +37464,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 */
@@ -48324,7 +48335,7 @@
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=252120 - variation
-public void test1403() throws Exception {
+public void _test1403() throws Exception {
this.runNegativeTest(
new String[] {
"A.java",
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..67b866e 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,5 +1,5 @@
/*******************************************************************************
- * 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
@@ -739,7 +739,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/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..c869a4e
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java
@@ -0,0 +1,270 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 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.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\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");
+}
+// 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\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");
+}
+// 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(e); \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(e); \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");
+}
+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..2df5b54
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java
@@ -0,0 +1,956 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 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.regression;
+
+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_USE)\n" +
+ "@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" +
+ "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" +
+ "The annotation @Marker is disallowed for this location\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" +
+ "The annotation @Marker is disallowed for this location\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 cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // check locations
+ public void test035() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.Map;\n" +
+ "import java.util.List;\n" +
+ "public class X {\n" +
+ " @H java.lang.String @E[] @F[] @G[] field;\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " @H java.lang.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 java.lang.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 java.lang.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 java.lang.String @E[] @F[] @G[] field;\n" +
+ " ^\n" +
+ "G cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=383884 -- Compiler tolerates illegal dimension annotation in class literal expressions
+ public void test036() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " System.out.println(int [] [] [] [] [].class);\n" +
+ " System.out.println(X [] [] [] [] [].class);\n" +
+ " }\n" +
+ "}\n" +
+ "@interface Empty {\n" +
+ "}\n" +
+ "@interface NonEmpty {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^\n" +
+ "Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 3)\n" +
+ " System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^\n" +
+ "Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 3)\n" +
+ " System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^\n" +
+ "Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 3)\n" +
+ " System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 3)\n" +
+ " System.out.println(int @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^\n" +
+ "Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 4)\n" +
+ " System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "9. ERROR in X.java (at line 4)\n" +
+ " System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^\n" +
+ "Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" +
+ "----------\n" +
+ "10. ERROR in X.java (at line 4)\n" +
+ " System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "11. ERROR in X.java (at line 4)\n" +
+ " System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^\n" +
+ "Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" +
+ "----------\n" +
+ "12. ERROR in X.java (at line 4)\n" +
+ " System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^\n" +
+ "Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" +
+ "----------\n" +
+ "13. ERROR in X.java (at line 4)\n" +
+ " System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "14. ERROR in X.java (at line 4)\n" +
+ " System.out.println(X @NonEmpty [] [] @NonEmpty @Empty [] [] @NonEmpty[].class); // illegal!\n" +
+ " ^^^^^^^^^\n" +
+ "Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=383950
+ // [1.8][compiler] Type annotations must have target type meta annotation TYPE_USE
+ public void test037() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "@interface Marker {}\n" +
+ "@Marker // line 2: Don't complain \n" +
+ "public class X<@Marker T> extends @Marker Object{ // 3: Complain \n" +
+ " public @Marker Object foo(@Marker Object obj) { // 4: Don't complain on both\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " public class X<@Marker T> extends @Marker Object{ // 3: Complain \n" +
+ " ^^^^^^^\n" +
+ "Only annotation types that explicitly specify TYPE_PARAMETER as a possible target element type can be applied here\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " public class X<@Marker T> extends @Marker Object{ // 3: Complain \n" +
+ " ^^^^^^^\n" +
+ "Only annotation types that explicitly specify TYPE_USE as a possible target element type can be applied here\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=383950
+ // [1.8][compiler] Type annotations must have target type meta annotation TYPE_USE
+ public void test038() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.lang.annotation.Target;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "@Target({PACKAGE, TYPE, METHOD, FIELD, CONSTRUCTOR, PARAMETER, LOCAL_VARIABLE})\n" +
+ "@interface Marker {}\n" +
+ "public class X<@Marker T> extends @Marker Object{ // 3: Complain \n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " public class X<@Marker T> extends @Marker Object{ // 3: Complain \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " public class X<@Marker T> extends @Marker Object{ // 3: Complain \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n");
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
index 253c543..a4d6819 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java
@@ -19,7 +19,6 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
// see bug 186342 - [compiler][null] Using annotations for null checking
public class NullAnnotationTest extends AbstractComparableTest {
@@ -553,10 +552,6 @@
}
// non-null varargs (message send)
public void test_nonnull_parameter_015() {
- if (this.complianceLevel > ClassFileConstants.JDK1_7) {
- fail("Reminder: should check if JSR 308 mandates a change in handling vararg elements (see bug 365983).");
- return;
- }
runNegativeTest(
new String[] {
"X.java",
@@ -606,10 +601,6 @@
}
// non-null varargs (allocation and explicit constructor calls)
public void test_nonnull_parameter_016() {
- if (this.complianceLevel > ClassFileConstants.JDK1_7) {
- fail("Reminder: should check if JSR 308 mandates a change in handling vararg elements (see bug 365983).");
- return;
- }
runNegativeTest(
new String[] {
"X.java",
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java
index 6e782c5..74070b2 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java
@@ -1,9 +1,13 @@
/*******************************************************************************
- * 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
@@ -1306,4 +1310,32 @@
"Invalid unicode\n" +
"----------\n");
}
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=383062
+ public void test061() {
+ IScanner scanner = ToolFactory.createScanner(false, false, false, JavaCore.VERSION_1_4);
+ char[] source = "->".toCharArray(); //$NON-NLS-1$
+ scanner.setSource(source);
+ scanner.resetTo(0, source.length - 1);
+ int token = 0;
+ try {
+ token = scanner.getNextToken();
+ } catch (InvalidInputException e) {
+ // ignore ...
+ }
+ assertEquals("Expecting ->", ITerminalSymbols.TokenNameARROW, token);
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=383062
+ public void test062() {
+ IScanner scanner = ToolFactory.createScanner(false, false, false, JavaCore.VERSION_1_4);
+ char[] source = "::".toCharArray(); //$NON-NLS-1$
+ scanner.setSource(source);
+ scanner.resetTo(0, source.length - 1);
+ int token = 0;
+ try {
+ token = scanner.getNextToken();
+ } catch (InvalidInputException e) {
+ // ignore.
+ }
+ assertEquals("Expecting ::", ITerminalSymbols.TokenNameCOLON_COLON, token);
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
index 49a2b1f..258094a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
@@ -5,6 +5,10 @@
* 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
@@ -113,6 +117,21 @@
ArrayList since_1_6 = new ArrayList();
since_1_6.add(StackMapAttributeTest.class);
since_1_6.add(Compliance_1_6.class);
+
+ ArrayList since_1_7 = new ArrayList();
+ since_1_7.add(AssignmentTest_1_7.class);
+ since_1_7.add(BinaryLiteralTest.class);
+ since_1_7.add(UnderscoresInLiteralsTest.class);
+ since_1_7.add(TryStatement17Test.class);
+ since_1_7.add(TryWithResourcesStatementTest.class);
+ since_1_7.add(GenericsRegressionTest_1_7.class);
+ since_1_7.add(PolymorphicSignatureTest.class);
+ since_1_7.add(Compliance_1_7.class);
+
+ ArrayList since_1_8 = new ArrayList();
+ since_1_8.add(NegativeTypeAnnotationTest.class);
+ since_1_8.add(NegativeLambdaExpressionsTest.class);
+ since_1_8.add(DefaultMethodsTest.class);
// Build final test suite
TestSuite all = new TestSuite(TestAll.class.getName());
@@ -175,14 +194,7 @@
tests_1_7.addAll(since_1_4);
tests_1_7.addAll(since_1_5);
tests_1_7.addAll(since_1_6);
- tests_1_7.add(AssignmentTest_1_7.class);
- tests_1_7.add(BinaryLiteralTest.class);
- tests_1_7.add(UnderscoresInLiteralsTest.class);
- tests_1_7.add(TryStatement17Test.class);
- tests_1_7.add(TryWithResourcesStatementTest.class);
- tests_1_7.add(GenericsRegressionTest_1_7.class);
- tests_1_7.add(PolymorphicSignatureTest.class);
- tests_1_7.add(Compliance_1_7.class);
+ tests_1_7.addAll(since_1_7);
// Reset forgotten subsets tests
TestCase.TESTS_PREFIX = null;
TestCase.TESTS_NAMES = null;
@@ -191,6 +203,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)standardTests.clone();
+ tests_1_8.addAll(since_1_4);
+ tests_1_8.addAll(since_1_5);
+ tests_1_8.addAll(since_1_6);
+ tests_1_8.addAll(since_1_7);
+ tests_1_8.addAll(since_1_8);
+ // 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));
+ }
all.addTest(new TestSuite(Jsr14Test.class));
return all;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
index 0678867..40e9d8b 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.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
@@ -36,6 +40,7 @@
public static final int F_1_5 = 0x04;
public static final int F_1_6 = 0x08;
public static final int F_1_7 = 0x10;
+ public static final int F_1_8 = 0x20;
public static final boolean RUN_JAVAC = CompilerOptions.ENABLED.equals(System.getProperty("run.javac"));
private static final int UNINITIALIZED = -1;
@@ -74,6 +79,9 @@
if ((complianceLevels & AbstractCompilerTest.F_1_7) != 0) {
suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.JDK1_7));
}
+ if ((complianceLevels & AbstractCompilerTest.F_1_8) != 0) {
+ suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.JDK1_8));
+ }
}
/**
@@ -104,6 +112,9 @@
if ((complianceLevels & AbstractCompilerTest.F_1_7) != 0) {
suite.addTest(buildComplianceTestSuite(testClasses, setupClass, ClassFileConstants.JDK1_7));
}
+ if ((complianceLevels & AbstractCompilerTest.F_1_8) != 0) {
+ suite.addTest(buildComplianceTestSuite(testClasses, setupClass, ClassFileConstants.JDK1_8));
+ }
return suite;
}
@@ -215,6 +226,14 @@
suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.JDK1_7));
}
}
+ int level18 = complianceLevels & AbstractCompilerTest.F_1_8;
+ if (level18 != 0) {
+ if (level18 < minimalCompliance) {
+ System.err.println("Cannot run "+evaluationTestClass.getName()+" at compliance "+CompilerOptions.versionFromJdkLevel(ClassFileConstants.JDK1_8)+"!");
+ } else {
+ suite.addTest(buildUniqueComplianceTestSuite(evaluationTestClass, ClassFileConstants.JDK1_8));
+ }
+ }
return suite;
}
@@ -259,6 +278,9 @@
*/
public static long highestComplianceLevels() {
int complianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
+ if ((complianceLevels & AbstractCompilerTest.F_1_8) != 0) {
+ return ClassFileConstants.JDK1_8;
+ }
if ((complianceLevels & AbstractCompilerTest.F_1_7) != 0) {
return ClassFileConstants.JDK1_7;
}
@@ -291,6 +313,8 @@
possibleComplianceLevels = F_1_6;
} else if (CompilerOptions.VERSION_1_7.equals(compliance)) {
possibleComplianceLevels = F_1_7;
+ } else if (CompilerOptions.VERSION_1_8.equals(compliance)) {
+ possibleComplianceLevels = F_1_8;
} else {
System.out.println("Invalid compliance specified (" + compliance + ")");
System.out.print("Use one of ");
@@ -298,7 +322,8 @@
System.out.print(CompilerOptions.VERSION_1_4 + ", ");
System.out.print(CompilerOptions.VERSION_1_5 + ", ");
System.out.print(CompilerOptions.VERSION_1_6 + ", ");
- System.out.println(CompilerOptions.VERSION_1_7);
+ System.out.print(CompilerOptions.VERSION_1_7 + ", ");
+ System.out.println(CompilerOptions.VERSION_1_8);
System.out.println("Defaulting to all possible compliances");
}
}
@@ -325,6 +350,10 @@
if (canRun1_7) {
possibleComplianceLevels |= F_1_7;
}
+ boolean canRun1_8 = canRun1_7 && !CompilerOptions.VERSION_1_7.equals(specVersion);
+ if (canRun1_8) {
+ possibleComplianceLevels |= F_1_8;
+ }
} else if ("1.0".equals(specVersion)
|| CompilerOptions.VERSION_1_1.equals(specVersion)
|| CompilerOptions.VERSION_1_2.equals(specVersion)
@@ -337,6 +366,9 @@
possibleComplianceLevels |= F_1_6;
if (!CompilerOptions.VERSION_1_6.equals(specVersion)) {
possibleComplianceLevels |= F_1_7;
+ if (!CompilerOptions.VERSION_1_7.equals(specVersion)) {
+ possibleComplianceLevels |= F_1_8;
+ }
}
}
}
@@ -465,6 +497,10 @@
options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7);
options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7);
options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
+ } else if (this.complianceLevel == ClassFileConstants.JDK1_8) {
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8);
+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
}
return options;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/workspace/Test380112.jar b/org.eclipse.jdt.core.tests.compiler/workspace/Test380112.jar
new file mode 100644
index 0000000..856a711
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/workspace/Test380112.jar
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java
index 03c13be..14fc55e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java
@@ -776,7 +776,7 @@
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=129909
- public void test0014() throws JavaModelException {
+ public void _test0014() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Converter/src/test/X.java",
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
index d33456b..39a4870 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java
@@ -5,6 +5,10 @@
* 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
*******************************************************************************/
@@ -7204,7 +7208,7 @@
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, result.getNodeType()); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
String expectedOutput =
- "Syntax error on token \",\", invalid VariableInitializer";
+ "Syntax error on token \",\", invalid Expression";
assertProblemsSize(compilationUnit, 1, expectedOutput);
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertEquals("Not a compilation unit", ASTNode.FIELD_DECLARATION, node.getNodeType()); //$NON-NLS-1$
@@ -7223,7 +7227,7 @@
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, result.getNodeType()); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
String expectedOutput =
- "Syntax error on token \",\", invalid VariableInitializer";
+ "Syntax error on token \",\", invalid Expression";
assertProblemsSize(compilationUnit, 1, expectedOutput);
}
/**
@@ -7561,7 +7565,7 @@
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=129330
*/
- public void test0642() throws JavaModelException {
+ public void _test0642() throws JavaModelException {
ICompilationUnit workingCopy = null;
try {
String contents =
@@ -7649,7 +7653,7 @@
true);
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
CompilationUnit unit = (CompilationUnit) node;
- assertProblemsSize(unit, 1, "Syntax error on token \"=\", VariableInitializer expected after this token");
+ assertProblemsSize(unit, 1, "Syntax error on token \"=\", Expression expected after this token");
node = getASTNode(unit, 0, 0, 0);
assertEquals("Not a vaviable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType());
VariableDeclarationStatement statement = (VariableDeclarationStatement) node;
@@ -7930,7 +7934,7 @@
* @bug 149126: IllegalArgumentException in ASTConverter
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=149126"
*/
- public void test0652() throws CoreException {
+ public void _test0652() throws CoreException {
ASTResult result = this.buildMarkedAST(
"/Converter/src/TestCharset.java",
"import java.nio.ByteBuffer;\n" +
@@ -8277,7 +8281,7 @@
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=157570
*/
- public void test0658() {
+ public void _test0658() {
String src = "public static void m1()\n" +
" {\n" +
" int a;\n" +
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST4_2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST4_2.java
index a19d196..4d07c73 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST4_2.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST4_2.java
@@ -4,6 +4,11 @@
* 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
@@ -7201,7 +7206,7 @@
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, result.getNodeType()); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
String expectedOutput =
- "Syntax error on token \",\", invalid VariableInitializer";
+ "Syntax error on token \",\", invalid Expression";
assertProblemsSize(compilationUnit, 1, expectedOutput);
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertEquals("Not a compilation unit", ASTNode.FIELD_DECLARATION, node.getNodeType()); //$NON-NLS-1$
@@ -7220,7 +7225,7 @@
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, result.getNodeType()); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
String expectedOutput =
- "Syntax error on token \",\", invalid VariableInitializer";
+ "Syntax error on token \",\", invalid Expression";
assertProblemsSize(compilationUnit, 1, expectedOutput);
}
/**
@@ -7558,7 +7563,7 @@
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=129330
*/
- public void test0642() throws JavaModelException {
+ public void _test0642() throws JavaModelException {
ICompilationUnit workingCopy = null;
try {
String contents =
@@ -7646,7 +7651,7 @@
true);
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
CompilationUnit unit = (CompilationUnit) node;
- assertProblemsSize(unit, 1, "Syntax error on token \"=\", VariableInitializer expected after this token");
+ assertProblemsSize(unit, 1, "Syntax error on token \"=\", Expression expected after this token");
node = getASTNode(unit, 0, 0, 0);
assertEquals("Not a vaviable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType());
VariableDeclarationStatement statement = (VariableDeclarationStatement) node;
@@ -7927,7 +7932,7 @@
* @bug 149126: IllegalArgumentException in ASTConverter
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=149126"
*/
- public void test0652() throws CoreException {
+ public void _test0652() throws CoreException {
ASTResult result = this.buildMarkedAST(
"/Converter/src/TestCharset.java",
"import java.nio.ByteBuffer;\n" +
@@ -8274,7 +8279,7 @@
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=157570
*/
- public void test0658() {
+ public void _test0658() {
String src = "public static void m1()\n" +
" {\n" +
" int a;\n" +
diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/336046src/p/CVS/Entries b/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/336046src/p/CVS/Entries
deleted file mode 100644
index ebc0718..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/336046src/p/CVS/Entries
+++ /dev/null
@@ -1,2 +0,0 @@
-/Bug336046.java/1.1/Fri Feb 18 10:03:10 2011//
-D
diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/336046src/p/CVS/Repository b/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/336046src/p/CVS/Repository
deleted file mode 100644
index fb591f0..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/336046src/p/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/336046src/p
diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/336046src/p/CVS/Root b/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/336046src/p/CVS/Root
deleted file mode 100644
index 2d37d16..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/336046src/p/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/src/javadoc/testBug336821/CVS/Entries b/org.eclipse.jdt.core.tests.model/workspace/Converter/src/javadoc/testBug336821/CVS/Entries
deleted file mode 100644
index 56e8e1a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/src/javadoc/testBug336821/CVS/Entries
+++ /dev/null
@@ -1,2 +0,0 @@
-/Try.java/1.1/Fri Feb 11 14:55:06 2011//
-D
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/src/javadoc/testBug336821/CVS/Repository b/org.eclipse.jdt.core.tests.model/workspace/Converter/src/javadoc/testBug336821/CVS/Repository
deleted file mode 100644
index b594a81..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/src/javadoc/testBug336821/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-org.eclipse.jdt.core.tests.model/workspace/Converter/src/javadoc/testBug336821
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/src/javadoc/testBug336821/CVS/Root b/org.eclipse.jdt.core.tests.model/workspace/Converter/src/javadoc/testBug336821/CVS/Root
deleted file mode 100644
index 2d37d16..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/src/javadoc/testBug336821/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse
diff --git a/org.eclipse.jdt.core/META-INF/MANIFEST.MF b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
index 9f7993f..94341de 100644
--- a/org.eclipse.jdt.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core; singleton:=true
-Bundle-Version: 3.8.1.v_OTDT_r210_qualifier
+Bundle-Version: 3.9.0.v_OTDT_r210_qualifier
Bundle-Activator: org.eclipse.jdt.core.JavaCore
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
index 774c9c2..41cbe91 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
@@ -5,6 +5,10 @@
* 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
* Tom Tromey - Contribution for bug 125961
@@ -1706,6 +1710,8 @@
return ClassFileConstants.JDK1_6 >= minimalSupportedVersion;
case 51 : // 1.7
return ClassFileConstants.JDK1_7 >= minimalSupportedVersion;
+ case 52 : // 1.8
+ return ClassFileConstants.JDK1_8 >= minimalSupportedVersion;
}
// unknown version
return false;
@@ -2073,6 +2079,16 @@
mode = DEFAULT;
continue;
}
+ if (currentArg.equals("-1.8") || currentArg.equals("-8") || currentArg.equals("-8.0")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (didSpecifyCompliance) {
+ throw new IllegalArgumentException(
+ this.bind("configure.duplicateCompliance", currentArg)); //$NON-NLS-1$
+ }
+ didSpecifyCompliance = true;
+ this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8);
+ mode = DEFAULT;
+ continue;
+ }
if (currentArg.equals("-d")) { //$NON-NLS-1$
if (this.destinationPath != null) {
StringBuffer errorMessage = new StringBuffer();
@@ -2510,7 +2526,10 @@
this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
} else if (currentArg.equals("1.7") || currentArg.equals("7") || currentArg.equals("7.0")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
- } else if (currentArg.equals("jsr14")) { //$NON-NLS-1$
+ } else if (currentArg.equals("1.8") || currentArg.equals("8") || currentArg.equals("8.0")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
+ }
+ else if (currentArg.equals("jsr14")) { //$NON-NLS-1$
this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_JSR14);
} else if (currentArg.equals("cldc1.1")) { //$NON-NLS-1$
this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_CLDC1_1);
@@ -2563,6 +2582,8 @@
this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
} else if (currentArg.equals("1.7") || currentArg.equals("7") || currentArg.equals("7.0")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7);
+ } else if (currentArg.equals("1.8") || currentArg.equals("8") || currentArg.equals("8.0")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8);
} else {
throw new IllegalArgumentException(this.bind("configure.source", currentArg)); //$NON-NLS-1$
}
@@ -4566,6 +4587,24 @@
this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7);
if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
}
+ } else if (CompilerOptions.VERSION_1_8.equals(version)) {
+ if (this.didSpecifySource) {
+ Object source = this.options.get(CompilerOptions.OPTION_Source);
+ if (CompilerOptions.VERSION_1_3.equals(source)
+ || CompilerOptions.VERSION_1_4.equals(source)) {
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
+ } else if (CompilerOptions.VERSION_1_5.equals(source)
+ || CompilerOptions.VERSION_1_6.equals(source)) {
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
+ } else if (CompilerOptions.VERSION_1_7.equals(source)) {
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
+ } else if (CompilerOptions.VERSION_1_8.equals(source)) {
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
+ }
+ } else {
+ this.options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8);
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
+ }
}
} else if (this.didSpecifySource) {
Object version = this.options.get(CompilerOptions.OPTION_Source);
@@ -4582,12 +4621,19 @@
} else if (CompilerOptions.VERSION_1_7.equals(version)) {
if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7);
if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
+ } else if (CompilerOptions.VERSION_1_8.equals(version)) {
+ if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8);
+ if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8);
}
}
final Object sourceVersion = this.options.get(CompilerOptions.OPTION_Source);
final Object compliance = this.options.get(CompilerOptions.OPTION_Compliance);
- if (sourceVersion.equals(CompilerOptions.VERSION_1_7)
+ if (sourceVersion.equals(CompilerOptions.VERSION_1_8)
+ && CompilerOptions.versionToJdkLevel(compliance) < ClassFileConstants.JDK1_8) {
+ // compliance must be 1.8 if source is 1.8
+ throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForSource", (String)this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_8)); //$NON-NLS-1$
+ } else if (sourceVersion.equals(CompilerOptions.VERSION_1_7)
&& CompilerOptions.versionToJdkLevel(compliance) < ClassFileConstants.JDK1_7) {
// compliance must be 1.7 if source is 1.7
throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForSource", (String)this.options.get(CompilerOptions.OPTION_Compliance), CompilerOptions.VERSION_1_7)); //$NON-NLS-1$
@@ -4622,6 +4668,11 @@
throw new IllegalArgumentException(this.bind("configure.incompatibleComplianceForCldcTarget", (String) targetVersion, (String) sourceVersion)); //$NON-NLS-1$
}
} else {
+ // target must be 1.8 if source is 1.8
+ if (CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_8
+ && CompilerOptions.versionToJdkLevel(targetVersion) < ClassFileConstants.JDK1_8){
+ throw new IllegalArgumentException(this.bind("configure.incompatibleTargetForSource", (String) targetVersion, CompilerOptions.VERSION_1_8)); //$NON-NLS-1$
+ }
// target must be 1.7 if source is 1.7
if (CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_7
&& CompilerOptions.versionToJdkLevel(targetVersion) < ClassFileConstants.JDK1_7){
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
index e06b15a..72d2f90 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
@@ -57,7 +57,7 @@
configure.duplicateCompliance = duplicate compliance setting specification: {0}
configure.duplicateSource = duplicate source compliance setting specification: {0}
configure.duplicateTarget = duplicate target compliance setting specification: {0}
-configure.source = source level should be comprised in between ''1.3'' and ''1.6'' (or ''5'', ''5.0'', ..., ''7'' or ''7.0''): {0}
+configure.source = source level should be comprised in between ''1.3'' and ''1.8'' (or ''5'', ''5.0'', ..., ''8'' or ''8.0''): {0}
configure.duplicateOutputPath = duplicate output path specification: {0}
configure.duplicateBootClasspath = duplicate bootclasspath specification: {0}
configure.duplicateExtDirs = duplicate extdirs specification: {0}
@@ -66,7 +66,7 @@
configure.invalidWarningConfiguration = invalid warning configuration: ''{0}''
configure.invalidWarning = invalid warning token: ''{0}''. Ignoring warning and compiling
configure.invalidWarningOption = invalid warning option: ''{0}''. Must specify a warning token
-configure.targetJDK = target level should be comprised in between ''1.1'' and ''1.7'' (or ''5'', ''5.0'', ..., ''7'' or ''7.0'') or cldc1.1: {0}
+configure.targetJDK = target level should be comprised in between ''1.1'' and ''1.8'' (or ''5'', ''5.0'', ..., ''8'' or ''8.0'') or cldc1.1: {0}
configure.incompatibleTargetForSource = Target level ''{0}'' is incompatible with source level ''{1}''. A target level ''{1}'' or better is required
configure.incompatibleTargetForGenericSource = Target level ''{0}'' is incompatible with source level ''{1}''. A source level ''1.5'' or better is required
configure.incompatibleComplianceForSource = Compliance level ''{0}'' is incompatible with source level ''{1}''. A compliance level ''{1}'' or better is required
@@ -188,8 +188,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\
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java
index f584192..6861b53 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 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
*******************************************************************************/
@@ -55,6 +59,12 @@
public TypeReference copyDims(int dim){
return this;
}
+/*
+ * No expansion of the completion reference into an array one
+ */
+public TypeReference copyDims(int dim, Annotation[][] annotationsOnDimensions){
+ return this;
+}
protected TypeBinding getTypeBinding(Scope scope) {
// it can be a package, type or member type
Binding binding = scope.parent.getTypeOrPackage(this.tokens); // step up from the ClassScope
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java
index 4345fd2..0278e66 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.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
*******************************************************************************/
@@ -58,6 +62,12 @@
public TypeReference copyDims(int dim){
return this;
}
+/*
+ * No expansion of the completion reference into an array one
+ */
+public TypeReference copyDims(int dim, Annotation[][] annotationsOnDimensions){
+ return this;
+}
protected TypeBinding getTypeBinding(Scope scope) {
if (this.fieldTypeCompletionNode != null) {
throw new CompletionNodeFound(this.fieldTypeCompletionNode, scope);
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
index c38f86d..faf76d4 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
@@ -5,6 +5,10 @@
* 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
* Fraunhofer FIRST - extended API and implementation
@@ -1198,9 +1202,12 @@
if(info == LESS && node instanceof TypeReference) {
if(this.identifierLengthPtr > -1 && this.identifierLengthStack[this.identifierLengthPtr]!= 0) {
if (consumeTypeArguments) consumeTypeArguments();
- TypeReference ref = this.getTypeReference(0);
+ TypeReference ref;
if(prevKind == K_PARAMETERIZED_CAST) {
+ ref = this.getUnannotatedTypeReference(0); // by design type is not annotated.
ref = computeQualifiedGenericsFromRightSide(ref, 0);
+ } else {
+ ref = this.getTypeReference(0);
}
if(this.currentElement instanceof RecoveredType) {
this.currentElement = this.currentElement.add(new CompletionOnFieldType(ref, false), 0);
@@ -1408,7 +1415,8 @@
if ((length = this.identifierLengthStack[this.identifierLengthPtr-1]) < 0) {
// build the primitive type node
int dim = isAfterArrayType() ? this.intStack[this.intPtr--] : 0;
- SingleTypeReference typeRef = (SingleTypeReference)TypeReference.baseTypeReference(-length, dim);
+ Annotation [][] annotationsOnDimensions = dim == 0 ? null : getAnnotationsOnDimensions(dim);
+ SingleTypeReference typeRef = (SingleTypeReference)TypeReference.baseTypeReference(-length, dim, annotationsOnDimensions);
typeRef.sourceStart = this.intStack[this.intPtr--];
if (dim == 0) {
typeRef.sourceEnd = this.intStack[this.intPtr--];
@@ -2399,6 +2407,33 @@
cast.sourceStart = castType.sourceStart - 1;
cast.sourceEnd = exp.sourceEnd;
}
+protected void consumeCastExpressionWithPrimitiveTypeWithTypeAnnotations() {
+ popElement(K_CAST_STATEMENT);
+
+ Expression expression = this.expressionStack[this.expressionPtr--];
+ this.expressionLengthPtr--;
+ TypeReference typeReference = (TypeReference) this.expressionStack[this.expressionPtr--];
+ this.expressionLengthPtr--;
+ int length;
+ if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
+ System.arraycopy(
+ this.expressionStack,
+ (this.expressionPtr -= length) + 1,
+ typeReference.annotations = new Annotation[length],
+ 0,
+ length);
+ int typeReferenceSourceStart = typeReference.annotations[0].sourceStart;
+ if (this.modifiersSourceStart < typeReferenceSourceStart) {
+ typeReferenceSourceStart = this.modifiersSourceStart;
+ }
+ typeReference.sourceStart = typeReferenceSourceStart;
+ }
+
+ Expression cast;
+ pushOnExpressionStack(cast = new CastExpression(expression, typeReference));
+ cast.sourceStart = typeReference.sourceStart - 1;
+ cast.sourceEnd = expression.sourceEnd;
+}
protected void consumeCastExpressionWithGenericsArray() {
popElement(K_CAST_STATEMENT);
@@ -2411,7 +2446,35 @@
cast.sourceStart = castType.sourceStart - 1;
cast.sourceEnd = exp.sourceEnd;
}
+protected void consumeCastExpressionWithGenericsArrayWithTypeAnnotations() {
+ popElement(K_CAST_STATEMENT);
+
+ Expression exp = this.expressionStack[this.expressionPtr--];
+ this.expressionLengthPtr--;
+ // pop the type reference
+ TypeReference typeReference = (TypeReference) this.expressionStack[this.expressionPtr--];
+ this.expressionLengthPtr--;
+ int length;
+ if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
+ System.arraycopy(
+ this.expressionStack,
+ (this.expressionPtr -= length) + 1,
+ typeReference.annotations = new Annotation[length],
+ 0,
+ length);
+ int typeReferenceSourceStart = typeReference.annotations[0].sourceStart;
+ if (this.modifiersSourceStart < typeReferenceSourceStart) {
+ typeReferenceSourceStart = this.modifiersSourceStart;
+ }
+ typeReference.sourceStart = typeReferenceSourceStart;
+ }
+
+ Expression cast;
+ pushOnExpressionStack(cast = new CastExpression(exp, typeReference));
+ cast.sourceStart = typeReference.sourceStart - 1;
+ cast.sourceEnd = exp.sourceEnd;
+}
protected void consumeCastExpressionWithQualifiedGenericsArray() {
popElement(K_CAST_STATEMENT);
@@ -2424,6 +2487,32 @@
cast.sourceStart = castType.sourceStart - 1;
cast.sourceEnd = exp.sourceEnd;
}
+protected void consumeCastExpressionWithQualifiedGenericsArrayWithTypeAnnotations() {
+ popElement(K_CAST_STATEMENT);
+
+ Expression expression = this.expressionStack[this.expressionPtr--];
+ this.expressionLengthPtr--;
+ TypeReference typeReference = (TypeReference) this.expressionStack[this.expressionPtr--];
+ this.expressionLengthPtr--;
+ int length;
+ if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
+ System.arraycopy(
+ this.expressionStack,
+ (this.expressionPtr -= length) + 1,
+ typeReference.annotations = new Annotation[length],
+ 0,
+ length);
+ int typeReferenceSourceStart = typeReference.annotations[0].sourceStart;
+ if (this.modifiersSourceStart < typeReferenceSourceStart) {
+ typeReferenceSourceStart = this.modifiersSourceStart;
+ }
+ typeReference.sourceStart = typeReferenceSourceStart;
+ }
+ Expression cast;
+ pushOnExpressionStack(cast = new CastExpression(expression, typeReference));
+ cast.sourceStart = typeReference.sourceStart - 1;
+ cast.sourceEnd = expression.sourceEnd;
+}
protected void consumeCastExpressionWithNameArray() {
// CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
popElement(K_CAST_STATEMENT);
@@ -2437,10 +2526,41 @@
cast.sourceStart = castType.sourceStart - 1;
cast.sourceEnd = exp.sourceEnd;
}
+protected void consumeCastExpressionWithNameArrayWithTypeAnnotations() {
+ popElement(K_CAST_STATEMENT);
+
+ Expression expression = this.expressionStack[this.expressionPtr--];
+ this.expressionLengthPtr--;
+ TypeReference typeReference = (TypeReference) this.expressionStack[this.expressionPtr--];
+ this.expressionLengthPtr--;
+
+ int length;
+ if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
+ System.arraycopy(
+ this.expressionStack,
+ (this.expressionPtr -= length) + 1,
+ typeReference.annotations = new Annotation[length],
+ 0,
+ length);
+ int typeReferenceSourceStart = typeReference.annotations[0].sourceStart;
+ if (this.modifiersSourceStart < typeReferenceSourceStart) {
+ typeReferenceSourceStart = this.modifiersSourceStart;
+ }
+ typeReference.sourceStart = typeReferenceSourceStart;
+ }
+ Expression cast;
+ pushOnExpressionStack(cast = new CastExpression(expression, typeReference));
+ cast.sourceStart = typeReference.sourceStart - 1;
+ cast.sourceEnd = expression.sourceEnd;
+}
protected void consumeCastExpressionLL1() {
popElement(K_CAST_STATEMENT);
super.consumeCastExpressionLL1();
}
+protected void consumeCastExpressionLL1WithTypeAnnotations() {
+ popElement(K_CAST_STATEMENT);
+ super.consumeCastExpressionLL1WithTypeAnnotations();
+}
protected void consumeCatchFormalParameter() {
if (this.indexOfAssistIdentifier() < 0) {
super.consumeCatchFormalParameter();
@@ -2920,6 +3040,10 @@
// SH}
}
protected void consumeFormalParameter(boolean isVarArgs) {
+
+ this.invocationType = NO_RECEIVER;
+ this.qualifier = -1;
+
if (this.indexOfAssistIdentifier() < 0) {
super.consumeFormalParameter(isVarArgs);
if (this.pendingAnnotation != null) {
@@ -2927,7 +3051,11 @@
this.pendingAnnotation = null;
}
} else {
-
+ boolean isReceiver = this.intStack[this.intPtr--] == 0;
+ if (isReceiver) {
+ this.expressionPtr--;
+ this.expressionLengthPtr --;
+ }
this.identifierLengthPtr--;
char[] identifierName = this.identifierStack[this.identifierPtr];
long namePositions = this.identifierPositionStack[this.identifierPtr--];
@@ -2937,10 +3065,31 @@
endOfEllipsis = this.intStack[this.intPtr--];
}
int firstDimensions = this.intStack[this.intPtr--];
- final int typeDimensions = firstDimensions + extendedDimensions;
- TypeReference type = getTypeReference(typeDimensions);
+ TypeReference type = getUnannotatedTypeReference(extendedDimensions);
+ Annotation [] varArgsAnnotations = null;
+ int length;
+ if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
+ System.arraycopy(
+ this.typeAnnotationStack,
+ (this.typeAnnotationPtr -= length) + 1,
+ varArgsAnnotations = new Annotation[length],
+ 0,
+ length);
+ }
+ final int typeDimensions = firstDimensions + extendedDimensions + (isVarArgs ? 1 : 0);
+ if (typeDimensions != extendedDimensions) {
+ // jsr308 type annotations management
+ Annotation [][] annotationsOnFirstDimensions = firstDimensions == 0 ? null : getAnnotationsOnDimensions(firstDimensions);
+ Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : type.getAnnotationsOnDimensions();
+ Annotation [][] annotationsOnAllDimensions = null;
+ if (annotationsOnFirstDimensions != null || annotationsOnExtendedDimensions != null || varArgsAnnotations != null) {
+ annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions, annotationsOnFirstDimensions, extendedDimensions, annotationsOnExtendedDimensions);
+ annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions + extendedDimensions, annotationsOnAllDimensions, isVarArgs ? 1 : 0, isVarArgs ? new Annotation[][]{varArgsAnnotations} : null);
+ }
+ type = copyDims(type, typeDimensions, annotationsOnAllDimensions);
+ type.sourceEnd = type.isParameterizedTypeReference() ? this.endStatementPosition : this.endPosition;
+ }
if (isVarArgs) {
- type = copyDims(type, typeDimensions + 1);
if (extendedDimensions == 0) {
type.sourceEnd = endOfEllipsis;
}
@@ -2954,7 +3103,6 @@
type,
this.intStack[this.intPtr + 1] & ~ClassFileConstants.AccDeprecated); // modifiers
// consume annotations
- int length;
if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
System.arraycopy(
this.expressionStack,
@@ -3056,6 +3204,24 @@
}
pushOnElementStack(K_CAST_STATEMENT);
}
+protected void consumeInsideCastExpressionWithAnnotatedQualifiedGenerics() {
+ popElement(K_PARAMETERIZED_CAST);
+
+ Expression castType;
+ int end = this.intStack[this.intPtr--];
+
+ int dim = this.intStack[this.intPtr--];
+ // TODO is it an annotated type reference?
+ TypeReference rightSide = getUnannotatedTypeReference(0); // by design the type after . is not annotated.
+
+ castType = computeQualifiedGenericsFromRightSide(rightSide, dim);
+ this.intPtr--;
+ castType.sourceEnd = end - 1;
+ castType.sourceStart = this.intStack[this.intPtr--] + 1;
+ pushOnExpressionStack(castType);
+
+ pushOnElementStack(K_CAST_STATEMENT);
+}
protected void consumeInsideCastExpressionWithQualifiedGenerics() {
popElement(K_PARAMETERIZED_CAST);
@@ -3063,7 +3229,7 @@
int end = this.intStack[this.intPtr--];
int dim = this.intStack[this.intPtr--];
- TypeReference rightSide = getTypeReference(0);
+ TypeReference rightSide = getUnannotatedTypeReference(0); // by design the type after . is not annotated.
castType = computeQualifiedGenericsFromRightSide(rightSide, dim);
this.intPtr--;
@@ -4809,6 +4975,16 @@
}
return result;
}
+protected TypeReference copyDims(TypeReference typeRef, int dim, Annotation[][] annotationsOnDimensions) {
+ if (this.assistNode == typeRef) {
+ return typeRef;
+ }
+ TypeReference result = super.copyDims(typeRef, dim, annotationsOnDimensions);
+ if (this.assistNodeParent == typeRef) {
+ this.assistNodeParent = result;
+ }
+ return result;
+}
public CompilationUnitDeclaration dietParse(ICompilationUnit sourceUnit, CompilationResult compilationResult, int cursorLoc) {
this.cursorLocation = cursorLoc;
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java
index 88a632d..a48a96d 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.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
- * $Id: CompletionScanner.java 22741 2009-10-13 22:23:05Z stephan $
+ *
+ * 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
@@ -105,7 +109,7 @@
}
return super.getCurrentTokenSourceString();
}
-public int getNextToken() throws InvalidInputException {
+protected int getNextToken0() throws InvalidInputException {
this.wasAcr = false;
this.unicodeCharSize = 0;
@@ -257,13 +261,15 @@
return TokenNameMINUS_MINUS;
if (test > 0)
return TokenNameMINUS_EQUAL;
-//{ObjectTeams: check for callout binding after '-' tokens
- else {
- if (test < 0 && this._isOTSource)
- if (getNextChar('>')) {
- this._calloutSeen = true;
- return TokenNameBINDOUT;
- }
+//{ObjectTeams: set _calloutSeen?
+/* orig:
+ if (getNextChar('>'))
+ return TokenNameARROW;
+ :giro */
+ if (getNextChar('>')) {
+ if (this._isOTSource)
+ this._calloutSeen = true;
+ return TokenNameARROW;
}
// Markus Witte}
return TokenNameMINUS;
@@ -368,6 +374,8 @@
case '?' :
return TokenNameQUESTION;
case ':' :
+ if (getNextChar(':'))
+ return TokenNameCOLON_COLON;
return TokenNameCOLON;
case '\'' :
{
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
index 5a2bedf..f1b11a2 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.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
* Fraunhofer FIRST - extended API and implementation
@@ -981,20 +985,21 @@
/*
* Build specific type reference nodes in case the cursor is located inside the type reference
*/
-protected TypeReference getTypeReference(int dim) {
+protected TypeReference getUnannotatedTypeReference(int dim) {
//{ObjectTeams: wrap to introduce 2nd parameter
- return getTypeReference(dim, false);
+ return getUnannotatedTypeReference(dim, false);
}
-protected TypeReference getTypeReference(int dim, boolean liftingTypeAllowed) {
+protected TypeReference getUnannotatedTypeReference(int dim, boolean liftingTypeAllowed) {
// orig:
int index;
/* no need to take action if not inside completed identifiers */
if ((index = indexOfAssistIdentifier(true)) < 0) {
-/*
- return super.getTypeReference(dim);
- :giro */
- return super.getTypeReference(dim, liftingTypeAllowed);
+// orig: FIXME
+ return super.getUnannotatedTypeReference(dim);
+// :giro */
+// OT PREVIOUS:
+// return super.getUnannotatedTypeReference(dim, liftingTypeAllowed);
// SH}
}
int length = this.identifierLengthStack[this.identifierLengthPtr];
@@ -1801,6 +1806,9 @@
this.astLengthPtr = -1;
this.expressionPtr = -1;
this.expressionLengthPtr = -1;
+ this.unattachedAnnotationPtr = -1;
+ this.typeAnnotationLengthPtr = -1;
+ this.typeAnnotationPtr = -1;
this.identifierPtr = -1;
this.identifierLengthPtr = -1;
this.intPtr = -1;
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
index 930a18d..20e1d60 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.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
* Fraunhofer FIRST - extended API and implementation
@@ -349,9 +353,6 @@
arg.annotations = new Annotation[length],
0,
length);
- RecoveredType currentRecoveryType = this.currentRecoveryType();
- if (currentRecoveryType != null)
- currentRecoveryType.annotationsConsumed(arg.annotations);
}
pushOnAstStack(arg);
@@ -635,6 +636,11 @@
}
}
} else {
+ boolean isReceiver = this.intStack[this.intPtr--] == 0;
+ if (isReceiver) {
+ this.expressionPtr--;
+ this.expressionLengthPtr --;
+ }
this.identifierLengthPtr--;
char[] identifierName = this.identifierStack[this.identifierPtr];
long namePositions = this.identifierPositionStack[this.identifierPtr--];
@@ -644,10 +650,31 @@
endOfEllipsis = this.intStack[this.intPtr--];
}
int firstDimensions = this.intStack[this.intPtr--];
- final int typeDimensions = firstDimensions + extendedDimensions;
- TypeReference type = getTypeReference(typeDimensions);
+ TypeReference type = getUnannotatedTypeReference(extendedDimensions);
+ Annotation [] varArgsAnnotations = null;
+ int length;
+ if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
+ System.arraycopy(
+ this.typeAnnotationStack,
+ (this.typeAnnotationPtr -= length) + 1,
+ varArgsAnnotations = new Annotation[length],
+ 0,
+ length);
+ }
+ final int typeDimensions = firstDimensions + extendedDimensions + (isVarArgs ? 1 : 0);
+ if (typeDimensions != extendedDimensions) {
+ // jsr308 type annotations management
+ Annotation [][] annotationsOnFirstDimensions = firstDimensions == 0 ? null : getAnnotationsOnDimensions(firstDimensions);
+ Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : type.getAnnotationsOnDimensions();
+ Annotation [][] annotationsOnAllDimensions = null;
+ if (annotationsOnFirstDimensions != null || annotationsOnExtendedDimensions != null || varArgsAnnotations != null) {
+ annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions, annotationsOnFirstDimensions, extendedDimensions, annotationsOnExtendedDimensions);
+ annotationsOnAllDimensions = getMergedAnnotationsOnDimensions(firstDimensions + extendedDimensions, annotationsOnAllDimensions, isVarArgs ? 1 : 0, isVarArgs ? new Annotation[][]{varArgsAnnotations} : null);
+ }
+ type = copyDims(type, typeDimensions, annotationsOnAllDimensions);
+ type.sourceEnd = type.isParameterizedTypeReference() ? this.endStatementPosition : this.endPosition;
+ }
if (isVarArgs) {
- type = copyDims(type, typeDimensions + 1);
if (extendedDimensions == 0) {
type.sourceEnd = endOfEllipsis;
}
@@ -664,7 +691,6 @@
arg.declarationSourceStart = modifierPositions;
// consume annotations
- int length;
if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
System.arraycopy(
this.expressionStack,
@@ -672,6 +698,9 @@
arg.annotations = new Annotation[length],
0,
length);
+ RecoveredType currentRecoveryType = this.currentRecoveryType();
+ if (currentRecoveryType != null)
+ currentRecoveryType.annotationsConsumed(arg.annotations);
}
pushOnAstStack(arg);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
index f72b0d8..6b6f798 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
@@ -4,7 +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
- * $Id: IProblem.java 23306 2010-01-23 13:45:42Z stephan $
+ *
+ * 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
@@ -152,6 +155,7 @@
* UninitializedLocalVariableHintMissingDefault
* UninitializedBlankFinalFieldHintMissingDefault
* ShouldReturnValueHintMissingDefault
+ * IllegalModifierForInterfaceDefaultMethod
*******************************************************************************/
package org.eclipse.jdt.core.compiler;
@@ -1292,7 +1296,33 @@
int UnusedWarningToken = Internal + 635;
/** @since 3.6 */
int MissingOverrideAnnotationForInterfaceMethodImplementation = MethodRelated + 636;
-
+ /** @since 3.9 */
+ int InvalidUsageOfTypeAnnotations = Syntax + Internal + 637;
+ /** @since 3.9 */
+ int InvalidUsageOfReceiverAnnotations = Syntax + Internal + 638;
+ /** @since 3.9 */
+ int MisplacedTypeAnnotations = Syntax + Internal + 639;
+ /** @since 3.9 */
+ int InvalidLocationForModifiers = Syntax + Internal + 640;
+ /** @since 3.9*/
+ int IllegalUsageOfTypeAnnotations = Internal + Syntax + 641;
+ /** @since 3.9*/
+ int IllegalDeclarationOfThisParameter = Internal + Syntax + 642;
+ /** @since 3.9*/
+ int ExplicitThisParameterNotBelow18 = Internal + Syntax + 643;
+ /** @since 3.9*/
+ int DefaultMethodNotBelow18 = Internal + Syntax + 644;
+ /** @since 3.9*/
+ int LambdaExpressionNotBelow18 = Internal + Syntax + 645;
+ /** @since 3.9*/
+ int MethodReferenceNotBelow18 = Internal + Syntax + 646;
+ /** @since 3.9*/
+ int ConstructorReferenceNotBelow18 = Internal + Syntax + 647;
+ /** @since 3.9*/
+ int ExplicitThisParameterNotInLambda = Internal + Syntax + 648;
+ /** @since 3.9 */
+ int ExplicitAnnotationTargetRequired = TypeRelated + 649;
+
/**
* More problems in generics
*/
@@ -1508,6 +1538,15 @@
int SpecdNonNullLocalVariableComparisonYieldsFalse = Internal + 932;
/** @since 3.8 */
int RequiredNonNullButProvidedSpecdNullable = Internal + 933;
+
+
+ // Java 8 work
+ /** @since 3.9 */
+ int IllegalModifiersForElidedType = Internal + 1001;
+
+ // default methods:
+ /** @since 3.9 */
+ int IllegalModifierForInterfaceDefaultMethod = MethodRelated + 1050;
/**
* External problems -- These are problems defined by other plugins
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ASTVisitor.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ASTVisitor.java
index f07f838..2a624dd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ASTVisitor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ASTVisitor.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
* Fraunhofer FIRST - extended API and implementation
@@ -67,6 +71,9 @@
public void endVisit(ArrayInitializer arrayInitializer, BlockScope scope) {
// do nothing by default
}
+ public void endVisit(ArrayInitializer arrayInitializer, ClassScope scope) {
+ // do nothing by default
+ }
public void endVisit(
ArrayQualifiedTypeReference arrayQualifiedTypeReference,
BlockScope scope) {
@@ -287,12 +294,26 @@
// do nothing by default
}
/**
+ * @param annotation
+ * @param scope
+ */
+ public void endVisit(MarkerAnnotation annotation, ClassScope scope) {
+ // do nothing by default
+ }
+ /**
* @param pair
* @param scope
*/
public void endVisit(MemberValuePair pair, BlockScope scope) {
// do nothing by default
}
+ /**
+ * @param pair
+ * @param scope
+ */
+ public void endVisit(MemberValuePair pair, ClassScope scope) {
+ // do nothing by default
+ }
public void endVisit(MessageSend messageSend, BlockScope scope) {
// do nothing by default
}
@@ -310,6 +331,9 @@
public void endVisit(NormalAnnotation annotation, BlockScope scope) {
// do nothing by default
}
+ public void endVisit(NormalAnnotation annotation, ClassScope scope) {
+ // do nothing by default
+ }
public void endVisit(NullLiteral nullLiteral, BlockScope scope) {
// do nothing by default
}
@@ -390,6 +414,13 @@
public void endVisit(SingleMemberAnnotation annotation, BlockScope scope) {
// do nothing by default
}
+ /**
+ * @param annotation
+ * @param scope
+ */
+ public void endVisit(SingleMemberAnnotation annotation, ClassScope scope) {
+ // do nothing by default
+ }
public void endVisit(
SingleNameReference singleNameReference,
BlockScope scope) {
@@ -545,6 +576,9 @@
public boolean visit(ArrayInitializer arrayInitializer, BlockScope scope) {
return true; // do nothing by default, keep traversing
}
+ public boolean visit(ArrayInitializer arrayInitializer, ClassScope scope) {
+ return true; // do nothing by default, keep traversing
+ }
public boolean visit(
ArrayQualifiedTypeReference arrayQualifiedTypeReference,
BlockScope scope) {
@@ -765,6 +799,13 @@
return true;
}
/**
+ * @param annotation
+ * @param scope
+ */
+ public boolean visit(MarkerAnnotation annotation, ClassScope scope) {
+ return true;
+ }
+ /**
* @param pair
* @param scope
* @since 3.1
@@ -772,6 +813,13 @@
public boolean visit(MemberValuePair pair, BlockScope scope) {
return true;
}
+ /**
+ * @param pair
+ * @param scope
+ */
+ public boolean visit(MemberValuePair pair, ClassScope scope) {
+ return true;
+ }
public boolean visit(MessageSend messageSend, BlockScope scope) {
return true; // do nothing by default, keep traversing
}
@@ -791,6 +839,13 @@
public boolean visit(NormalAnnotation annotation, BlockScope scope) {
return true;
}
+ /**
+ * @param annotation
+ * @param scope
+ */
+ public boolean visit(NormalAnnotation annotation, ClassScope scope) {
+ return true;
+ }
public boolean visit(NullLiteral nullLiteral, BlockScope scope) {
return true; // do nothing by default, keep traversing
}
@@ -871,6 +926,13 @@
public boolean visit(SingleMemberAnnotation annotation, BlockScope scope) {
return true;
}
+ /**
+ * @param annotation
+ * @param scope
+ */
+ public boolean visit(SingleMemberAnnotation annotation, ClassScope scope) {
+ return true;
+ }
public boolean visit(
SingleNameReference singleNameReference,
BlockScope scope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
index 5a71ec3..5d22c4b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -4,7 +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
- * $Id: ClassFile.java 23404 2010-02-03 14:10:22Z stephan $
+ *
+ * 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
@@ -291,6 +294,11 @@
} else {
this.codeStream = new CodeStream(this);
}
+ if (this.targetJDK == ClassFileConstants.JDK1_8) {
+ //TODO JAVA8: Version number is not yet updated in the java8 beta...
+ //Remove this after it is upgraded
+ this.targetJDK = ClassFileConstants.JDK1_7;
+ }
initByteArrays();
}
@@ -4297,6 +4305,11 @@
this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3
this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
}
+ if (this.targetJDK == ClassFileConstants.JDK1_8) {
+ //TODO JAVA8: Version number is not yet updated in the java8 beta...
+ //Remove this after it is upgraded
+ this.targetJDK = ClassFileConstants.JDK1_7;
+ }
this.bytes = null;
this.constantPool.reset();
this.codeStream.reset(this);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index f9b4f3d..b769a69 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -5,6 +5,10 @@
* 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
* Matt McCutchen - partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=122995
@@ -41,8 +45,8 @@
// storage for internal flags (32 bits) BIT USAGE
public final static int Bit1 = 0x1; // return type (operator) | name reference kind (name ref) | add assertion (type decl) | useful empty statement (empty statement)
- public final static int Bit2 = 0x2; // return type (operator) | name reference kind (name ref) | has local type (type, method, field decl)
- public final static int Bit3 = 0x4; // return type (operator) | name reference kind (name ref) | implicit this (this ref)
+ public final static int Bit2 = 0x2; // return type (operator) | name reference kind (name ref) | has local type (type, method, field decl) | if type elided (local)
+ public final static int Bit3 = 0x4; // return type (operator) | name reference kind (name ref) | implicit this (this ref) | is argument(local)
public final static int Bit4 = 0x8; // return type (operator) | first assignment to local (name ref,local decl) | undocumented empty block (block, type and method decl)
public final static int Bit5 = 0x10; // value for return (expression) | has all method bodies (unit) | supertype ref (type ref) | resolved (field decl)
public final static int Bit6 = 0x20; // depth (name ref, msg) | ignore need cast check (cast expression) | error in signature (method declaration/ initializer) | is recovered (annotation reference)
@@ -127,7 +131,9 @@
public static final int RestrictiveFlagMASK = Bit1|Bit2|Bit3;
// for local decls
+ public static final int IsTypeElided = Bit2; // type elided lambda argument.
public static final int IsArgument = Bit3;
+ public static final int IsLocalDeclarationReachable = Bit31;
// for name refs or local decls
public static final int FirstAssignmentToLocal = Bit4;
@@ -148,8 +154,6 @@
public static final int DocumentedFallthrough = Bit30; // switch statement
public static final int DocumentedCasesOmitted = Bit31; // switch statement
- // local decls
- public static final int IsLocalDeclarationReachable = Bit31;
// try statements
public static final int IsSubRoutineEscaping = Bit15;
@@ -278,6 +282,9 @@
public static final int INVOCATION_ARGUMENT_UNCHECKED = 1;
public static final int INVOCATION_ARGUMENT_WILDCARD = 2;
+ // for all declarations that can contain type references that have type annotations
+ public static final int HasTypeAnnotations = Bit21;
+
// for type reference (diamond case) - Java 7
public static final int IsUnionType = Bit30;
// Used to tag ParameterizedSingleTypeReference or ParameterizedQualifiedTypeReference when they are
@@ -578,8 +585,15 @@
public static StringBuffer printAnnotations(Annotation[] annotations, StringBuffer output) {
int length = annotations.length;
for (int i = 0; i < length; i++) {
- annotations[i].print(0, output);
- output.append(" "); //$NON-NLS-1$
+ if (i > 0) {
+ output.append(" "); //$NON-NLS-1$
+ }
+ Annotation annotation2 = annotations[i];
+ if (annotation2 != null) {
+ annotation2.print(0, output);
+ } else {
+ output.append('?');
+ }
}
return output;
}
@@ -691,6 +705,25 @@
local.setAnnotations(annotations, scope);
}
break;
+ case Binding.TYPE_PARAMETER :
+ // jsr308
+ ReferenceBinding typeVariableBinding = (ReferenceBinding) recipient;
+ if ((typeVariableBinding.tagBits & TagBits.AnnotationResolved) != 0) return;
+ typeVariableBinding.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
+ if (length > 0) {
+ annotations = new AnnotationBinding[length];
+ typeVariableBinding.setAnnotations(annotations);
+ }
+ break;
+ case Binding.TYPE_USE :
+ ReferenceBinding typeUseBinding = (ReferenceBinding) recipient;
+ if ((typeUseBinding.tagBits & TagBits.AnnotationResolved) != 0) return;
+ typeUseBinding.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
+ if (length > 0) {
+ annotations = new AnnotationBinding[length];
+ typeUseBinding.setAnnotations(annotations);
+ }
+ break;
default :
return;
}
@@ -787,6 +820,122 @@
}
}
+ /**
+ * Resolve annotations, and check duplicates, answers combined tagBits
+ * for recognized standard annotations
+ */
+ public static void resolveAnnotations(ClassScope scope, Annotation[] sourceAnnotations, Binding recipient) {
+ AnnotationBinding[] annotations = null;
+ int length = sourceAnnotations == null ? 0 : sourceAnnotations.length;
+ if (recipient != null) {
+ switch (recipient.kind()) {
+ case Binding.PACKAGE :
+ PackageBinding packageBinding = (PackageBinding) recipient;
+ if ((packageBinding.tagBits & TagBits.AnnotationResolved) != 0) return;
+ packageBinding.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
+ break;
+ case Binding.TYPE :
+ case Binding.GENERIC_TYPE :
+ ReferenceBinding type = (ReferenceBinding) recipient;
+ if ((type.tagBits & TagBits.AnnotationResolved) != 0) return;
+ type.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
+ if (length > 0) {
+ annotations = new AnnotationBinding[length];
+ type.setAnnotations(annotations);
+ }
+ break;
+ case Binding.METHOD :
+ MethodBinding method = (MethodBinding) recipient;
+ if ((method.tagBits & TagBits.AnnotationResolved) != 0) return;
+ method.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
+ if (length > 0) {
+ annotations = new AnnotationBinding[length];
+ method.setAnnotations(annotations);
+ }
+ break;
+ case Binding.FIELD :
+ FieldBinding field = (FieldBinding) recipient;
+ if ((field.tagBits & TagBits.AnnotationResolved) != 0) return;
+ field.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
+ if (length > 0) {
+ annotations = new AnnotationBinding[length];
+ field.setAnnotations(annotations);
+ }
+ break;
+ case Binding.LOCAL :
+ LocalVariableBinding local = (LocalVariableBinding) recipient;
+ if ((local.tagBits & TagBits.AnnotationResolved) != 0) return;
+ local.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
+ if (length > 0) {
+ annotations = new AnnotationBinding[length];
+ local.setAnnotations(annotations, scope);
+ }
+ break;
+ default :
+ return;
+ }
+ }
+ if (sourceAnnotations == null)
+ return;
+ for (int i = 0; i < length; i++) {
+ Annotation annotation = sourceAnnotations[i];
+ final Binding annotationRecipient = annotation.recipient;
+ if (annotationRecipient != null && recipient != null) {
+ // only local and field can share annnotations
+ switch (recipient.kind()) {
+ case Binding.FIELD :
+ FieldBinding field = (FieldBinding) recipient;
+ field.tagBits = ((FieldBinding) annotationRecipient).tagBits;
+ break;
+ case Binding.LOCAL :
+ LocalVariableBinding local = (LocalVariableBinding) recipient;
+ local.tagBits = ((LocalVariableBinding) annotationRecipient).tagBits;
+ break;
+ }
+ if (annotations != null) {
+ // need to fill the instances array
+ annotations[0] = annotation.getCompilerAnnotation();
+ for (int j = 1; j < length; j++) {
+ Annotation annot = sourceAnnotations[j];
+ annotations[j] = annot.getCompilerAnnotation();
+ }
+ }
+ return;
+ } else {
+ annotation.recipient = recipient;
+ annotation.resolveType(scope);
+ // null if receiver is a package binding
+ if (annotations != null) {
+ annotations[i] = annotation.getCompilerAnnotation();
+ }
+ }
+ }
+ // check duplicate annotations
+ if (annotations != null) {
+ AnnotationBinding[] distinctAnnotations = annotations; // only copy after 1st duplicate is detected
+ for (int i = 0; i < length; i++) {
+ AnnotationBinding annotation = distinctAnnotations[i];
+ if (annotation == null) continue;
+ TypeBinding annotationType = annotation.getAnnotationType();
+ boolean foundDuplicate = false;
+ for (int j = i+1; j < length; j++) {
+ AnnotationBinding otherAnnotation = distinctAnnotations[j];
+ if (otherAnnotation == null) continue;
+ if (otherAnnotation.getAnnotationType() == annotationType) {
+ foundDuplicate = true;
+ if (distinctAnnotations == annotations) {
+ System.arraycopy(distinctAnnotations, 0, distinctAnnotations = new AnnotationBinding[length], 0, length);
+ }
+ distinctAnnotations[j] = null; // report it only once
+ scope.problemReporter().duplicateAnnotation(sourceAnnotations[j]);
+ }
+ }
+ if (foundDuplicate) {
+ scope.problemReporter().duplicateAnnotation(sourceAnnotations[i]);
+ }
+ }
+ }
+ }
/**
* Figures if @Deprecated annotation is specified, do not resolve entire annotations.
*/
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
index 0617799..ccaac41 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
@@ -5,6 +5,10 @@
* 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
* Fraunhofer FIRST - extended API and implementation
@@ -14,6 +18,7 @@
* bug 367203 - [compiler][null] detect assigning null to nonnull argument
* bug 365519 - editorial cleanup after bug 186342 and bug 365387
* bug 365531 - [compiler][null] investigate alternative strategy for internally encoding nullness defaults
+ * bug 382353 - [1.8][compiler] Implementation property modifiers should be accepted on default methods.
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
@@ -181,6 +186,8 @@
public int modifiers;
public int modifiersSourceStart;
public Annotation[] annotations;
+ // jsr 308
+ public Annotation[] receiverAnnotations;
public Argument[] arguments;
public TypeReference[] thrownExceptions;
public Statement[] statements;
@@ -571,6 +578,10 @@
}
// SH}
+ public void getAllAnnotationContexts(int targetType, List allAnnotationContexts) {
+ // do nothing
+ }
+
private void checkArgumentsSize() {
TypeBinding[] parameters = this.binding.parameters;
int size = 1; // an abstract method or a native method cannot be static
@@ -628,6 +639,10 @@
return false;
}
+ public boolean isDefaultMethod() {
+ return false;
+ }
+
public boolean isInitializationMethod() {
return false;
@@ -666,7 +681,10 @@
}
printIndent(tab, output);
printModifiers(this.modifiers, output);
- if (this.annotations != null) printAnnotations(this.annotations, output);
+ if (this.annotations != null) {
+ printAnnotations(this.annotations, output);
+ output.append(' ');
+ }
TypeParameter[] typeParams = typeParameters();
if (typeParams != null) {
@@ -696,6 +714,10 @@
}
}
output.append(')');
+ if (this.receiverAnnotations != null) {
+ output.append(" "); //$NON-NLS-1$
+ printAnnotations(this.receiverAnnotations, output);
+ }
if (this.thrownExceptions != null) {
output.append(" throws "); //$NON-NLS-1$
for (int i = 0; i < this.thrownExceptions.length; i++) {
@@ -753,6 +775,14 @@
// SH}
resolveJavadoc();
resolveAnnotations(this.scope, this.annotations, this.binding);
+ // jsr308
+ if (this.receiverAnnotations != null && this.scope.isStatic) {
+ int last = this.receiverAnnotations.length - 1;
+ this.scope.problemReporter().illegalReceiverAnnotations(this.receiverAnnotations[0],
+ this.receiverAnnotations[last]);
+ }
+ // jsr 308
+ resolveAnnotations(this.scope, this.receiverAnnotations, new Annotation.TypeUseBinding(Binding.TYPE_USE));
validateNullAnnotations();
resolveStatements();
// check @Deprecated annotation presence
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java
index 8910eb1..15cc54c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java
@@ -1,11 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * $Id: AbstractVariableDeclaration.java 19881 2009-04-13 23:35:46Z stephan $
*
+ * 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
* Fraunhofer FIRST - extended API and implementation
@@ -93,7 +96,10 @@
public StringBuffer printAsExpression(int indent, StringBuffer output) {
printIndent(indent, output);
printModifiers(this.modifiers, output);
- if (this.annotations != null) printAnnotations(this.annotations, output);
+ if (this.annotations != null) {
+ printAnnotations(this.annotations, output);
+ output.append(' ');
+ }
if (this.type != null) {
this.type.print(0, output).append(' ');
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
index 859ee05..79a0c3b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
@@ -5,6 +5,10 @@
* 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
* Fraunhofer FIRST - extended API and implementation
@@ -15,6 +19,8 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
+import java.util.Stack;
+
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -32,6 +38,329 @@
* Annotation
*/
public abstract class Annotation extends Expression {
+
+ /**
+ * Return the location for the corresponding annotation inside the type reference, <code>null</code> if none.
+ */
+ public static int[] getLocations(
+ final TypeReference reference,
+ final Annotation[] primaryAnnotation,
+ final Annotation annotation,
+ final Annotation[][] annotationsOnDimensionsOnExpression) {
+ class LocationCollector extends ASTVisitor {
+ Stack currentIndexes;
+ Annotation currentAnnotation;
+ boolean search = true;
+
+ public LocationCollector(Annotation currentAnnotation) {
+ this.currentIndexes = new Stack();
+ this.currentAnnotation = currentAnnotation;
+ }
+ public boolean visit(ArrayTypeReference typeReference, BlockScope scope) {
+ if (!this.search) return false;
+ Annotation[][] annotationsOnDimensions = typeReference.annotationsOnDimensions;
+ if (annotationsOnDimensions != null) {
+ // check if the annotation is located on the first dimension
+ Annotation[] annotations = annotationsOnDimensions[0];
+ if (annotations != null) {
+ for (int j = 0, max2 = annotations.length; j < max2; j++) {
+ Annotation current = annotations[j];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+
+ this.currentIndexes.push(new Integer(0));
+ for (int i = 1, max = annotationsOnDimensions.length; i < max; i++) {
+ annotations = annotationsOnDimensions[i];
+ if (annotations != null) {
+ for (int j = 0, max2 = annotations.length; j < max2; j++) {
+ Annotation current = annotations[j];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+ this.currentIndexes.push(new Integer(((Integer) this.currentIndexes.pop()).intValue() + 1));
+ }
+ }
+ Annotation[] annotations = typeReference.annotations;
+ if (annotations == null) {
+ annotations = primaryAnnotation;
+ }
+ if (annotations != null) {
+ for (int i = 0; i < annotations.length; i++) {
+ Annotation current = annotations[i];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+ this.currentIndexes.pop();
+ return true;
+ }
+ public boolean visit(ArrayQualifiedTypeReference typeReference, BlockScope scope) {
+ if (!this.search) return false;
+ Annotation[][] annotationsOnDimensions = typeReference.annotationsOnDimensions;
+ if (annotationsOnDimensions != null) {
+ // check if the annotation is located on the first dimension
+ Annotation[] annotations = annotationsOnDimensions[0];
+ if (annotations != null) {
+ for (int j = 0, max2 = annotations.length; j < max2; j++) {
+ Annotation current = annotations[j];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+
+ this.currentIndexes.push(new Integer(0));
+ for (int i = 1, max = annotationsOnDimensions.length; i < max; i++) {
+ annotations = annotationsOnDimensions[i];
+ if (annotations != null) {
+ for (int j = 0, max2 = annotations.length; j < max2; j++) {
+ Annotation current = annotations[j];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+ this.currentIndexes.push(new Integer(((Integer) this.currentIndexes.pop()).intValue() + 1));
+ }
+ }
+ Annotation[] annotations = typeReference.annotations;
+ if (annotations == null) {
+ annotations = primaryAnnotation;
+ }
+ if (annotations != null) {
+ for (int i = 0; i < annotations.length; i++) {
+ Annotation current = annotations[i];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+ this.currentIndexes.pop();
+ return true;
+ }
+ public boolean visit(ParameterizedSingleTypeReference typeReference, BlockScope scope) {
+ if (!this.search) return false;
+ Annotation[][] annotationsOnDimensions = typeReference.annotationsOnDimensions;
+ if (annotationsOnDimensions != null) {
+ // check if the annotation is located on the first dimension
+ Annotation[] annotations = annotationsOnDimensions[0];
+ if (annotations != null) {
+ for (int j = 0, max2 = annotations.length; j < max2; j++) {
+ Annotation current = annotations[j];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+
+ this.currentIndexes.push(new Integer(0));
+ for (int i = 1, max = annotationsOnDimensions.length; i < max; i++) {
+ annotations = annotationsOnDimensions[i];
+ if (annotations != null) {
+ for (int j = 0, max2 = annotations.length; j < max2; j++) {
+ Annotation current = annotations[j];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+ this.currentIndexes.push(new Integer(((Integer) this.currentIndexes.pop()).intValue() + 1));
+ }
+ }
+ Annotation[] annotations = typeReference.annotations;
+ if (annotations == null) {
+ annotations = primaryAnnotation;
+ }
+ if (annotations != null) {
+ for (int i = 0; i < annotations.length; i++) {
+ Annotation current = annotations[i];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+ TypeReference[] typeReferences = typeReference.typeArguments;
+ this.currentIndexes.push(new Integer(0));
+ for (int i = 0, max = typeReferences.length; i < max; i++) {
+ typeReferences[i].traverse(this, scope);
+ if (!this.search) return false;
+ this.currentIndexes.push(new Integer(((Integer) this.currentIndexes.pop()).intValue() + 1));
+ }
+ this.currentIndexes.pop();
+ return true;
+ }
+ public boolean visit(ParameterizedQualifiedTypeReference typeReference, BlockScope scope) {
+ if (!this.search) return false;
+ Annotation[][] annotationsOnDimensions = typeReference.annotationsOnDimensions;
+ if (annotationsOnDimensions != null) {
+ // check if the annotation is located on the first dimension
+ Annotation[] annotations = annotationsOnDimensions[0];
+ if (annotations != null) {
+ for (int j = 0, max2 = annotations.length; j < max2; j++) {
+ Annotation current = annotations[j];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+
+ this.currentIndexes.push(new Integer(0));
+ for (int i = 1, max = annotationsOnDimensions.length; i < max; i++) {
+ annotations = annotationsOnDimensions[i];
+ if (annotations != null) {
+ for (int j = 0, max2 = annotations.length; j < max2; j++) {
+ Annotation current = annotations[j];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+ this.currentIndexes.push(new Integer(((Integer) this.currentIndexes.pop()).intValue() + 1));
+ }
+ }
+ Annotation[] annotations = typeReference.annotations;
+ if (annotations == null) {
+ annotations = primaryAnnotation;
+ }
+ if (annotations != null) {
+ for (int i = 0; i < annotations.length; i++) {
+ Annotation current = annotations[i];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+ //TODO it is unclear how to manage annotations located in the first type arguments
+ TypeReference[] typeReferences = typeReference.typeArguments[typeReference.typeArguments.length - 1];
+ this.currentIndexes.push(new Integer(0));
+ for (int i = 0, max = typeReferences.length; i < max; i++) {
+ typeReferences[i].traverse(this, scope);
+ if (!this.search) return false;
+ this.currentIndexes.push(new Integer(((Integer) this.currentIndexes.pop()).intValue() + 1));
+ }
+ this.currentIndexes.pop();
+ return true;
+ }
+ public boolean visit(SingleTypeReference typeReference, BlockScope scope) {
+ if (!this.search) return false;
+ Annotation[][] annotationsOnDimensions = annotationsOnDimensionsOnExpression;
+ if (annotationsOnDimensions != null) {
+ // check if the annotation is located on the first dimension
+ Annotation[] annotations = annotationsOnDimensions[0];
+ if (annotations != null) {
+ for (int j = 0, max2 = annotations.length; j < max2; j++) {
+ Annotation current = annotations[j];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+
+ this.currentIndexes.push(new Integer(0));
+ for (int i = 1, max = annotationsOnDimensions.length; i < max; i++) {
+ annotations = annotationsOnDimensions[i];
+ if (annotations != null) {
+ for (int j = 0, max2 = annotations.length; j < max2; j++) {
+ Annotation current = annotations[j];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+ this.currentIndexes.push(new Integer(((Integer) this.currentIndexes.pop()).intValue() + 1));
+ }
+ }
+ Annotation[] annotations = typeReference.annotations;
+ if (annotations != null) {
+ for (int i = 0; i < annotations.length; i++) {
+ Annotation current = annotations[i];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+ return false;
+ }
+ public boolean visit(Wildcard typeReference, BlockScope scope) {
+ if (!this.search) return false;
+ TypeReference bound = typeReference.bound;
+ bound.traverse(this, scope);
+ return true;
+ }
+ public boolean visit(QualifiedTypeReference typeReference, BlockScope scope) {
+ if (!this.search) return false;
+ Annotation[] annotations = typeReference.annotations;
+ if (annotations != null) {
+ for (int i = 0; i < annotations.length; i++) {
+ Annotation current = annotations[i];
+ if (current == this.currentAnnotation) {
+ this.search = false;
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer
+ .append("search location for ") //$NON-NLS-1$
+ .append(this.currentAnnotation)
+ .append("\ncurrent indexes : ") //$NON-NLS-1$
+ .append(this.currentIndexes);
+ return String.valueOf(buffer);
+ }
+ }
+ if (reference == null) return null;
+ LocationCollector collector = new LocationCollector(annotation);
+ reference.traverse(collector, (BlockScope) null);
+ if (collector.currentIndexes.isEmpty()) {
+ return null;
+ }
+ int size = collector.currentIndexes.size();
+ int[] result = new int[size];
+ for (int i = 0; i < size; i++) {
+ result[size - i - 1] = ((Integer) collector.currentIndexes.pop()).intValue();
+ }
+ return result;
+ }
+
+ // jsr 308
+ public static class TypeUseBinding extends ReferenceBinding {
+ private int kind;
+ public TypeUseBinding(int kind) {
+ this.tagBits = 0L;
+ this.kind = kind;
+ }
+ public int kind() {
+ return this.kind;
+ }
+ public boolean hasTypeBit(int bit) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+ }
final static MemberValuePair[] NoValuePairs = new MemberValuePair[0];
private static final long TAGBITS_NULLABLE_OR_NONNULL = TagBits.AnnotationNullable|TagBits.AnnotationNonNull;
@@ -98,6 +427,10 @@
case 'T' :
if (CharOperation.equals(elementName, TypeConstants.TYPE))
return TagBits.AnnotationForType;
+ if (CharOperation.equals(elementName, TypeConstants.TYPE_USE_TARGET))
+ return TagBits.AnnotationForTypeUse;
+ if (CharOperation.equals(elementName, TypeConstants.TYPE_PARAMETER_TARGET))
+ return TagBits.AnnotationForTypeParameter;
break;
}
return 0; // unknown
@@ -214,18 +547,62 @@
return false;
}
long metaTagBits = annotationBinding.getAnnotationTagBits(); // could be forward reference
+ // jsr 308
+ // we need to filter out type use and type parameter annotations
+ if ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) != 0) {
+ return false;
+ }
+
if ((metaTagBits & TagBits.AnnotationRetentionMASK) == 0)
return true; // by default the retention is CLASS
return (metaTagBits & TagBits.AnnotationRetentionMASK) == TagBits.AnnotationClassRetention;
}
+ public boolean isRuntimeTypeInvisible() {
+ final TypeBinding annotationBinding = this.resolvedType;
+ if (annotationBinding == null) {
+ return false;
+ }
+ long metaTagBits = annotationBinding.getAnnotationTagBits(); // could be forward reference
+ // jsr 308
+ // we need to filter out type use and type parameter annotations
+ if ((metaTagBits & (TagBits.AnnotationTargetMASK)) != 0
+ && ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) == 0)) {
+ return false;
+ }
+
+ if ((metaTagBits & TagBits.AnnotationRetentionMASK) == 0)
+ return true; // by default the retention is CLASS
+
+ return (metaTagBits & TagBits.AnnotationRetentionMASK) == TagBits.AnnotationClassRetention;
+ }
+
+ public boolean isRuntimeTypeVisible() {
+ final TypeBinding annotationBinding = this.resolvedType;
+ if (annotationBinding == null) {
+ return false;
+ }
+ long metaTagBits = annotationBinding.getAnnotationTagBits();
+ if ((metaTagBits & (TagBits.AnnotationTargetMASK)) != 0
+ && ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) == 0)) {
+ return false;
+ }
+ if ((metaTagBits & TagBits.AnnotationRetentionMASK) == 0)
+ return false; // by default the retention is CLASS
+
+ return (metaTagBits & TagBits.AnnotationRetentionMASK) == TagBits.AnnotationRuntimeRetention;
+ }
+
public boolean isRuntimeVisible() {
final TypeBinding annotationBinding = this.resolvedType;
if (annotationBinding == null) {
return false;
}
long metaTagBits = annotationBinding.getAnnotationTagBits();
+ if ((metaTagBits & (TagBits.AnnotationForTypeParameter | TagBits.AnnotationForTypeUse)) != 0) {
+ return false;
+ }
if ((metaTagBits & TagBits.AnnotationRetentionMASK) == 0)
return false; // by default the retention is CLASS
@@ -282,7 +659,6 @@
break pairLoop;
}
}
-
if (isSuppressingWarnings && suppressWarningIrritants != null) {
scope.referenceCompilationUnit().recordSuppressWarnings(suppressWarningIrritants, this, startSuppresss, endSuppress);
}
@@ -354,16 +730,19 @@
}
}
}
- if (!foundValue &&
- (method.modifiers & ClassFileConstants.AccAnnotationDefault) == 0 &&
- (this.bits & IsRecovered) == 0) {
+ if (!foundValue
+ && (method.modifiers & ClassFileConstants.AccAnnotationDefault) == 0
+ && (this.bits & IsRecovered) == 0
+ && annotationType.isValidBinding()) {
scope.problemReporter().missingValueForAnnotationMember(this, selector);
}
}
// check unused pairs
for (int i = 0; i < pairsLength; i++) {
if (pairs[i] != null) {
- scope.problemReporter().undefinedAnnotationValue(annotationType, pairs[i]);
+ if (annotationType.isValidBinding()) {
+ scope.problemReporter().undefinedAnnotationValue(annotationType, pairs[i]);
+ }
pairs[i].resolveTypeExpecting(scope, null); // resilient
}
}
@@ -375,9 +754,10 @@
// record annotation positions in the compilation result
scope.referenceCompilationUnit().recordSuppressWarnings(IrritantSet.NLS, null, this.sourceStart, this.declarationSourceEnd);
if (this.recipient != null) {
+ int kind = this.recipient.kind();
if (tagBits != 0) {
// tag bits onto recipient
- switch (this.recipient.kind()) {
+ switch (kind) {
case Binding.PACKAGE :
((PackageBinding)this.recipient).tagBits |= tagBits;
break;
@@ -450,19 +830,35 @@
}
// check (meta)target compatibility
checkTargetCompatibility: {
- long metaTagBits = annotationType.getAnnotationTagBits(); // could be forward reference
- if ((metaTagBits & TagBits.AnnotationTargetMASK) == 0) // does not specify any target restriction
+ if (!annotationType.isValidBinding()) {
+ // no need to check annotation usage if missing
break checkTargetCompatibility;
+ }
- switch (this.recipient.kind()) {
+ long metaTagBits = annotationType.getAnnotationTagBits(); // could be forward reference
+ if ((metaTagBits & TagBits.AnnotationTargetMASK) == 0) {
+ // does not specify any target restriction - all locations supported in Java 7 and before are possible
+ if (kind == Binding.TYPE_PARAMETER || kind == Binding.TYPE_USE) {
+ scope.problemReporter().explitAnnotationTargetRequired(this);
+ }
+ break checkTargetCompatibility;
+ }
+
+ switch (kind) {
case Binding.PACKAGE :
if ((metaTagBits & TagBits.AnnotationForPackage) != 0)
break checkTargetCompatibility;
break;
+ case Binding.TYPE_USE :
+ if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0) {
+ // jsr 308
+ break checkTargetCompatibility;
+ }
+ break;
case Binding.TYPE :
case Binding.GENERIC_TYPE :
if (((ReferenceBinding)this.recipient).isAnnotationType()) {
- if ((metaTagBits & (TagBits.AnnotationForAnnotationType|TagBits.AnnotationForType)) != 0)
+ if ((metaTagBits & (TagBits.AnnotationForAnnotationType | TagBits.AnnotationForType)) != 0)
break checkTargetCompatibility;
} else if ((metaTagBits & TagBits.AnnotationForType) != 0) {
break checkTargetCompatibility;
@@ -477,11 +873,19 @@
// SH}
break;
case Binding.METHOD :
- if (((MethodBinding)this.recipient).isConstructor()) {
+ MethodBinding methodBinding = (MethodBinding) this.recipient;
+ if (methodBinding.isConstructor()) {
if ((metaTagBits & TagBits.AnnotationForConstructor) != 0)
break checkTargetCompatibility;
- } else if ((metaTagBits & TagBits.AnnotationForMethod) != 0)
+ } else if ((metaTagBits & TagBits.AnnotationForMethod) != 0) {
break checkTargetCompatibility;
+ } else if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0) {
+ // jsr 308 - annotation on method return type
+ if (methodBinding.returnType != null && methodBinding.returnType.id == T_void) {
+ scope.problemReporter().illegalUsageOfTypeAnnotations(this);
+ }
+ break checkTargetCompatibility;
+ }
break;
//{ObjectTeams: method mappings
// TODO(SH): should annotations for method mappings be controlled separately?
@@ -491,17 +895,33 @@
break;
// SH}
case Binding.FIELD :
- if ((metaTagBits & TagBits.AnnotationForField) != 0)
+ if ((metaTagBits & TagBits.AnnotationForField) != 0) {
break checkTargetCompatibility;
+ } else if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0) {
+ // jsr 308 - annotation on field type
+ break checkTargetCompatibility;
+ }
break;
case Binding.LOCAL :
if ((((LocalVariableBinding)this.recipient).tagBits & TagBits.IsArgument) != 0) {
- if ((metaTagBits & TagBits.AnnotationForParameter) != 0)
+ if ((metaTagBits & TagBits.AnnotationForParameter) != 0) {
break checkTargetCompatibility;
- } else if ((annotationType.tagBits & TagBits.AnnotationForLocalVariable) != 0)
+ } else if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0) {
+ // jsr 308 - annotation on method parameter type
+ break checkTargetCompatibility;
+ }
+ } else if ((annotationType.tagBits & TagBits.AnnotationForLocalVariable) != 0) {
break checkTargetCompatibility;
+ } else if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0) {
+ // jsr 308 - annotation on local type
+ break checkTargetCompatibility;
+ }
break;
- }
+ case Binding.TYPE_PARAMETER : // jsr308
+ if ((metaTagBits & TagBits.AnnotationForTypeParameter) != 0) {
+ break checkTargetCompatibility;
+ }
+ }
scope.problemReporter().disallowedTargetForAnnotation(this);
}
}
@@ -510,4 +930,5 @@
public abstract void traverse(ASTVisitor visitor, BlockScope scope);
+ public abstract void traverse(ASTVisitor visitor, ClassScope scope);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnnotationMethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnnotationMethodDeclaration.java
index 8860ec6..69840bb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnnotationMethodDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnnotationMethodDeclaration.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 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
*******************************************************************************/
@@ -55,7 +59,10 @@
printIndent(tab, output);
printModifiers(this.modifiers, output);
- if (this.annotations != null) printAnnotations(this.annotations, output);
+ if (this.annotations != null) {
+ printAnnotations(this.annotations, output);
+ output.append(' ');
+ }
TypeParameter[] typeParams = typeParameters();
if (typeParams != null) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
index f00b176..f6af465 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
@@ -5,6 +5,10 @@
* 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
* Fraunhofer FIRST - extended API and implementation
@@ -41,9 +45,24 @@
this.declarationSourceEnd = (int) posNom;
this.modifiers = modifiers;
this.type = tr;
+ if (tr != null) {
+ this.bits |= (tr.bits & ASTNode.HasTypeAnnotations);
+ }
this.bits |= (IsLocalDeclarationReachable | IsArgument);
}
+ public Argument(char[] name, long posNom, TypeReference tr, int modifiers, boolean typeElided) {
+
+ super(name, (int) (posNom >>> 32), (int) posNom);
+ this.declarationSourceEnd = (int) posNom;
+ this.modifiers = modifiers;
+ this.type = tr;
+ if (tr != null) {
+ this.bits |= (tr.bits & ASTNode.HasTypeAnnotations);
+ }
+ this.bits |= (IsLocalDeclarationReachable | IsArgument | IsTypeElided);
+ }
+
//{ObjectTeams: consistent updating of name
public void updateName(char[] newName) {
this.name = newName;
@@ -128,6 +147,10 @@
return (this.bits & ASTNode.IsArgument) != 0 ? PARAMETER : LOCAL_VARIABLE;
}
+ public boolean isArgument() {
+ return true;
+ }
+
public boolean isVarArgs() {
return this.type != null && (this.type.bits & IsVarArgs) != 0;
}
@@ -136,7 +159,10 @@
printIndent(indent, output);
printModifiers(this.modifiers, output);
- if (this.annotations != null) printAnnotations(this.annotations, output);
+ if (this.annotations != null) {
+ printAnnotations(this.annotations, output);
+ output.append(' ');
+ }
if (this.type == null) {
output.append("<no type> "); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
index 1e3c61a..86d750f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
@@ -4,8 +4,11 @@
* 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
- * $Id: ArrayAllocationExpression.java 23404 2010-02-03 14:10:22Z stephan $
*
+ * 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 319201 - [null] no warning when unboxing SingleNameReference causes NPE
@@ -35,6 +38,7 @@
//dimensions.length gives the number of dimensions, but the
// last ones may be nulled as in new int[4][5][][]
public Expression[] dimensions;
+ public Annotation [][] annotationsOnDimensions; // jsr308 style annotations.
public ArrayInitializer initializer;
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
@@ -94,6 +98,11 @@
output.append("new "); //$NON-NLS-1$
this.type.print(0, output);
for (int i = 0; i < this.dimensions.length; i++) {
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[i] != null) {
+ output.append(' ');
+ printAnnotations(this.annotationsOnDimensions[i], output);
+ output.append(' ');
+ }
if (this.dimensions[i] == null)
output.append("[]"); //$NON-NLS-1$
else {
@@ -177,6 +186,12 @@
return null;
}
}
+ if (this.annotationsOnDimensions != null) {
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotations = this.annotationsOnDimensions[i];
+ resolveAnnotations(scope, annotations, new Annotation.TypeUseBinding(Binding.TYPE_USE));
+ }
+ }
return this.resolvedType;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
index 8ad408c..09ae845 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 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 - extended API and implementation
@@ -18,6 +22,7 @@
public class ArrayQualifiedTypeReference extends QualifiedTypeReference {
int dimensions;
+ Annotation[][] annotationsOnDimensions; // jsr308 style type annotations on dimensions
//{ObjectTeams: mark generated reference:
public ArrayQualifiedTypeReference(char[][] sources , int dim, long[] poss, boolean isGenerated) {
@@ -29,12 +34,23 @@
super( sources , poss);
this.dimensions = dim ;
+ this.annotationsOnDimensions = null;
+ }
+
+ public ArrayQualifiedTypeReference(char[][] sources, int dim, Annotation[][] annotationsOnDimensions, long[] poss) {
+ this(sources, dim, poss);
+ this.annotationsOnDimensions = annotationsOnDimensions;
+ this.bits |= ASTNode.HasTypeAnnotations;
}
public int dimensions() {
return this.dimensions;
}
+
+ public Annotation[][] getAnnotationsOnDimensions() {
+ return this.annotationsOnDimensions;
+ }
/**
* @return char[][]
@@ -77,16 +93,47 @@
}
}
+ protected TypeBinding internalResolveType(Scope scope) {
+ TypeBinding internalResolveType = super.internalResolveType(scope);
+ if (this.annotationsOnDimensions != null) {
+ switch(scope.kind) {
+ case Scope.BLOCK_SCOPE :
+ case Scope.METHOD_SCOPE :
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotationsOnDimension = this.annotationsOnDimensions[i];
+ resolveAnnotations((BlockScope) scope, annotationsOnDimension, new Annotation.TypeUseBinding(Binding.TYPE_USE));
+ }
+ break;
+ }
+ }
+ return internalResolveType;
+ }
+
public StringBuffer printExpression(int indent, StringBuffer output){
super.printExpression(indent, output);
if ((this.bits & IsVarArgs) != 0) {
for (int i= 0 ; i < this.dimensions - 1; i++) {
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[i] != null) {
+ output.append(' ');
+ printAnnotations(this.annotationsOnDimensions[i], output);
+ output.append(' ');
+ }
output.append("[]"); //$NON-NLS-1$
}
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[this.dimensions - 1] != null) {
+ output.append(' ');
+ printAnnotations(this.annotationsOnDimensions[this.dimensions - 1], output);
+ output.append(' ');
+ }
output.append("..."); //$NON-NLS-1$
} else {
for (int i= 0 ; i < this.dimensions; i++) {
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[i] != null) {
+ output.append(" "); //$NON-NLS-1$
+ printAnnotations(this.annotationsOnDimensions[i], output);
+ output.append(" "); //$NON-NLS-1$
+ }
output.append("[]"); //$NON-NLS-1$
}
}
@@ -94,14 +141,52 @@
}
public void traverse(ASTVisitor visitor, BlockScope scope) {
-
- visitor.visit(this, scope);
+ if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ if (this.annotationsOnDimensions != null) {
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotations2 = this.annotationsOnDimensions[i];
+ for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+ Annotation annotation = annotations2[j];
+ annotation.traverse(visitor, scope);
+ }
+ }
+ }
+ }
visitor.endVisit(this, scope);
}
public void traverse(ASTVisitor visitor, ClassScope scope) {
-
- visitor.visit(this, scope);
+ if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ if (this.annotationsOnDimensions != null) {
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotations2 = this.annotationsOnDimensions[i];
+ for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+ Annotation annotation = annotations2[j];
+ annotation.traverse(visitor, scope);
+ }
+ }
+ }
+ }
visitor.endVisit(this, scope);
}
+
+ protected void resolveAnnotations(BlockScope scope) {
+ super.resolveAnnotations(scope);
+ if (this.annotationsOnDimensions != null) {
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotationsOnDimension = this.annotationsOnDimensions[i];
+ resolveAnnotations(scope, annotationsOnDimension, new Annotation.TypeUseBinding(Binding.TYPE_USE));
+ }
+ }
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
index fa6c8d5..18f9ce8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.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
*******************************************************************************/
@@ -12,6 +16,7 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.Scope;
@@ -19,6 +24,7 @@
public class ArrayTypeReference extends SingleTypeReference {
public int dimensions;
+ public Annotation[][] annotationsOnDimensions; // jsr308 style type annotations on dimensions.
public int originalSourceEnd;
/**
@@ -32,12 +38,25 @@
super(source, pos);
this.originalSourceEnd = this.sourceEnd;
this.dimensions = dimensions ;
+ this.annotationsOnDimensions = null;
+ }
+
+ public ArrayTypeReference(char[] source, int dimensions, Annotation[][] annotationsOnDimensions, long pos) {
+ this(source, dimensions, pos);
+ if (annotationsOnDimensions != null) {
+ this.bits |= ASTNode.HasTypeAnnotations;
+ }
+ this.annotationsOnDimensions = annotationsOnDimensions;
}
public int dimensions() {
return this.dimensions;
}
+
+ public Annotation[][] getAnnotationsOnDimensions() {
+ return this.annotationsOnDimensions;
+ }
/**
* @return char[][]
*/
@@ -69,11 +88,26 @@
super.printExpression(indent, output);
if ((this.bits & IsVarArgs) != 0) {
for (int i= 0 ; i < this.dimensions - 1; i++) {
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[i] != null) {
+ output.append(' ');
+ printAnnotations(this.annotationsOnDimensions[i], output);
+ output.append(' ');
+ }
output.append("[]"); //$NON-NLS-1$
}
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[this.dimensions - 1] != null) {
+ output.append(' ');
+ printAnnotations(this.annotationsOnDimensions[this.dimensions - 1], output);
+ output.append(' ');
+ }
output.append("..."); //$NON-NLS-1$
} else {
for (int i= 0 ; i < this.dimensions; i++) {
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[i] != null) {
+ output.append(" "); //$NON-NLS-1$
+ printAnnotations(this.annotationsOnDimensions[i], output);
+ output.append(" "); //$NON-NLS-1$
+ }
output.append("[]"); //$NON-NLS-1$
}
}
@@ -81,14 +115,71 @@
}
public void traverse(ASTVisitor visitor, BlockScope scope) {
-
- visitor.visit(this, scope);
+ if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ if (this.annotationsOnDimensions != null) {
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotations2 = this.annotationsOnDimensions[i];
+ if (annotations2 != null) {
+ for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+ Annotation annotation = annotations2[j];
+ annotation.traverse(visitor, scope);
+ }
+ }
+ }
+ }
+ }
visitor.endVisit(this, scope);
}
public void traverse(ASTVisitor visitor, ClassScope scope) {
-
- visitor.visit(this, scope);
+ if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ if (this.annotationsOnDimensions != null) {
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotations2 = this.annotationsOnDimensions[i];
+ if (annotations2 != null) {
+ for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+ Annotation annotation = annotations2[j];
+ annotation.traverse(visitor, scope);
+ }
+ }
+ }
+ }
+ }
visitor.endVisit(this, scope);
}
+
+ protected TypeBinding internalResolveType(Scope scope) {
+ TypeBinding internalResolveType = super.internalResolveType(scope);
+ if (this.annotationsOnDimensions != null) {
+ switch(scope.kind) {
+ case Scope.BLOCK_SCOPE :
+ case Scope.METHOD_SCOPE :
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotationsOnDimension = this.annotationsOnDimensions[i];
+ resolveAnnotations((BlockScope) scope, annotationsOnDimension, new Annotation.TypeUseBinding(Binding.TYPE_USE));
+ }
+ break;
+ }
+ }
+ return internalResolveType;
+ }
+ protected void resolveAnnotations(BlockScope scope) {
+ super.resolveAnnotations(scope);
+ if (this.annotationsOnDimensions != null) {
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotationsOnDimension = this.annotationsOnDimensions[i];
+ resolveAnnotations(scope, annotationsOnDimension, new Annotation.TypeUseBinding(Binding.TYPE_USE));
+ }
+ }
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
index ab7f28f..5476beb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
@@ -4,7 +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
- * $Id: CastExpression.java 23405 2010-02-03 17:02:18Z stephan $
+ *
+ * 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
@@ -562,9 +565,15 @@
}
public StringBuffer printExpression(int indent, StringBuffer output) {
+ int parenthesesCount = (this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
+ String suffix = ""; //$NON-NLS-1$
+ for(int i = 0; i < parenthesesCount; i++) {
+ output.append('(');
+ suffix += ')';
+ }
output.append('(');
this.type.print(0, output).append(") "); //$NON-NLS-1$
- return this.expression.printExpression(0, output);
+ return this.expression.printExpression(0, output).append(suffix);
}
public TypeBinding resolveType(BlockScope scope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
index 00d6a11..12f1ba6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
@@ -4,8 +4,11 @@
* 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
- * $Id: FieldDeclaration.java 23404 2010-02-03 14:10:22Z stephan $
*
+ * 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
* Fraunhofer FIRST - extended API and implementation
@@ -13,10 +16,13 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
+import java.util.List;
+
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.impl.*;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.flow.*;
@@ -146,7 +152,13 @@
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
-
+public void getAllAnnotationContexts(int targetType, List allAnnotationContexts) {
+ AnnotationCollector collector = new AnnotationCollector(this, targetType, allAnnotationContexts);
+ for (int i = 0, max = this.annotations.length; i < max; i++) {
+ Annotation annotation = this.annotations[i];
+ annotation.traverse(collector, (BlockScope) null);
+ }
+}
/**
* @see org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration#getKind()
*/
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java
index 6cb2c16..8a14ea4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java
@@ -5,6 +5,9 @@
* 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
*******************************************************************************/
@@ -87,7 +90,10 @@
if (this.modifiers != 0) {
printIndent(indent, output);
printModifiers(this.modifiers, output);
- if (this.annotations != null) printAnnotations(this.annotations, output);
+ if (this.annotations != null) {
+ printAnnotations(this.annotations, output);
+ output.append(' ');
+ }
output.append("{\n"); //$NON-NLS-1$
if (this.block != null) {
this.block.printBody(indent, output);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java
index 696a693..7f985aa 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/JavadocImplicitTypeReference.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
*******************************************************************************/
@@ -30,6 +34,10 @@
public TypeReference copyDims(int dim) {
return null;
}
+
+ public TypeReference copyDims(int dim, Annotation[][] annotationsOnDimensions) {
+ return null;
+ }
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.compiler.ast.TypeReference#getTypeBinding(org.eclipse.jdt.internal.compiler.lookup.Scope)
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java
new file mode 100644
index 0000000..25b0f2b
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.jdt.internal.compiler.ast;
+
+public class LambdaExpression extends NullLiteral { // For the time being.
+ Argument [] arguments;
+ Statement body;
+
+ public LambdaExpression(Argument [] arguments, Statement body) {
+ super(0, 0);
+ this.arguments = arguments;
+ this.body = body;
+ }
+
+ public StringBuffer printExpression(int tab, StringBuffer output) {
+ int parenthesesCount = (this.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
+ String suffix = ""; //$NON-NLS-1$
+ for(int i = 0; i < parenthesesCount; i++) {
+ output.append('(');
+ suffix += ')';
+ }
+ output.append('(');
+ if (this.arguments != null) {
+ for (int i = 0; i < this.arguments.length; i++) {
+ if (i > 0) output.append(", "); //$NON-NLS-1$
+ this.arguments[i].print(0, output);
+ }
+ }
+ output.append(") -> " ); //$NON-NLS-1$
+ this.body.print(this.body instanceof Block ? tab : 0, output);
+ return output.append(suffix);
+ }
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
index 7aa2afc..e3d72a2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
@@ -4,8 +4,11 @@
* 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
- * $Id: LocalDeclaration.java 23405 2010-02-03 17:02:18Z stephan $
*
+ * 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
* Fraunhofer FIRST - extended API and implementation
@@ -22,8 +25,11 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
+import java.util.List;
+
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.impl.*;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.flow.*;
@@ -245,6 +251,22 @@
return LOCAL_VARIABLE;
}
+ // for local variables
+ public void getAllAnnotationContexts(int targetType, LocalVariableBinding localVariable, List allAnnotationContexts) {
+ AnnotationCollector collector = new AnnotationCollector(this, targetType, localVariable, allAnnotationContexts);
+ this.traverse(collector, (BlockScope) null);
+ }
+ // for arguments
+ public void getAllAnnotationContexts(int targetType, int parameterIndex, List allAnnotationContexts) {
+ AnnotationCollector collector = new AnnotationCollector(this, targetType, parameterIndex, allAnnotationContexts);
+ this.traverse(collector, (BlockScope) null);
+ }
+ public boolean isArgument() {
+ return false;
+ }
+ public boolean isReceiver() {
+ return false;
+ }
public void resolve(BlockScope scope) {
//{ObjectTeams: avoid duplicate resolving:
TypeBinding variableType = null;
@@ -367,6 +389,11 @@
}
// only resolve annotation at the end, for constant to be positioned before (96991)
resolveAnnotations(scope, this.annotations, this.binding);
+ // jsr 308
+ Annotation[] typeAnnotations = this.type.annotations;
+ if (typeAnnotations != null) {
+ ASTNode.resolveAnnotations(scope, typeAnnotations, new Annotation.TypeUseBinding(Binding.TYPE_USE));
+ }
scope.validateNullAnnotation(this.binding.tagBits, this.type, this.annotations);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MarkerAnnotation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MarkerAnnotation.java
index 2a48484..eae5b91 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MarkerAnnotation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MarkerAnnotation.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
*******************************************************************************/
@@ -42,4 +46,12 @@
}
visitor.endVisit(this, scope);
}
+ public void traverse(ASTVisitor visitor, ClassScope scope) {
+ if (visitor.visit(this, scope)) {
+ if (this.type != null) {
+ this.type.traverse(visitor, scope);
+ }
+ }
+ visitor.endVisit(this, scope);
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java
index e0f7cfb..53c7b16 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MemberValuePair.java
@@ -5,6 +5,10 @@
* 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
@@ -17,6 +21,7 @@
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
@@ -241,4 +246,12 @@
}
visitor.endVisit(this, scope);
}
+ public void traverse(ASTVisitor visitor, ClassScope scope) {
+ if (visitor.visit(this, scope)) {
+ if (this.value != null) {
+ this.value.traverse(visitor, scope);
+ }
+ }
+ visitor.endVisit(this, scope);
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
index 882980c..34a75e1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
@@ -4,8 +4,11 @@
* 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
- * $Id: MethodDeclaration.java 23404 2010-02-03 14:10:22Z stephan $
*
+ * 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
* Fraunhofer FIRST - extended API and implementation
@@ -15,12 +18,15 @@
* bug 186342 - [compiler][null] Using annotations for null checking
* bug 365519 - editorial cleanup after bug 186342 and bug 365387
* bug 368546 - [compiler][resource] Avoid remaining false positives found when compiling the Eclipse SDK
+ * bug 382353 - [1.8][compiler] Implementation property modifiers should be accepted on default methods.
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import static org.eclipse.objectteams.otdt.core.compiler.IOTConstants.CALLIN_FLAG_DEFINITELY_MISSING_BASECALL;
import static org.eclipse.objectteams.otdt.core.compiler.IOTConstants.CALLIN_FLAG_POTENTIALLY_MISSING_BASECALL;
+import java.util.List;
+
import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.CompilationResult;
@@ -30,6 +36,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
@@ -41,6 +48,7 @@
import org.eclipse.jdt.internal.compiler.parser.Parser;
import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector;
import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
import org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseCallTrackingVariable;
import org.eclipse.objectteams.otdt.internal.core.compiler.ast.GuardPredicateDeclaration;
@@ -138,6 +146,7 @@
if (this.arguments != null) {
for (int i = 0, count = this.arguments.length; i < count; i++) {
+ this.bits |= (this.arguments[i].bits & ASTNode.HasTypeAnnotations);
// if this method uses a type parameter declared by the declaring class,
// it can't be static. https://bugs.eclipse.org/bugs/show_bug.cgi?id=318682
if (this.arguments[i].binding != null && (this.arguments[i].binding.type instanceof TypeVariableBinding)) {
@@ -218,6 +227,18 @@
}
// SH}
+ public void getAllAnnotationContexts(int targetType, List allAnnotationContexts) {
+ AnnotationCollector collector = new AnnotationCollector(this, targetType, allAnnotationContexts);
+ for (int i = 0, max = this.annotations.length; i < max; i++) {
+ Annotation annotation = this.annotations[i];
+ annotation.traverse(collector, (BlockScope) null);
+ }
+ }
+
+ public boolean isDefaultMethod() {
+ return (this.modifiers & ExtraCompilerModifiers.AccDefaultMethod) != 0;
+ }
+
public boolean isMethod() {
return true;
}
@@ -235,6 +256,7 @@
public void resolveStatements() {
// ========= abort on fatal error =============
if (this.returnType != null && this.binding != null) {
+ this.bits |= (this.returnType.bits & ASTNode.HasTypeAnnotations);
this.returnType.resolvedType = this.binding.returnType;
// record the return type binding
}
@@ -252,7 +274,10 @@
}
if (this.typeParameters != null) {
for (int i = 0, length = this.typeParameters.length; i < length; i++) {
- this.typeParameters[i].resolve(this.scope);
+ TypeParameter typeParameter = this.typeParameters[i];
+ this.bits |= (typeParameter.bits & ASTNode.HasTypeAnnotations);
+ typeParameter.resolve(this.scope);
+ typeParameter.resolveAnnotations(this.scope);
if (returnsUndeclTypeVar && this.typeParameters[i].binding == this.returnType.resolvedType) {
returnsUndeclTypeVar = false;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NormalAnnotation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NormalAnnotation.java
index a1d1bd1..381cc9a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NormalAnnotation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NormalAnnotation.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
*******************************************************************************/
@@ -71,4 +75,17 @@
}
visitor.endVisit(this, scope);
}
+ public void traverse(ASTVisitor visitor, ClassScope scope) {
+ if (visitor.visit(this, scope)) {
+ if (this.type != null) {
+ this.type.traverse(visitor, scope);
+ }
+ if (this.memberValuePairs != null) {
+ int memberValuePairsLength = this.memberValuePairs.length;
+ for (int i = 0; i < memberValuePairsLength; i++)
+ this.memberValuePairs[i].traverse(visitor, scope);
+ }
+ }
+ visitor.endVisit(this, scope);
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java
index bf41a61..081fec2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.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
* Stephan Herrmann - Contribution for Bug 342671 - ClassCastException: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ArrayBinding
@@ -53,6 +57,13 @@
super(tokens, dim, positions);
this.typeArguments = typeArguments;
}
+ public ParameterizedQualifiedTypeReference(char[][] tokens, TypeReference[][] typeArguments, int dim, Annotation[][] annotationsOnDimensions, long[] positions) {
+ this(tokens, typeArguments, dim, positions);
+ this.annotationsOnDimensions = annotationsOnDimensions;
+ if (annotationsOnDimensions != null) {
+ this.bits |= ASTNode.HasTypeAnnotations;
+ }
+ }
public void checkBounds(Scope scope) {
if (this.resolvedType == null) return;
@@ -78,6 +89,17 @@
public TypeReference copyDims(int dim){
return new ParameterizedQualifiedTypeReference(this.tokens, this.typeArguments, dim, this.sourcePositions);
}
+ public TypeReference copyDims(int dim, Annotation[][] dimensionAnnotations){
+ ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference = new ParameterizedQualifiedTypeReference(this.tokens, this.typeArguments, dim, dimensionAnnotations, this.sourcePositions);
+ parameterizedQualifiedTypeReference.bits |= (this.bits & ASTNode.HasTypeAnnotations);
+ if (dimensionAnnotations != null) {
+ parameterizedQualifiedTypeReference.bits |= ASTNode.HasTypeAnnotations;
+ }
+ return parameterizedQualifiedTypeReference;
+ }
+ public boolean isParameterizedTypeReference() {
+ return true;
+ }
/**
* @return char[][]
@@ -147,6 +169,14 @@
}
}
this.bits |= ASTNode.DidResolve;
+ if (this.annotations != null) {
+ switch(scope.kind) {
+ case Scope.BLOCK_SCOPE :
+ case Scope.METHOD_SCOPE :
+ resolveAnnotations((BlockScope) scope, this.annotations, new Annotation.TypeUseBinding(Binding.TYPE_USE));
+ break;
+ }
+ }
TypeBinding type = internalResolveLeafType(scope, checkBounds);
createArrayType(scope);
return type == null ? type : this.resolvedType;
@@ -318,6 +348,11 @@
}
public StringBuffer printExpression(int indent, StringBuffer output) {
+ if (this.annotations != null) {
+ output.append(" "); //$NON-NLS-1$
+ printAnnotations(this.annotations, output);
+ output.append(' ');
+ }
int length = this.tokens.length;
for (int i = 0; i < length - 1; i++) {
output.append(this.tokens[i]);
@@ -354,11 +389,26 @@
}
if ((this.bits & IsVarArgs) != 0) {
for (int i= 0 ; i < this.dimensions - 1; i++) {
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[i] != null) {
+ output.append(" "); //$NON-NLS-1$
+ printAnnotations(this.annotationsOnDimensions[i], output);
+ output.append(" "); //$NON-NLS-1$
+ }
output.append("[]"); //$NON-NLS-1$
}
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[this.dimensions - 1] != null) {
+ output.append(" "); //$NON-NLS-1$
+ printAnnotations(this.annotationsOnDimensions[this.dimensions - 1], output);
+ output.append(" "); //$NON-NLS-1$
+ }
output.append("..."); //$NON-NLS-1$
} else {
for (int i= 0 ; i < this.dimensions; i++) {
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[i] != null) {
+ output.append(" "); //$NON-NLS-1$
+ printAnnotations(this.annotationsOnDimensions[i], output);
+ output.append(" "); //$NON-NLS-1$
+ }
output.append("[]"); //$NON-NLS-1$
}
}
@@ -373,6 +423,20 @@
}
public void traverse(ASTVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ if (this.annotationsOnDimensions != null) {
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotations2 = this.annotationsOnDimensions[i];
+ for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+ Annotation annotation = annotations2[j];
+ annotation.traverse(visitor, scope);
+ }
+ }
+ }
for (int i = 0, max = this.typeArguments.length; i < max; i++) {
if (this.typeArguments[i] != null) {
for (int j = 0, max2 = this.typeArguments[i].length; j < max2; j++) {
@@ -386,6 +450,20 @@
public void traverse(ASTVisitor visitor, ClassScope scope) {
if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ if (this.annotationsOnDimensions != null) {
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotations2 = this.annotationsOnDimensions[i];
+ for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+ Annotation annotation = annotations2[j];
+ annotation.traverse(visitor, scope);
+ }
+ }
+ }
for (int i = 0, max = this.typeArguments.length; i < max; i++) {
if (this.typeArguments[i] != null) {
for (int j = 0, max2 = this.typeArguments[i].length; j < max2; j++) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java
index 187978d..59b8733 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.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
* Stephan Herrmann - Contribution for Bug 342671 - ClassCastException: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ArrayBinding
@@ -60,6 +64,13 @@
this.originalSourceEnd = this.sourceEnd;
this.typeArguments = typeArguments;
}
+ public ParameterizedSingleTypeReference(char[] name, TypeReference[] typeArguments, int dim, Annotation[][] annotationsOnDimensions, long pos) {
+ this(name, typeArguments, dim, pos);
+ this.annotationsOnDimensions = annotationsOnDimensions;
+ if (annotationsOnDimensions != null) {
+ this.bits |= ASTNode.HasTypeAnnotations;
+ }
+ }
public void checkBounds(Scope scope) {
if (this.resolvedType == null) return;
@@ -79,6 +90,14 @@
public TypeReference copyDims(int dim) {
return new ParameterizedSingleTypeReference(this.token, this.typeArguments, dim, (((long)this.sourceStart)<<32)+this.sourceEnd);
}
+ public TypeReference copyDims(int dim, Annotation [][] annotationsOnDims) {
+ ParameterizedSingleTypeReference parameterizedSingleTypeReference = new ParameterizedSingleTypeReference(this.token, this.typeArguments, dim, annotationsOnDims, (((long)this.sourceStart)<<32)+this.sourceEnd);
+ parameterizedSingleTypeReference.bits |= (this.bits & ASTNode.HasTypeAnnotations);
+ if (annotationsOnDims != null) {
+ parameterizedSingleTypeReference.bits |= ASTNode.HasTypeAnnotations;
+ }
+ return parameterizedSingleTypeReference;
+ }
/**
* @return char[][]
@@ -117,6 +136,10 @@
protected TypeBinding getTypeBinding(Scope scope) {
return null; // not supported here - combined with resolveType(...)
}
+
+ public boolean isParameterizedTypeReference() {
+ return true;
+ }
/*
* No need to check for reference to raw type per construction
@@ -142,6 +165,14 @@
}
}
this.bits |= ASTNode.DidResolve;
+ if (this.annotations != null) {
+ switch(scope.kind) {
+ case Scope.BLOCK_SCOPE :
+ case Scope.METHOD_SCOPE :
+ resolveAnnotations((BlockScope) scope, this.annotations, new Annotation.TypeUseBinding(Binding.TYPE_USE));
+ break;
+ }
+ }
//{ObjectTeams: check team anchor first:
for (int typeParamPos=0; typeParamPos<this.typeArguments.length; typeParamPos++) {
if (this.typeArguments[typeParamPos] instanceof TypeAnchorReference)
@@ -219,7 +250,7 @@
}
TypeBinding type = internalResolveLeafType(importScope, scope, enclosingType, checkBounds);
/* orig:
- TypeBinding type = internalResolveLeafType(enclosingType, checkBounds);
+ TypeBinding type = internalResolveLeafType(scope, enclosingType, checkBounds);
:giro */
// SH}
// handle three different outcomes:
@@ -321,6 +352,7 @@
TypeBinding argType = isClassScope
? typeArgument.resolveTypeArgument((ClassScope) scope, currentOriginal, i)
: typeArgument.resolveTypeArgument((BlockScope) scope, currentOriginal, i);
+ this.bits |= (typeArgument.bits & ASTNode.HasTypeAnnotations);
if (argType == null) {
argHasError = true;
} else {
@@ -399,8 +431,19 @@
}
return type;
}
+
+ protected void resolveAnnotations(BlockScope scope) {
+ super.resolveAnnotations(scope);
+ for (int i = 0, length = this.typeArguments.length; i < length; i++) {
+ this.typeArguments[i].resolveAnnotations(scope);
+ }
+ }
public StringBuffer printExpression(int indent, StringBuffer output){
+ if (this.annotations != null) {
+ printAnnotations(this.annotations, output);
+ output.append(' ');
+ }
output.append(this.token);
output.append("<"); //$NON-NLS-1$
int length = this.typeArguments.length;
@@ -425,11 +468,26 @@
output.append(">"); //$NON-NLS-1$
if ((this.bits & IsVarArgs) != 0) {
for (int i= 0 ; i < this.dimensions - 1; i++) {
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[i] != null) {
+ output.append(" "); //$NON-NLS-1$
+ printAnnotations(this.annotationsOnDimensions[i], output);
+ output.append(" "); //$NON-NLS-1$
+ }
output.append("[]"); //$NON-NLS-1$
}
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[this.dimensions - 1] != null) {
+ output.append(" "); //$NON-NLS-1$
+ printAnnotations(this.annotationsOnDimensions[this.dimensions - 1], output);
+ output.append(" "); //$NON-NLS-1$
+ }
output.append("..."); //$NON-NLS-1$
} else {
for (int i= 0 ; i < this.dimensions; i++) {
+ if (this.annotationsOnDimensions != null && this.annotationsOnDimensions[i] != null) {
+ output.append(" "); //$NON-NLS-1$
+ printAnnotations(this.annotationsOnDimensions[i], output);
+ output.append(" "); //$NON-NLS-1$
+ }
output.append("[]"); //$NON-NLS-1$
}
}
@@ -511,6 +569,22 @@
// SH}
public void traverse(ASTVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ if (this.annotationsOnDimensions != null) {
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotations2 = this.annotationsOnDimensions[i];
+ if (annotations2 != null) {
+ for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+ Annotation annotation = annotations2[j];
+ annotation.traverse(visitor, scope);
+ }
+ }
+ }
+ }
for (int i = 0, max = this.typeArguments.length; i < max; i++) {
this.typeArguments[i].traverse(visitor, scope);
}
@@ -520,6 +594,20 @@
public void traverse(ASTVisitor visitor, ClassScope scope) {
if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ if (this.annotationsOnDimensions != null) {
+ for (int i = 0, max = this.annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotations2 = this.annotationsOnDimensions[i];
+ for (int j = 0, max2 = annotations2.length; j < max2; j++) {
+ Annotation annotation = annotations2[j];
+ annotation.traverse(visitor, scope);
+ }
+ }
+ }
for (int i = 0, max = this.typeArguments.length; i < max; i++) {
this.typeArguments[i].traverse(visitor, scope);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
index 43bc84c..90a73ca 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
@@ -1,11 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * $Id: QualifiedTypeReference.java 23404 2010-02-03 14:10:22Z stephan $
*
+ * 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
* Fraunhofer FIRST - extended API and implementation
@@ -58,6 +61,18 @@
//warning : the new type ref has a null binding
return new ArrayQualifiedTypeReference(this.tokens, dim, this.sourcePositions);
}
+
+ public TypeReference copyDims(int dim, Annotation[][] annotationsOnDimensions) {
+ //return a type reference copy of me with some dimensions
+ //warning : the new type ref has a null binding
+ ArrayQualifiedTypeReference arrayQualifiedTypeReference = new ArrayQualifiedTypeReference(this.tokens, dim, annotationsOnDimensions, this.sourcePositions);
+ arrayQualifiedTypeReference.bits |= (this.bits & ASTNode.HasTypeAnnotations);
+ if (annotationsOnDimensions != null) {
+ arrayQualifiedTypeReference.bits |= ASTNode.HasTypeAnnotations;
+ }
+ return arrayQualifiedTypeReference;
+ }
+
//{ObjectTeams:
/**
* Try to resolve this type reference as an anchored type "t.R".
@@ -216,7 +231,10 @@
}
public StringBuffer printExpression(int indent, StringBuffer output) {
-
+ if (this.annotations != null) {
+ printAnnotations(this.annotations, output);
+ output.append(' ');
+ }
for (int i = 0; i < this.tokens.length; i++) {
if (i > 0) output.append('.');
//{ObjectTeams: suppress prefix:
@@ -230,14 +248,24 @@
}
public void traverse(ASTVisitor visitor, BlockScope scope) {
-
- visitor.visit(this, scope);
+ if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ }
visitor.endVisit(this, scope);
}
public void traverse(ASTVisitor visitor, ClassScope scope) {
-
- visitor.visit(this, scope);
+ if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ }
visitor.endVisit(this, scope);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Receiver.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Receiver.java
new file mode 100644
index 0000000..971ee9d
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Receiver.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.jdt.internal.compiler.ast;
+
+import org.eclipse.jdt.core.compiler.CharOperation;
+
+public class Receiver extends Argument {
+ TypeReference qualifyingTypeReference;
+ public Receiver(char[] name, long posNom, TypeReference typeReference, TypeReference qualifyingTypeReference, int modifiers) {
+ super(qualifyingTypeReference == null ? name : CharOperation.concatWith(qualifyingTypeReference.getTypeName(), name, '.'), posNom, typeReference, modifiers);
+ this.qualifyingTypeReference = qualifyingTypeReference;
+ }
+ public boolean isReceiver() {
+ return true;
+ }
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java
new file mode 100644
index 0000000..bc680d6
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.jdt.internal.compiler.ast;
+
+public class ReferenceExpression extends NullLiteral { // For the time being.
+
+ protected NameReference name;
+ protected TypeReference type;
+ protected Expression primary;
+
+ protected TypeReference [] typeArguments;
+
+ protected SingleNameReference method; // == null ? "::new" : "::method"
+
+ public ReferenceExpression(NameReference name, TypeReference[] typeArguments, int sourceEnd) {
+ super(name.sourceStart, sourceEnd);
+ this.name = name;
+ this.typeArguments = typeArguments;
+ this.method = null;
+ }
+
+ public ReferenceExpression(NameReference name, TypeReference[] typeArguments, SingleNameReference method) {
+ super(name.sourceStart, method.sourceEnd);
+ this.name = name;
+ this.typeArguments = typeArguments;
+ this.method = method;
+ }
+
+ public ReferenceExpression(Expression primary, TypeReference [] typeArguments, SingleNameReference method) {
+ super(primary.sourceStart, method.sourceEnd);
+ this.primary = primary;
+ this.typeArguments = typeArguments;
+ this.method = method;
+ }
+
+ public ReferenceExpression(TypeReference type, TypeReference[] typeArguments, SingleNameReference method) {
+ super(type.sourceStart, method.sourceEnd);
+ this.type = type;
+ this.typeArguments = typeArguments;
+ this.method = method;
+ }
+
+ public ReferenceExpression(TypeReference type, TypeReference[] typeArguments, int sourceEnd) {
+ super(type.sourceStart, sourceEnd);
+ this.type = type;
+ this.typeArguments = typeArguments;
+ this.method = null;
+ }
+
+ public StringBuffer printExpression(int tab, StringBuffer output) {
+
+ if (this.type != null) {
+ this.type.print(0, output);
+ } else if (this.name != null) {
+ this.name.print(0, output);
+ } else {
+ this.primary.print(0, output);
+ }
+ output.append("::"); //$NON-NLS-1$
+ if (this.typeArguments != null) {
+ output.append('<');
+ int max = this.typeArguments.length - 1;
+ for (int j = 0; j < max; j++) {
+ this.typeArguments[j].print(0, output);
+ output.append(", ");//$NON-NLS-1$
+ }
+ this.typeArguments[max].print(0, output);
+ output.append('>');
+ }
+ if (this.method == null) {
+ output.append("new"); //$NON-NLS-1$
+ } else {
+ this.method.print(0, output);
+ }
+ return output;
+ }
+ public boolean isConstructorReference() {
+ return this.method == null;
+ }
+ public boolean isMethodReference() {
+ return this.method != null;
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleMemberAnnotation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleMemberAnnotation.java
index e64bf0c..2eff389 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleMemberAnnotation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleMemberAnnotation.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
*******************************************************************************/
@@ -62,4 +66,16 @@
}
visitor.endVisit(this, scope);
}
+
+ public void traverse(ASTVisitor visitor, ClassScope scope) {
+ if (visitor.visit(this, scope)) {
+ if (this.type != null) {
+ this.type.traverse(visitor, scope);
+ }
+ if (this.memberValue != null) {
+ this.memberValue.traverse(visitor, scope);
+ }
+ }
+ visitor.endVisit(this, scope);
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java
index 5f8c0e1..8352c86 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.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
* Fraunhofer FIRST - extended API and implementation
@@ -43,6 +47,17 @@
return new ArrayTypeReference(this.token, dim,(((long)this.sourceStart)<<32)+this.sourceEnd);
}
+
+ public TypeReference copyDims(int dim, Annotation[][] annotationsOnDimensions){
+ //return a type reference copy of me with some dimensions
+ //warning : the new type ref has a null binding
+ ArrayTypeReference arrayTypeReference = new ArrayTypeReference(this.token, dim, annotationsOnDimensions, (((long)this.sourceStart)<<32)+this.sourceEnd);
+ arrayTypeReference.bits |= (this.bits & ASTNode.HasTypeAnnotations);
+ if (annotationsOnDimensions != null) {
+ arrayTypeReference.bits |= ASTNode.HasTypeAnnotations;
+ }
+ return arrayTypeReference;
+ }
public char[] getLastToken() {
return this.token;
@@ -64,7 +79,10 @@
}
public StringBuffer printExpression(int indent, StringBuffer output){
-
+ if (this.annotations != null) {
+ printAnnotations(this.annotations, output);
+ output.append(' ');
+ }
return output.append(this.token);
}
@@ -133,12 +151,24 @@
// SH}
public void traverse(ASTVisitor visitor, BlockScope scope) {
- visitor.visit(this, scope);
+ if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ }
visitor.endVisit(this, scope);
}
public void traverse(ASTVisitor visitor, ClassScope scope) {
- visitor.visit(this, scope);
+ if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
+ }
visitor.endVisit(this, scope);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
index 4af7b4c..04f4e94 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
@@ -5,6 +5,10 @@
* 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
* Fraunhofer FIRST - extended API and implementation
@@ -1565,10 +1569,13 @@
public StringBuffer printHeader(int indent, StringBuffer output) {
printModifiers(this.modifiers, output);
+ if (this.annotations != null) {
+ printAnnotations(this.annotations, output);
+ output.append(' ');
+ }
//{ObjectTeams: role/team:
printTypeKind(this.modifiers, output);
// SH}
- if (this.annotations != null) printAnnotations(this.annotations, output);
switch (kind(this.modifiers)) {
case TypeDeclaration.CLASS_DECL :
@@ -1647,6 +1654,19 @@
try {
this.staticInitializerScope.insideTypeAnnotation = true;
resolveAnnotations(this.staticInitializerScope, this.annotations, sourceType);
+ if (this.superclass != null) {
+ this.superclass.resolveAnnotations(this.staticInitializerScope);
+ }
+ if (this.superInterfaces != null) {
+ for (int i = 0, max = this.superInterfaces.length; i < max; i++) {
+ this.superInterfaces[i].resolveAnnotations(this.staticInitializerScope);
+ }
+ }
+ if (this.typeParameters != null) {
+ for (int i = 0, count = this.typeParameters.length; i < count; i++) {
+ this.typeParameters[i].resolveAnnotations(this.staticInitializerScope);
+ }
+ }
} finally {
this.staticInitializerScope.insideTypeAnnotation = old;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java
index 87c0f87..07f6b75 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java
@@ -1,17 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 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 - extended API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
+import java.util.List;
+
import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference.AnnotationCollector;
+import org.eclipse.jdt.internal.compiler.codegen.AnnotationTargetTypeConstants;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
@@ -61,6 +69,36 @@
}
}
+ public void getAllAnnotationContexts(int targetType, int typeParameterIndex, List allAnnotationContexts) {
+ AnnotationCollector collector = new AnnotationCollector(this, targetType, typeParameterIndex, allAnnotationContexts);
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(collector, (BlockScope) null);
+ }
+ switch(collector.targetType) {
+ case AnnotationTargetTypeConstants.CLASS_TYPE_PARAMETER :
+ collector.targetType = AnnotationTargetTypeConstants.CLASS_TYPE_PARAMETER_BOUND;
+ break;
+ case AnnotationTargetTypeConstants.METHOD_TYPE_PARAMETER :
+ collector.targetType = AnnotationTargetTypeConstants.METHOD_TYPE_PARAMETER_BOUND;
+ }
+ if (this.type != null && ((this.type.bits & ASTNode.HasTypeAnnotations) != 0)) {
+ collector.info2 = 0;
+ this.type.traverse(collector, (BlockScope) null);
+ }
+ if (this.bounds != null) {
+ int boundsLength = this.bounds.length;
+ for (int i = 0; i < boundsLength; i++) {
+ TypeReference bound = this.bounds[i];
+ if ((bound.bits & ASTNode.HasTypeAnnotations) == 0) {
+ continue;
+ }
+ collector.info2 = i + 1;
+ bound.traverse(collector, (BlockScope) null);
+ }
+ }
+ }
private void internalResolve(Scope scope, boolean staticContext) {
// detect variable/type name collisions
if (this.binding != null) {
@@ -85,10 +123,28 @@
internalResolve(scope, scope.enclosingSourceType().isStatic());
}
+ public void resolveAnnotations(BlockScope scope) {
+ if (this.annotations != null) {
+ resolveAnnotations(scope, this.annotations, new Annotation.TypeUseBinding(Binding.TYPE_PARAMETER));
+ }
+ if (this.type != null) {
+ this.type.resolveAnnotations(scope);
+ }
+ if (this.bounds != null) {
+ for (int i = 0, max = this.bounds.length; i < max; i++) {
+ this.bounds[i].resolveAnnotations(scope);
+ }
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.compiler.ast.AstNode#print(int, java.lang.StringBuffer)
*/
public StringBuffer printStatement(int indent, StringBuffer output) {
+ if (this.annotations != null) {
+ printAnnotations(this.annotations, output);
+ output.append(' ');
+ }
output.append(this.name);
if (this.type != null) {
//{ObjectTeams: role type bound:
@@ -114,6 +170,11 @@
public void traverse(ASTVisitor visitor, BlockScope scope) {
if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
if (this.type != null) {
this.type.traverse(visitor, scope);
}
@@ -129,6 +190,11 @@
public void traverse(ASTVisitor visitor, ClassScope scope) {
if (visitor.visit(this, scope)) {
+ if (this.annotations != null) {
+ int annotationsLength = this.annotations.length;
+ for (int i = 0; i < annotationsLength; i++)
+ this.annotations[i].traverse(visitor, scope);
+ }
if (this.type != null) {
this.type.traverse(visitor, scope);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
index 0a30535..6bac200 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.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
* Fraunhofer FIRST - extended API and implementation
@@ -12,11 +16,16 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.codeassist.select.SelectionNodeFound;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.codegen.AnnotationContext;
+import org.eclipse.jdt.internal.compiler.codegen.AnnotationTargetTypeConstants;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@@ -43,6 +52,205 @@
public abstract class TypeReference extends Expression {
public static final TypeReference[] NO_TYPE_ARGUMENTS = new TypeReference[0];
+ static class AnnotationCollector extends ASTVisitor {
+ List annotationContexts;
+ TypeReference typeReference;
+ int targetType;
+ Annotation[] primaryAnnotations;
+ int info = -1;
+ int info2 = -1;
+ LocalVariableBinding localVariable;
+ Annotation[][] annotationsOnDimensions;
+ Wildcard currentWildcard;
+
+ public AnnotationCollector(
+ TypeParameter typeParameter,
+ int targetType,
+ int typeParameterIndex,
+ List annotationContexts) {
+ this.annotationContexts = annotationContexts;
+ this.typeReference = typeParameter.type;
+ this.targetType = targetType;
+ this.primaryAnnotations = typeParameter.annotations;
+ this.info = typeParameterIndex;
+ }
+
+ public AnnotationCollector(
+ LocalDeclaration localDeclaration,
+ int targetType,
+ LocalVariableBinding localVariable,
+ List annotationContexts) {
+ this.annotationContexts = annotationContexts;
+ this.typeReference = localDeclaration.type;
+ this.targetType = targetType;
+ this.primaryAnnotations = localDeclaration.annotations;
+ this.localVariable = localVariable;
+ }
+
+ public AnnotationCollector(
+ LocalDeclaration localDeclaration,
+ int targetType,
+ int parameterIndex,
+ List annotationContexts) {
+ this.annotationContexts = annotationContexts;
+ this.typeReference = localDeclaration.type;
+ this.targetType = targetType;
+ this.primaryAnnotations = localDeclaration.annotations;
+ this.info = parameterIndex;
+ }
+
+ public AnnotationCollector(
+ MethodDeclaration methodDeclaration,
+ int targetType,
+ List annotationContexts) {
+ this.annotationContexts = annotationContexts;
+ this.typeReference = methodDeclaration.returnType;
+ this.targetType = targetType;
+ this.primaryAnnotations = methodDeclaration.annotations;
+ }
+
+ public AnnotationCollector(
+ FieldDeclaration fieldDeclaration,
+ int targetType,
+ List annotationContexts) {
+ this.annotationContexts = annotationContexts;
+ this.typeReference = fieldDeclaration.type;
+ this.targetType = targetType;
+ this.primaryAnnotations = fieldDeclaration.annotations;
+ }
+ public AnnotationCollector(
+ TypeReference typeReference,
+ int targetType,
+ List annotationContexts) {
+ this.annotationContexts = annotationContexts;
+ this.typeReference = typeReference;
+ this.targetType = targetType;
+ }
+ public AnnotationCollector(
+ TypeReference typeReference,
+ int targetType,
+ int info,
+ List annotationContexts) {
+ this.annotationContexts = annotationContexts;
+ this.typeReference = typeReference;
+ this.info = info;
+ this.targetType = targetType;
+ }
+ public AnnotationCollector(
+ TypeReference typeReference,
+ int targetType,
+ int info,
+ int typeIndex,
+ List annotationContexts) {
+ this.annotationContexts = annotationContexts;
+ this.typeReference = typeReference;
+ this.info = info;
+ this.targetType = targetType;
+ this.info2 = typeIndex;
+ }
+ public AnnotationCollector(
+ TypeReference typeReference,
+ int targetType,
+ int info,
+ List annotationContexts,
+ Annotation[][] annotationsOnDimensions) {
+ this.annotationContexts = annotationContexts;
+ this.typeReference = typeReference;
+ this.info = info;
+ this.targetType = targetType;
+ this.annotationsOnDimensions = annotationsOnDimensions;
+ }
+ private boolean internalVisit(Annotation annotation) {
+ AnnotationContext annotationContext = null;
+ if (annotation.isRuntimeTypeInvisible()) {
+ annotationContext = new AnnotationContext(annotation, this.typeReference, this.targetType, this.primaryAnnotations, AnnotationContext.INVISIBLE, this.annotationsOnDimensions);
+ } else if (annotation.isRuntimeTypeVisible()) {
+ annotationContext = new AnnotationContext(annotation, this.typeReference, this.targetType, this.primaryAnnotations, AnnotationContext.VISIBLE, this.annotationsOnDimensions);
+ }
+ if (annotationContext != null) {
+ annotationContext.wildcard = this.currentWildcard;
+ switch(this.targetType) {
+ case AnnotationTargetTypeConstants.THROWS :
+ case AnnotationTargetTypeConstants.CLASS_TYPE_PARAMETER :
+ case AnnotationTargetTypeConstants.METHOD_TYPE_PARAMETER :
+ case AnnotationTargetTypeConstants.METHOD_PARAMETER :
+ case AnnotationTargetTypeConstants.TYPE_CAST :
+ case AnnotationTargetTypeConstants.TYPE_INSTANCEOF :
+ case AnnotationTargetTypeConstants.OBJECT_CREATION :
+ case AnnotationTargetTypeConstants.CLASS_LITERAL :
+ case AnnotationTargetTypeConstants.CLASS_EXTENDS_IMPLEMENTS:
+ annotationContext.info = this.info;
+ break;
+ case AnnotationTargetTypeConstants.CLASS_TYPE_PARAMETER_BOUND :
+ case AnnotationTargetTypeConstants.METHOD_TYPE_PARAMETER_BOUND :
+ annotationContext.info2 = this.info2;
+ annotationContext.info = this.info;
+ break;
+ case AnnotationTargetTypeConstants.LOCAL_VARIABLE :
+ annotationContext.variableBinding = this.localVariable;
+ break;
+ case AnnotationTargetTypeConstants.TYPE_ARGUMENT_METHOD_CALL :
+ case AnnotationTargetTypeConstants.TYPE_ARGUMENT_CONSTRUCTOR_CALL :
+ annotationContext.info2 = this.info2;
+ annotationContext.info = this.info;
+ }
+ this.annotationContexts.add(annotationContext);
+ }
+ return true;
+ }
+ public boolean visit(MarkerAnnotation annotation, BlockScope scope) {
+ return internalVisit(annotation);
+ }
+ public boolean visit(NormalAnnotation annotation, BlockScope scope) {
+ return internalVisit(annotation);
+ }
+ public boolean visit(SingleMemberAnnotation annotation, BlockScope scope) {
+ return internalVisit(annotation);
+ }
+ public boolean visit(Wildcard wildcard, BlockScope scope) {
+ this.currentWildcard = wildcard;
+ return true;
+ }
+ public boolean visit(Argument argument, BlockScope scope) {
+ if ((argument.bits & ASTNode.IsUnionType) == 0) {
+ return true;
+ }
+ for (int i = 0, max = this.localVariable.initializationCount; i < max; i++) {
+ int startPC = this.localVariable.initializationPCs[i << 1];
+ int endPC = this.localVariable.initializationPCs[(i << 1) + 1];
+ if (startPC != endPC) { // only entries for non zero length
+ return true;
+ }
+ }
+ return false;
+ }
+ public boolean visit(Argument argument, ClassScope scope) {
+ if ((argument.bits & ASTNode.IsUnionType) == 0) {
+ return true;
+ }
+ for (int i = 0, max = this.localVariable.initializationCount; i < max; i++) {
+ int startPC = this.localVariable.initializationPCs[i << 1];
+ int endPC = this.localVariable.initializationPCs[(i << 1) + 1];
+ if (startPC != endPC) { // only entries for non zero length
+ return true;
+ }
+ }
+ return false;
+ }
+ public boolean visit(LocalDeclaration localDeclaration, BlockScope scope) {
+ for (int i = 0, max = this.localVariable.initializationCount; i < max; i++) {
+ int startPC = this.localVariable.initializationPCs[i << 1];
+ int endPC = this.localVariable.initializationPCs[(i << 1) + 1];
+ if (startPC != endPC) { // only entries for non zero length
+ return true;
+ }
+ }
+ return false;
+ }
+ public void endVisit(Wildcard wildcard, BlockScope scope) {
+ this.currentWildcard = null;
+ }
+ }
//{ObjectTeams: for baseclass decapsulation (implement interface from Expression):
private DecapsulationState baseclassDecapsulation = DecapsulationState.NONE;
@@ -63,7 +271,7 @@
/*
* Answer a base type reference (can be an array of base type).
*/
-public static final TypeReference baseTypeReference(int baseType, int dim) {
+public static final TypeReference baseTypeReference(int baseType, int dim, Annotation[][] dimAnnotations) {
if (dim == 0) {
switch (baseType) {
@@ -89,26 +297,29 @@
}
switch (baseType) {
case (TypeIds.T_void) :
- return new ArrayTypeReference(TypeBinding.VOID.simpleName, dim, 0);
+ return new ArrayTypeReference(TypeBinding.VOID.simpleName, dim, dimAnnotations, 0);
case (TypeIds.T_boolean) :
- return new ArrayTypeReference(TypeBinding.BOOLEAN.simpleName, dim, 0);
+ return new ArrayTypeReference(TypeBinding.BOOLEAN.simpleName, dim, dimAnnotations, 0);
case (TypeIds.T_char) :
- return new ArrayTypeReference(TypeBinding.CHAR.simpleName, dim, 0);
+ return new ArrayTypeReference(TypeBinding.CHAR.simpleName, dim, dimAnnotations, 0);
case (TypeIds.T_float) :
- return new ArrayTypeReference(TypeBinding.FLOAT.simpleName, dim, 0);
+ return new ArrayTypeReference(TypeBinding.FLOAT.simpleName, dim, dimAnnotations, 0);
case (TypeIds.T_double) :
- return new ArrayTypeReference(TypeBinding.DOUBLE.simpleName, dim, 0);
+ return new ArrayTypeReference(TypeBinding.DOUBLE.simpleName, dim, dimAnnotations, 0);
case (TypeIds.T_byte) :
- return new ArrayTypeReference(TypeBinding.BYTE.simpleName, dim, 0);
+ return new ArrayTypeReference(TypeBinding.BYTE.simpleName, dim, dimAnnotations, 0);
case (TypeIds.T_short) :
- return new ArrayTypeReference(TypeBinding.SHORT.simpleName, dim, 0);
+ return new ArrayTypeReference(TypeBinding.SHORT.simpleName, dim, dimAnnotations, 0);
case (TypeIds.T_int) :
- return new ArrayTypeReference(TypeBinding.INT.simpleName, dim, 0);
+ return new ArrayTypeReference(TypeBinding.INT.simpleName, dim, dimAnnotations, 0);
default : //T_long
- return new ArrayTypeReference(TypeBinding.LONG.simpleName, dim, 0);
+ return new ArrayTypeReference(TypeBinding.LONG.simpleName, dim, dimAnnotations, 0);
}
}
+// JSR308 type annotations...
+public Annotation[] annotations = null;
+
// allows us to trap completion & selection nodes
public void aboutToResolve(Scope scope) {
// default implementation: do nothing
@@ -120,9 +331,57 @@
// only parameterized type references have bounds
}
public abstract TypeReference copyDims(int dim);
+public abstract TypeReference copyDims(int dim, Annotation[][] annotationsOnDimensions);
public int dimensions() {
return 0;
}
+public AnnotationContext[] getAllAnnotationContexts(int targetType) {
+ List allAnnotationContexts = new ArrayList();
+ AnnotationCollector collector = new AnnotationCollector(this, targetType, allAnnotationContexts);
+ this.traverse(collector, (BlockScope) null);
+ return (AnnotationContext[]) allAnnotationContexts.toArray(new AnnotationContext[allAnnotationContexts.size()]);
+}
+/**
+ * info can be either a type index (superclass/superinterfaces) or a pc into the bytecode
+ * @param targetType
+ * @param info
+ * @param allAnnotationContexts
+ */
+public void getAllAnnotationContexts(int targetType, int info, List allAnnotationContexts) {
+ AnnotationCollector collector = new AnnotationCollector(this, targetType, info, allAnnotationContexts);
+ this.traverse(collector, (BlockScope) null);
+}
+/**
+ * info can be either a type index (superclass/superinterfaces) or a pc into the bytecode
+ * @param targetType
+ * @param info
+ * @param allAnnotationContexts
+ */
+public void getAllAnnotationContexts(int targetType, int info, List allAnnotationContexts, Annotation[][] annotationsOnDimensions) {
+ AnnotationCollector collector = new AnnotationCollector(this, targetType, info, allAnnotationContexts, annotationsOnDimensions);
+ this.traverse(collector, (BlockScope) null);
+ if (annotationsOnDimensions != null) {
+ for (int i = 0, max = annotationsOnDimensions.length; i < max; i++) {
+ Annotation[] annotationsOnDimension = annotationsOnDimensions[i];
+ if (annotationsOnDimension != null) {
+ for (int j = 0, max2 = annotationsOnDimension.length; j< max2; j++) {
+ annotationsOnDimension[j].traverse(collector, (BlockScope) null);
+ }
+ }
+ }
+ }
+}
+public void getAllAnnotationContexts(int targetType, int info, int typeIndex, List allAnnotationContexts) {
+ AnnotationCollector collector = new AnnotationCollector(this, targetType, info, typeIndex, allAnnotationContexts);
+ this.traverse(collector, (BlockScope) null);
+}
+public void getAllAnnotationContexts(int targetType, List allAnnotationContexts) {
+ AnnotationCollector collector = new AnnotationCollector(this, targetType, allAnnotationContexts);
+ this.traverse(collector, (BlockScope) null);
+}
+public Annotation[][] getAnnotationsOnDimensions() {
+ return null;
+}
public abstract char[] getLastToken();
@@ -263,6 +522,15 @@
&& scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) {
scope.problemReporter().rawTypeReference(this, type);
}
+ if (this.annotations != null) {
+ switch(scope.kind) {
+ case Scope.BLOCK_SCOPE :
+ case Scope.METHOD_SCOPE :
+ resolveAnnotations((BlockScope) scope, this.annotations, new Annotation.TypeUseBinding(Binding.TYPE_USE));
+ break;
+ }
+ }
+
if (hasError) {
// do not store the computed type, keep the problem type instead
return type;
@@ -311,6 +579,10 @@
}
//Markus Witte}
+public boolean isParameterizedTypeReference() {
+ return false;
+}
+
protected void reportDeprecatedType(TypeBinding type, Scope scope, int index) {
scope.problemReporter().deprecatedType(type, this, index);
}
@@ -399,4 +671,10 @@
public abstract void traverse(ASTVisitor visitor, BlockScope scope);
public abstract void traverse(ASTVisitor visitor, ClassScope scope);
+
+protected void resolveAnnotations(BlockScope scope) {
+ if (this.annotations != null) {
+ resolveAnnotations(scope, this.annotations, new Annotation.TypeUseBinding(Binding.TYPE_USE));
+ }
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnionTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnionTypeReference.java
index f1d7415..bbf7806 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnionTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnionTypeReference.java
@@ -5,6 +5,10 @@
* 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
*******************************************************************************/
@@ -156,4 +160,9 @@
return output;
}
+ public TypeReference copyDims(int dim, Annotation[][] annotationsOnDimensions) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Wildcard.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Wildcard.java
index 73b985d..8f4db26 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Wildcard.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Wildcard.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 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
*******************************************************************************/
@@ -59,7 +63,7 @@
boundType = scope.kind == Scope.CLASS_SCOPE
? this.bound.resolveType((ClassScope)scope)
: this.bound.resolveType((BlockScope)scope, true /* check bounds*/);
-
+ this.bits |= (this.bound.bits & ASTNode.HasTypeAnnotations);
if (boundType == null) {
return null;
}
@@ -89,6 +93,7 @@
public TypeBinding resolveType(BlockScope scope, boolean checkBounds) {
if (this.bound != null) {
this.bound.resolveType(scope, checkBounds);
+ this.bits |= (this.bound.bits & ASTNode.HasTypeAnnotations);
}
return null;
}
@@ -96,6 +101,7 @@
public TypeBinding resolveType(ClassScope scope) {
if (this.bound != null) {
this.bound.resolveType(scope);
+ this.bits |= (this.bound.bits & ASTNode.HasTypeAnnotations);
}
return null;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
index ba8c821..3d65c50 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
@@ -1,10 +1,13 @@
/*******************************************************************************
- * 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
- * $Id: ClassFileConstants.java 19873 2009-04-13 16:51:05Z stephan $
+ *
+ * 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
@@ -105,6 +108,7 @@
int MAJOR_VERSION_1_5 = 49;
int MAJOR_VERSION_1_6 = 50;
int MAJOR_VERSION_1_7 = 51;
+ int MAJOR_VERSION_1_8 = 52; //TODO JAVA8: This probably needs to change
int MINOR_VERSION_0 = 0;
int MINOR_VERSION_1 = 1;
@@ -112,7 +116,7 @@
int MINOR_VERSION_3 = 3;
int MINOR_VERSION_4 = 4;
- // JDK 1.1 -> 1.7, comparable value allowing to check both major/minor version at once 1.4.1 > 1.4.0
+ // JDK 1.1 -> 1.8, comparable value allowing to check both major/minor version at once 1.4.1 > 1.4.0
// 16 unsigned bits for major, then 16 bits for minor
long JDK1_1 = ((long)ClassFileConstants.MAJOR_VERSION_1_1 << 16) + ClassFileConstants.MINOR_VERSION_3; // 1.1. is 45.3
long JDK1_2 = ((long)ClassFileConstants.MAJOR_VERSION_1_2 << 16) + ClassFileConstants.MINOR_VERSION_0;