Merge commit '9b5f216eb1069dc8f5211bf81bf5e2fb46bebbe1' into
OT_BETA_JAVA8
Conflicts:
plugins/org.eclipse.objectteams.otdt.jdt.ui/META-INF/MANIFEST.MF
releng/build-scripts/build/otdt_prerequisites.sh
releng/map/otdt.map.in
diff --git a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
index 50ad2b4..501de20 100644
--- a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jdt.core.tests.compiler
+Bundle-SymbolicName: org.eclipse.jdt.core.tests.compiler;singleton:=true
Bundle-Version: 3.8.3
Bundle-ClassPath: jdtcoretestscompiler.jar
Bundle-Vendor: %providerName
@@ -19,8 +19,10 @@
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.test.performance;bundle-version="[3.1.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.jdt.annotation;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0)",
+ org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)",
org.eclipse.objectteams.otdt
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Eclipse-BundleShape: dir
+Bundle-Activator: org.eclipse.jdt.core.tests.compiler.Activator
Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.jdt.core.tests.compiler/src/EvalTestsTarget.zip b/org.eclipse.jdt.core.tests.compiler/src/EvalTestsTarget.zip
new file mode 100644
index 0000000..19bb2e9
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/EvalTestsTarget.zip
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.compiler/src/TestJavadocVisibility.zip b/org.eclipse.jdt.core.tests.compiler/src/TestJavadocVisibility.zip
new file mode 100644
index 0000000..cfb2c9b
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/TestJavadocVisibility.zip
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/Activator.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/Activator.java
new file mode 100644
index 0000000..18a8e1b
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/Activator.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Stephan Herrmann 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;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Make the PackageAdmin service accessible to tests.
+ *
+ * @deprecated uses deprecated class PackageAdmin.
+ */
+public class Activator extends Plugin {
+
+ private static final String PLUGIN_ID = "org.eclipse.jdt.core.tests.compiler";
+
+ static org.osgi.service.packageadmin.PackageAdmin packageAdmin = null;
+
+
+ public void start(BundleContext context) throws Exception {
+
+ ServiceReference ref= context.getServiceReference(org.osgi.service.packageadmin.PackageAdmin.class.getName());
+ if (ref!=null)
+ packageAdmin = (org.osgi.service.packageadmin.PackageAdmin)context.getService(ref);
+ else
+ getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Failed to load PackageAdmin service. Will not be able to access bundles org.eclipse.jdt.annotation."));
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ // nothing
+ }
+
+ public static org.osgi.service.packageadmin.PackageAdmin getPackageAdmin() {
+ return packageAdmin;
+ }
+
+}
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..6e52392
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSyntaxTreeTest.java
@@ -0,0 +1,504 @@
+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 |
+//{ObjectTeams: with our grammar testing the IndexingParser is even less useful (creates false positives), just disable it:
+/* orig:
+ CHECK_SOURCE_ELEMENT_PARSER | CHECK_INDEXING_PARSER);
+ :giro */
+ CHECK_SOURCE_ELEMENT_PARSER /*| CHECK_INDEXING_PARSER */);
+// SH}
+ 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 0b4da40..3b0da42 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,13 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Technical University Berlin - adapted for Object Teams
+ * Jesper S Moller - realigned with bug 399695
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.parser;
@@ -22,11 +27,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 +67,47 @@
this.runNegativeTest(testFiles, expected17ProblemLog);
}
}
+public void runComplianceParserTest(
+ String[] testFiles,
+ String expected13ProblemLog,
+ String expected14ProblemLog,
+ String expected15ProblemLog,
+ String expected16ProblemLog,
+ String expected17ProblemLog){
+ if (this.complianceLevel == ClassFileConstants.JDK1_3) {
+ this.runNegativeTest(testFiles, expected13ProblemLog);
+ } else if(this.complianceLevel == ClassFileConstants.JDK1_4) {
+ this.runNegativeTest(testFiles, expected14ProblemLog);
+ } else if(this.complianceLevel == ClassFileConstants.JDK1_5) {
+ this.runNegativeTest(testFiles, expected15ProblemLog);
+ } else if(this.complianceLevel == ClassFileConstants.JDK1_6) {
+ this.runNegativeTest(testFiles, expected16ProblemLog);
+ } else if(this.complianceLevel < ClassFileConstants.JDK1_8) {
+ this.runNegativeTest(testFiles, expected17ProblemLog);
+ }
+ }
+public void runComplianceParserTest(
+ String[] testFiles,
+ String expected13ProblemLog,
+ String expected14ProblemLog,
+ String expected15ProblemLog,
+ String expected16ProblemLog,
+ String expected17ProblemLog,
+ String expected18ProblemLog){
+ if (this.complianceLevel == ClassFileConstants.JDK1_3) {
+ this.runNegativeTest(testFiles, expected13ProblemLog);
+ } else if(this.complianceLevel == ClassFileConstants.JDK1_4) {
+ this.runNegativeTest(testFiles, expected14ProblemLog);
+ } else if(this.complianceLevel == ClassFileConstants.JDK1_5) {
+ this.runNegativeTest(testFiles, expected15ProblemLog);
+ } else if(this.complianceLevel == ClassFileConstants.JDK1_6) {
+ this.runNegativeTest(testFiles, expected16ProblemLog);
+ } else if(this.complianceLevel < ClassFileConstants.JDK1_8) {
+ this.runNegativeTest(testFiles, expected17ProblemLog);
+ } else {
+ this.runNegativeTest(testFiles, expected18ProblemLog);
+ }
+ }
public void test0001() {
String[] testFiles = new String[] {
"X.java",
@@ -1061,12 +1107,12 @@
expected13ProblemLog;
String expected15ProblemLog =
- "----------\n" +
- "1. ERROR in X.java (at line 1)\n" +
- " import static for;\n" +
- " ^^^\n" +
- "Syntax error on token \"for\", Identifier expected\n" +
- "----------\n";
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " import static for;\n" +
+ " ^^^\n" +
+ "Syntax error on token \"for\", invalid Name\n" +
+ "----------\n";
runComplianceParserTest(
testFiles,
@@ -1344,7 +1390,7 @@
expected15ProblemLog
);
}
-public void test0030() {
+public void _test0030() {
String[] testFiles = new String[] {
"X.java",
"public class X {\n" +
@@ -1459,7 +1505,7 @@
expected15ProblemLog
);
}
-public void test0032() {
+public void _test0032() {
String[] testFiles = new String[] {
"X.java",
"public class X <T1 extends String, T2 extends Y {\n" +
@@ -2641,4 +2687,688 @@
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 default void foo() { System.out.println(); }\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public default void foo() { 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" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " I i = super::goo;\n" +
+ " ^^^^^^^^^^\n" +
+ "The method goo(int) from the type Y should be accessed in a static way \n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383714
+public void test0060() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(int p);\n" +
+ "}\n" +
+ "class Y {\n" +
+ " void goo(int x) {\n" +
+ " }\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " I i = new Y()::goo;\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " I i = new Y()::goo;\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Method references are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383714
+public void test0061() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(int p);\n" +
+ "}\n" +
+ "class Y {\n" +
+ " void goo(int x) {\n" +
+ " }\n" +
+ " Y() {}\n" +
+ " Y(int x) {}\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " I i = Y::new;\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 11)\n" +
+ " I i = Y::new;\n" +
+ " ^^^^^^\n" +
+ "Constructor references are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383714
+public void test0062() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " int foo(int p);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I i = p -> 10 + 20 + 30;\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " I i = p -> 10 + 20 + 30;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "Lambda expressions are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=381358
+public void test0063() {
+ if (this.complianceLevel <= ClassFileConstants.JDK1_4 || this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " int foo(int p);\n" +
+ "}\n" +
+ "public class X<T> {\n" +
+ " I i = X<String>::foo;\n" +
+ " I i2 = (p) -> 10;\n" +
+ " public static int foo(int p) {\n" +
+ " return p;\n" +
+ " }\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " I i = X<String>::foo;\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "Method references are allowed only at source level 1.8 or above\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " I i = X<String>::foo;\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "The method foo(int) from the type X<String> should be accessed in a static way \n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 6)\n" +
+ " I i2 = (p) -> 10;\n" +
+ " ^^^^^^^^^\n" +
+ "Lambda expressions are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383913#c22
+public void test0064() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] source = new String[] {
+ "X.java",
+ "class X {\n" +
+ " void foo(X this){}\n" +
+ "}"
+ };
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " void foo(X this){}\n" +
+ " ^^^^\n" +
+ "Explicit declaration of 'this' parameter is allowed only at source level 1.8 or above\n" +
+ "----------\n";
+ runComplianceParserTest(
+ source,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=391201
+public void testBug391201() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8 || this.complianceLevel < ClassFileConstants.JDK1_5) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @Marker int foo(@Marker int p) {\n" +
+ " @Marker int i = 0;\n" +
+ " return i;\n" +
+ " }\n" +
+ " @Marker\n" +
+ " class Y {}\n" +
+ " @java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_USE)\n" +
+ " @interface Marker {}" +
+ "}",
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n" +
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " @Marker int foo(@Marker int p) {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are available only when source level is at least 1.8\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " @Marker int foo(@Marker int p) {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are available only when source level is at least 1.8\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " @Marker int i = 0;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are available only when source level is at least 1.8\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 6)\n" +
+ " @Marker\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are available only when source level is at least 1.8\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+public void testBug399773() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_8)
+ return;
+ String[] testFiles = new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "interface J {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " Object p = (I & J) () -> {};\n" +
+ "}\n" ,
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java\n" +
+ "Default methods are allowed only at source level 1.8 or above\n" +
+ "----------\n" +
+ "2. ERROR in X.java\n" +
+ "Default methods are allowed only at source level 1.8 or above\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 10)\n" +
+ " Object p = (I & J) () -> {};\n" +
+ " ^^^^^\n" +
+ "Additional bounds are not allowed in cast operator at source levels below 1.8\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 10)\n" +
+ " Object p = (I & J) () -> {};\n" +
+ " ^^^^^^^^\n" +
+ "Lambda expressions are allowed only at source level 1.8 or above\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 10)\n" +
+ " Object p = (I & J) () -> {};\n" +
+ " ^^^^^^^^\n" +
+ "The target type of this expression must be a functional interface\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399778, [1.8][compiler] Conditional operator expressions should propagate target types
+public void testBug399778() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return;
+ String[] testFiles = new String[] {
+ "X.java",
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "public class X {\n" +
+ " List<String> l = null == null ? Arrays.asList() : Arrays.asList(\"Hello\",\"world\");\n" +
+ "}\n",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " List<String> l = null == null ? Arrays.asList() : Arrays.asList(\"Hello\",\"world\");\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from List<capture#1-of ? extends Object> to List<String>\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ "" // 1.8 should compile this fine.
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399778, [1.8][compiler] Conditional operator expressions should propagate target types
+public void testBug399778a() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return;
+ String[] testFiles = new String[] {
+ "X.java",
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "public class X {\n" +
+ " List<String> l = (List<String>) (null == null ? Arrays.asList() : Arrays.asList(\"Hello\",\"world\"));\n" +
+ "}\n",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 4)\n" +
+ " List<String> l = (List<String>) (null == null ? Arrays.asList() : Arrays.asList(\"Hello\",\"world\"));\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Type safety: Unchecked cast from List<capture#1-of ? extends Object> to List<String>\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog // 1.8 also issue type safety warning.
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399780: static methods in interfaces.
+public void testBug399780() {
+ if(this.complianceLevel >= ClassFileConstants.JDK1_8) {
+ return;
+ }
+ String[] testFiles = new String[] {
+ "I.java",
+ "interface I {\n" +
+ " public static void foo1() { System.out.println(); }\n" +
+ " public static void foo2();\n" +
+ " public abstract static void foo3();\n" +
+ "}\n"
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in I.java (at line 2)\n" +
+ " public static void foo1() { System.out.println(); }\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo1; only public & abstract are permitted\n" +
+ "----------\n" +
+ "2. ERROR in I.java (at line 2)\n" +
+ " public static void foo1() { System.out.println(); }\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Static methods are allowed in interfaces only at source level 1.8 or above\n" +
+ "----------\n" +
+ "3. ERROR in I.java (at line 3)\n" +
+ " public static void foo2();\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo2; only public & abstract are permitted\n" +
+ "----------\n" +
+ "4. ERROR in I.java (at line 4)\n" +
+ " public abstract static void foo3();\n" +
+ " ^^^^^^\n" +
+ "Illegal modifier for the interface method foo3; only public & abstract are permitted\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=399769: Use of '_' as identifier name should trigger a diagnostic
+public void testBug399781() {
+ String[] testFiles = new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int _;\n" +
+ " void foo(){\n" +
+ " int _ = 3;\n" +
+ " int _123 = 4;\n" +
+ " int a_ = 5;\n" +
+ " }\n" +
+ " void goo(int _) {}\n" +
+ " void zoo() {\n" +
+ " try {\n" +
+ " } catch (Exception _) {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int _;\n" +
+ " ^\n" +
+ "\'_\' should not be used as an identifier, since it is a reserved keyword from source level 1.8 on\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " int _ = 3;\n" +
+ " ^\n" +
+ "\'_\' should not be used as an identifier, since it is a reserved keyword from source level 1.8 on\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 4)\n" +
+ " int _ = 3;\n" +
+ " ^\n" +
+ "The local variable _ is hiding a field from type X\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 8)\n" +
+ " void goo(int _) {}\n" +
+ " ^\n" +
+ "\'_\' should not be used as an identifier, since it is a reserved keyword from source level 1.8 on\n" +
+ "----------\n" +
+ "5. WARNING in X.java (at line 8)\n" +
+ " void goo(int _) {}\n" +
+ " ^\n" +
+ "The parameter _ is hiding a field from type X\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 11)\n" +
+ " } catch (Exception _) {\n" +
+ " ^\n" +
+ "\'_\' should not be used as an identifier, since it is a reserved keyword from source level 1.8 on\n" +
+ "----------\n" +
+ "7. WARNING in X.java (at line 11)\n" +
+ " } catch (Exception _) {\n" +
+ " ^\n" +
+ "The parameter _ is hiding a field from type X\n" +
+ "----------\n";
+ String expected13ProblemLog =
+ "----------\n" +
+ "1. WARNING in X.java (at line 4)\n" +
+ " int _ = 3;\n" +
+ " ^\n" +
+ "The local variable _ is hiding a field from type X\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 8)\n" +
+ " void goo(int _) {}\n" +
+ " ^\n" +
+ "The parameter _ is hiding a field from type X\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 11)\n" +
+ " } catch (Exception _) {\n" +
+ " ^\n" +
+ "The parameter _ is hiding a field from type X\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expected13ProblemLog,
+ expected13ProblemLog,
+ expected13ProblemLog,
+ expected13ProblemLog,
+ expected13ProblemLog,
+ expectedProblemLog
+ );
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=406846: [1.8] compiler NPE for method reference/lambda code compiled with < 1.8 compliance
+public void test406846() {
+
+ if (this.complianceLevel >= ClassFileConstants.JDK1_8) // tested in LET.
+ return;
+
+ String[] testFiles = new String[] {
+ "X.java",
+ "import java.util.*;\n" +
+ "public class X {\n" +
+ " public static <E> void printItem(E value, int index) {\n" +
+ " String output = String.format(\"%d -> %s\", index, value);\n" +
+ " System.out.println(output);\n" +
+ " }\n" +
+ " public static void main(String[] argv) {\n" +
+ " List<String> list = Arrays.asList(\"A\",\"B\",\"C\");\n" +
+ " eachWithIndex(list,X::printItem);\n" +
+ " }\n" +
+ " interface ItemWithIndexVisitor<E> {\n" +
+ " public void visit(E item, int index);\n" +
+ " }\n" +
+ " public static <E> void eachWithIndex(List<E> list, ItemWithIndexVisitor<E> visitor) {\n" +
+ " for (int i = 0; i < list.size(); i++) {\n" +
+ " visitor.visit(list.get(i), i);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ };
+
+ String expectedProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " eachWithIndex(list,X::printItem);\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Method references are allowed only at source level 1.8 or above\n" +
+ "----------\n";
+ String expected1314ProblemLog =
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " public static <E> void printItem(E value, int index) {\n" +
+ " ^\n" +
+ "Syntax error, type parameters are only available if source level is 1.5 or greater\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " String output = String.format(\"%d -> %s\", index, value);\n" +
+ " ^^^^^^\n" +
+ "The method format(String, Object[]) in the type String is not applicable for the arguments (String, int, E)\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 8)\n" +
+ " List<String> list = Arrays.asList(\"A\",\"B\",\"C\");\n" +
+ " ^^^^^^\n" +
+ "Syntax error, parameterized types are only available if source level is 1.5 or greater\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 8)\n" +
+ " List<String> list = Arrays.asList(\"A\",\"B\",\"C\");\n" +
+ " ^^^^^^\n" +
+ "The method asList(T[]) in the type Arrays is not applicable for the arguments (String, String, String)\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 9)\n" +
+ " eachWithIndex(list,X::printItem);\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Method references are allowed only at source level 1.8 or above\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 11)\n" +
+ " interface ItemWithIndexVisitor<E> {\n" +
+ " ^\n" +
+ "Syntax error, type parameters are only available if source level is 1.5 or greater\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 14)\n" +
+ " public static <E> void eachWithIndex(List<E> list, ItemWithIndexVisitor<E> visitor) {\n" +
+ " ^\n" +
+ "Syntax error, type parameters are only available if source level is 1.5 or greater\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 14)\n" +
+ " public static <E> void eachWithIndex(List<E> list, ItemWithIndexVisitor<E> visitor) {\n" +
+ " ^\n" +
+ "Syntax error, parameterized types are only available if source level is 1.5 or greater\n" +
+ "----------\n" +
+ "9. ERROR in X.java (at line 14)\n" +
+ " public static <E> void eachWithIndex(List<E> list, ItemWithIndexVisitor<E> visitor) {\n" +
+ " ^\n" +
+ "Syntax error, parameterized types are only available if source level is 1.5 or greater\n" +
+ "----------\n";
+
+ runComplianceParserTest(
+ testFiles,
+ expected1314ProblemLog,
+ expected1314ProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog,
+ expectedProblemLog
+ );
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
index 5eb01c8..ba11373 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Technical University Berlin - adapted for Object Teams
@@ -2500,7 +2504,7 @@
* Should recover from method with missing argument names
*/
-public void test32() {
+public void _test32() {
String s =
"public class WB2 { \n"+
@@ -4646,14 +4650,14 @@
" super();\n" +
" }\n" +
" int hello() {\n" +
- " fo = $missing$;\n" +
+ " fo $missing$;\n" +
" }\n" +
" int world() {\n" +
" }\n" +
" void foo() {\n" +
" }\n" +
" }\n" +
- " ba = $missing$;\n" +
+ " ba $missing$;\n" +
" }\n" +
"}\n";
@@ -4848,7 +4852,7 @@
" else\n" +
" if ((depth > 1))\n" +
" {\n" +
- " sol = $missing$;\n" +
+ " sol $missing$;\n" +
" }\n" +
" else\n" +
" ;\n" +
@@ -6003,7 +6007,7 @@
" restricts breakpoint;\n" +
" given thread;\n" +
" any other;\n" +
- " specified = $missing$;\n" +
+ " specified $missing$;\n" +
" }\n" +
" public void removeThreadFilter(IJavaThread thread) {\n" +
" removes the;\n" +
@@ -6014,7 +6018,7 @@
" request as;\n" +
" does not;\n" +
" the removal;\n" +
- " thread = $missing$;\n" +
+ " thread $missing$;\n" +
:giro */
// SH}
" }\n" +
@@ -6582,7 +6586,7 @@
expectedFullUnitToString,
expectedCompletionDietUnitToString, testName);
}
-public void test110() {
+public void _test110() {
String s =
"public class X {\n" +
" void bar(){\n" +
@@ -7585,7 +7589,7 @@
expectedCompletionDietUnitToString, testName);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=157570
-public void test124() {
+public void _test124() {
String s =
"public class Test {\n" +
" void aMethod() {\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
index 55209fb..512232e 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java
@@ -1,13 +1,19 @@
/*******************************************************************************
- * 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
* Technical University Berlin - adapted for Object Teams
+ * Stephan Herrmann - Contribution for
+ * bug 401035 - [1.8] A few tests have started failing recently
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.parser;
@@ -36,7 +42,9 @@
public GenericDietRecoveryTest(String testName){
super(testName);
}
-
+static {
+// TESTS_NAMES = new String[] { "test0025" };
+}
/*
* Toggle compiler in mode -1.5
*/
@@ -949,7 +957,7 @@
expectedFullUnitToString,
expectedCompletionDietUnitToString, testName);
}
-public void test0019() {
+public void _test0019() {
String s =
"package a; \n"
@@ -1208,7 +1216,7 @@
String expectedDietUnitToString =
"import java.util.*;\n" +
"public interface X<T> {\n" +
- " <K>Map<K, T> foo();\n" +
+ " public <K>Map<K, T> foo();\n" +
"}\n";
String expectedDietPlusBodyUnitToString =
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java
new file mode 100644
index 0000000..744c33f
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LambdaExpressionSyntaxTest.java
@@ -0,0 +1,719 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.parser;
+
+import java.io.File;
+import java.io.IOException;
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
+
+public class LambdaExpressionSyntaxTest extends AbstractSyntaxTreeTest {
+
+ private static String jsr335TestScratchArea = "c:\\Jsr335TestScratchArea";
+ private static String referenceCompiler = "C:\\jdk-7-ea-bin-b75-windows-i586-30_oct_2009\\jdk7\\bin\\javac.exe"; // TODO: Patch when RI becomes available.
+
+ public static Class testClass() {
+ return LambdaExpressionSyntaxTest.class;
+ }
+ public void initialize(CompilerTestSetup setUp) {
+ super.initialize(setUp);
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+ }
+
+ public LambdaExpressionSyntaxTest(String testName){
+ super(testName, referenceCompiler, jsr335TestScratchArea);
+ if (referenceCompiler != null) {
+ File f = new File(jsr335TestScratchArea);
+ if (!f.exists()) {
+ f.mkdir();
+ }
+ CHECK_ALL |= CHECK_JAVAC_PARSER;
+ }
+ }
+
+ static {
+ // TESTS_NAMES = new String[] { "test0012" };
+ // TESTS_NUMBERS = new int[] { 133, 134, 135 };
+ if (!(new File(referenceCompiler).exists())) {
+ referenceCompiler = null;
+ jsr335TestScratchArea = null;
+ }
+ }
+ // type elided, unparenthesized parameter + expression body lambda in casting context.
+ public void test0001() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(((I) x -> x * x).square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(((I) (<no type> x) -> (x * x)).square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0001", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda as initializer.
+ public void test0002() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = x -> x * x;\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = (<no type> x) -> (x * x);\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0002", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda as initializer, full lambda is parenthesized.
+ public void test0003() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = ((((x -> x * x))));\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = (((((<no type> x) -> (x * x)))));\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0003", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda as RHS of assignment, full lambda is parenthesized.
+ public void test0004() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i;\n" +
+ " i = (x -> x * x);\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i;\n" +
+ " i = ((<no type> x) -> (x * x));\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0004", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in return statement, full lambda is parenthesized.
+ public void test0005() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static I getI() {\n" +
+ " return (x -> x * x);\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static I getI() {\n" +
+ " return ((<no type> x) -> (x * x));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0005", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in conditional expression.
+ public void test0006() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = args == null ? x -> x * x : x -> x * x * x;\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = ((args == null) ? (<no type> x) -> (x * x) : (<no type> x) -> ((x * x) * x));\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0006", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in message send.
+ public void test0007() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " foo(x -> x * x, x -> x * x * x);\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " foo((<no type> x) -> (x * x), (<no type> x) -> ((x * x) * x));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0007", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in constructor call.
+ public void test0008() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " X (I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " new X(x -> x * x, x -> x * x * x);\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " X(I i1, I i2) {\n" +
+ " super();\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X((<no type> x) -> (x * x), (<no type> x) -> ((x * x) * x));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0008", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in lambda.
+ public void test0009() throws IOException {
+ String source =
+ "interface I {\n" +
+ " I square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println (((I) a->b->c->d->e->f->g-> null).square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " I square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(((I) (<no type> a) -> (<no type> b) -> (<no type> c) -> (<no type> d) -> (<no type> e) -> (<no type> f) -> (<no type> g) -> null).square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0009", expectedUnitToString);
+ }
+ // type elided, unparenthesized parameter + expression body lambda in an initializer block
+ public void test00010() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static I i = x -> x * x;\n" +
+ " {\n" +
+ " i = x -> x * x * x;\n" +
+ " }\n" +
+ " static {\n" +
+ " i = x -> x * x * x;\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static I i = (<no type> x) -> (x * x);\n" +
+ " {\n" +
+ " i = (<no type> x) -> ((x * x) * x);\n" +
+ " }\n" +
+ " static {\n" +
+ " i = (<no type> x) -> ((x * x) * x);\n" +
+ " }\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test00010", expectedUnitToString);
+ }
+ // type elided, parenthesized parameter + expression body lambda in casting context.
+ public void test0011() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(((I) (x) -> x * x).square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(((I) (<no type> x) -> (x * x)).square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0011", expectedUnitToString);
+ }
+ // Normal & minimal parameter list + expression body lambda in assignment context.
+ public void test0012() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = (int x) -> x * x;\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = (int x) -> (x * x);\n" +
+ " System.out.println(i.square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0012", expectedUnitToString);
+ }
+ // Normal parameter list, with modifiers & annotations + expression body lambda in invocation context.
+ public void test0013() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " @interface Positive {}\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " foo((final int x) -> x * x, (final @Positive int x) -> x * x * x);\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " @interface Positive {\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " foo((final int x) -> (x * x), (final @Positive int x) -> ((x * x) * x));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0013", expectedUnitToString);
+ }
+ // Vararg parameter list, with modifiers & annotations + expression body lambda in message send context.
+ public void test0014() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int ... x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " @interface Positive {}\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " foo((final int ... x) -> 10, (final @Positive int [] x) -> 20);\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int... x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " @interface Positive {\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static void foo(I i1, I i2) {\n" +
+ " System.out.println(i1.square(10));\n" +
+ " System.out.println(i2.square(10));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " foo((final int... x) -> 10, (final @Positive int[] x) -> 20);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0014", expectedUnitToString);
+ }
+ // multi parameter type elided list + expression body lambda in return statement.
+ public void test0015() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int product(int x, int y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static I getI() {\n" +
+ " return ((x, y) -> x * y);\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.product(5, 6));\n" +
+ " }\n" +
+ "};\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int product(int x, int y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static I getI() {\n" +
+ " return ((<no type> x, <no type> y) -> (x * y));\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.product(5, 6));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0015", expectedUnitToString);
+ }
+ // multi parameter type specified list + block body lambda in return statement.
+ public void test0016() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int product(int x, int y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static I getI() {\n" +
+ " return (int x, int y) -> { return x * y; };\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.product(5, 6));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int product(int x, int y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static I getI() {\n" +
+ " return (int x, int y) -> {\n" +
+ " return (x * y);\n" +
+ "};\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = getI();\n" +
+ " System.out.println(i.product(5, 6));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0016", expectedUnitToString);
+ }
+ // noarg + block body lambda
+ public void test0017() throws IOException {
+ String source =
+ "interface I {\n" +
+ " String noarg();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println( ((I) () -> { return \"noarg\"; }).noarg());\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " String noarg();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(((I) () -> {\n" +
+ " return \"noarg\";\n" +
+ "}).noarg());\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0017", expectedUnitToString);
+ }
+ // Assorted tests.
+ public void test0018() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo();\n" +
+ "}\n" +
+ "\n" +
+ "interface J {\n" +
+ " int foo();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I i1 = ()->{}; \n" +
+ " J j1 = ()->0;\n" +
+ " J j2 = ()->{ return 0; };\n" +
+ " I i2 = ()->{ System.gc(); };\n" +
+ " J j3 = ()->{\n" +
+ " if (true) return 0;\n" +
+ " else {\n" +
+ " int r = 12;\n" +
+ " for (int i = 1; i < 8; i++)\n" +
+ " r += i;\n" +
+ " return r;\n" +
+ " }\n" +
+ " };\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo();\n" +
+ "}\n" +
+ "interface J {\n" +
+ " int foo();\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I i1 = () -> {\n" +
+ " };\n" +
+ " J j1 = () -> 0;\n" +
+ " J j2 = () -> {\n" +
+ " return 0;\n" +
+ " };\n" +
+ " I i2 = () -> {\n" +
+ " System.gc();\n" +
+ " };\n" +
+ " J j3 = () -> {\n" +
+ " if (true)\n" +
+ " return 0;\n" +
+ " else\n" +
+ " {\n" +
+ " int r = 12;\n" +
+ " for (int i = 1;; (i < 8); i ++) \n" +
+ " r += i;\n" +
+ " return r;\n" +
+ " }\n" +
+ " };\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0018", expectedUnitToString);
+ }
+
+ // like test0001() but body expression is an assignment
+ public void test0019() throws IOException {
+ String source =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " int y;\n" +
+ " public static void main(String [] args) {\n" +
+ " System.out.println(((I) x -> y = x * x ).square(10));\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " int square(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " int y;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(((I) (<no type> x) -> y = (x * x)).square(10));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0019", expectedUnitToString);
+ }
+
+ // Coverage: exercise this condition in Parser.consumeExpression():
+ // if (this.valueLambdaNestDepth >= 0 && this.stateStackLengthStack[this.valueLambdaNestDepth] == this.stateStackTop - 1)
+ // make sure we see a (true && false) combination
+ public void testNestedLambda01() throws IOException {
+ String source =
+ "public class C {\n" +
+ " I foo() {\n" +
+ " return (i1, i2) -> (String x1, String x2) -> { \n" +
+ " return x1+x2; \n" + // here end-of-expression does not finish the type-eliding lambda (i1,i2)->...
+ " };\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "interface I {\n" +
+ " String doit(String s1, String s2);\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class C {\n" +
+ " public C() {\n" +
+ " super();\n" +
+ " }\n" +
+ " I foo() {\n" +
+ " return (<no type> i1, <no type> i2) -> (String x1, String x2) -> {\n" +
+ " return (x1 + x2);\n" +
+ "};\n" +
+ " }\n" +
+ "}\n" +
+ "interface I {\n" +
+ " String doit(String s1, String s2);\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "testNestedLambda01", expectedUnitToString);
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385132
+ public void test385132() throws IOException {
+ String source = "->";
+ String expectedErrorString =
+ "----------\n" +
+ "1. ERROR in test385132 (at line 1)\n" +
+ " ->\n" +
+ " ^^\n" +
+ "Syntax error on token \"->\", delete this token\n" +
+ "----------\n";
+
+ checkParse(CHECK_PARSER , source.toCharArray(), expectedErrorString, "test385132", null);
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
index 75d26ea..a4651ea 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -71,18 +75,22 @@
" }\n" +
"}\n"
},
- "----------\n" +
- "1. ERROR in X.java (at line 3)\n" +
- " throws new X\n" +
- " ^^^^^^\n" +
- "Syntax error on token \"throws\", throw expected\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " throws new X\n" +
- " ^\n" +
- "Syntax error, unexpected end of method\n" +
- "----------\n"
- );
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"throws\", throw expected\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^\n" +
+ "Syntax error, insert \"( )\" to complete Expression\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^\n" +
+ "Syntax error, insert \";\" to complete BlockStatements\n" +
+ "----------\n");
}
public void test004() {
this.runNegativeTest(
@@ -130,18 +138,22 @@
" }\n" +
"}\n"
},
- "----------\n" +
- "1. ERROR in X.java (at line 3)\n" +
- " throws new X\n" +
- " ^^^^^^\n" +
- "Syntax error on token \"throws\", throw expected\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
- " throws new X\n" +
- " ^\n" +
- "Syntax error, unexpected end of initializer\n" +
- "----------\n"
- );
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^^^^^^\n" +
+ "Syntax error on token \"throws\", throw expected\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^\n" +
+ "Syntax error, insert \"( )\" to complete Expression\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " throws new X\n" +
+ " ^\n" +
+ "Syntax error, insert \";\" to complete BlockStatements\n" +
+ "----------\n");
}
public void test007() {
this.runNegativeTest(
@@ -228,7 +240,7 @@
"----------\n"
);
}
-public void test011() {
+public void _test011() {
this.runNegativeTest(
new String[] {
"X.java",
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java
new file mode 100644
index 0000000..80517b3
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceExpressionSyntaxTest.java
@@ -0,0 +1,983 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.parser;
+
+import java.io.File;
+import java.io.IOException;
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
+
+public class ReferenceExpressionSyntaxTest extends AbstractSyntaxTreeTest {
+
+ private static String jsr335TestScratchArea = "c:\\Jsr335TestScratchArea";
+ private static String referenceCompiler = "C:\\jdk-7-ea-bin-b75-windows-i586-30_oct_2009\\jdk7\\bin\\javac.exe"; // TODO: Patch when RI becomes available.
+
+ public static Class testClass() {
+ return ReferenceExpressionSyntaxTest.class;
+ }
+ public void initialize(CompilerTestSetup setUp) {
+ super.initialize(setUp);
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+ }
+
+ public ReferenceExpressionSyntaxTest(String testName){
+ super(testName, referenceCompiler, jsr335TestScratchArea);
+ if (referenceCompiler != null) {
+ File f = new File(jsr335TestScratchArea);
+ if (!f.exists()) {
+ f.mkdir();
+ }
+ CHECK_ALL |= CHECK_JAVAC_PARSER;
+ }
+ }
+
+ static {
+ // TESTS_NAMES = new String[] { "test0012" };
+ // TESTS_NUMBERS = new int[] { 133, 134, 135 };
+ if (!(new File(referenceCompiler).exists())) {
+ referenceCompiler = null;
+ jsr335TestScratchArea = null;
+ }
+ }
+ // Reference expression - super:: form, without type arguments.
+ public void test0001() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " public static void main(String [] args) {\n" +
+ " new X().doit();\n" +
+ " }\n" +
+ " void doit() {\n" +
+ " I i = super::foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().doit();\n" +
+ " }\n" +
+ " void doit() {\n" +
+ " I i = super::foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0001", expectedUnitToString);
+ }
+ // Reference expression - super:: form, with type arguments.
+ public void test0002() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " public static void main(String [] args) {\n" +
+ " new X().doit();\n" +
+ " }\n" +
+ " void doit() {\n" +
+ " I i = super::<String>foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X extends Y {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().doit();\n" +
+ " }\n" +
+ " void doit() {\n" +
+ " I i = super::<String>foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0002", expectedUnitToString);
+ }
+ // Reference expression - SimpleName:: form, without type arguments.
+ public void test0003() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y::foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y::foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0003", expectedUnitToString);
+ }
+ // Reference expression - SimpleName:: form, with type arguments.
+ public void test0004() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y::<String>foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y::<String>foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0004", expectedUnitToString);
+ }
+ // Reference expression - QualifiedName:: form, without type arguments.
+ public void test0005() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y.Z::foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " static class Z {\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y.Z::foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " static class Z {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0005", expectedUnitToString);
+ }
+ // Reference expression - QualifiedName:: form, with type arguments.
+ public void test0006() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y.Z::<String>foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " static class Z {\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y.Z::<String>foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " static class Z {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0006", expectedUnitToString);
+ }
+ // Reference expression - Primary:: form, without type arguments.
+ public void test0007() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = new Y()::foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = new Y()::foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0007", expectedUnitToString);
+ }
+ // Reference expression - primary:: form, with type arguments.
+ public void test0008() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = new Y()::<String>foo;\n" +
+ " i.foo(10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = new Y()::<String>foo;\n" +
+ " i.foo(10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0008", expectedUnitToString);
+ }
+ // Reference expression - X<T>:: form, without type arguments.
+ public void test0009() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String> y, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>::foo;\n" +
+ " i.foo(new Y<String>(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String> y, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>::foo;\n" +
+ " i.foo(new Y<String>(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0009", expectedUnitToString);
+ }
+ // Reference expression - X<T>:: form, with type arguments.
+ public void test0010() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String> y, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>::<String>foo;\n" +
+ " i.foo(new Y<String>(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String> y, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>::<String>foo;\n" +
+ " i.foo(new Y<String>(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0010", expectedUnitToString);
+ }
+ // Reference expression - X<T>.Name:: form, without type arguments.
+ public void test0011() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String>.Z z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.Z::foo;\n" +
+ " i.foo(new Y<String>().new Z(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String>.Z z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>.Z::foo;\n" +
+ " i.foo(new Y<String>().new Z(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0011", expectedUnitToString);
+ }
+ // Reference expression - X<T>.Name:: form, with type arguments.
+ public void test0012() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String>.Z z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.Z::<String>foo;\n" +
+ " i.foo(new Y<String>().new Z(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String>.Z z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>.Z::<String>foo;\n" +
+ " i.foo(new Y<String>().new Z(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0012", expectedUnitToString);
+ }
+ // Reference expression - X<T>.Y<K>:: form, without type arguments.
+ public void test0013() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String>.Z<Integer> z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.Z<Integer>::foo;\n" +
+ " i.foo(new Y<String>().new Z<Integer>(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String>.Z<Integer> z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>.Z<Integer>::foo;\n" +
+ " i.foo(new Y<String>().new Z<Integer>(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0013", expectedUnitToString);
+ }
+ // Reference expression - X<T>.Y<K>:: form, with type arguments.
+ public void test0014() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String>.Z<Integer> z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.Z<Integer>::<String>foo;\n" +
+ " i.foo(new Y<String>().new Z<Integer>(), 10); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String>.Z<Integer> z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>.Z<Integer>::<String>foo;\n" +
+ " i.foo(new Y<String>().new Z<Integer>(), 10);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0014", expectedUnitToString);
+ }
+ // Constructor reference expression - X<T>.Y<K>::new form, with type arguments.
+ public void test0015() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(Y<String> y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.Z<Integer>::<String>new;\n" +
+ " i.foo(new Y<String>()); \n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " Z() {\n" +
+ " System.out.println(\"Y<T>.Z<K>::new\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(Y<String> y);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = Y<String>.Z<Integer>::<String>new;\n" +
+ " i.foo(new Y<String>());\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z<K> {\n" +
+ " Z() {\n" +
+ " super();\n" +
+ " System.out.println(\"Y<T>.Z<K>::new\");\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0015", expectedUnitToString);
+ }
+ // Reference expression - PrimitiveType[]:: form, with type arguments.
+ public void test0016() throws IOException {
+ String source =
+ "interface I {\n" +
+ " Object copy(int [] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = int[]::<String>clone;\n" +
+ " i.copy(new int[10]); \n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " Object copy(int[] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = int[]::<String>clone;\n" +
+ " i.copy(new int[10]);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0016", expectedUnitToString);
+ }
+ // Reference expression - Name[]:: form, with type arguments.
+ public void test0017() throws IOException {
+ String source =
+ "interface I {\n" +
+ " Object copy(X [] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = X[]::<String>clone;\n" +
+ " i.copy(new X[10]); \n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " Object copy(X[] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = X[]::<String>clone;\n" +
+ " i.copy(new X[10]);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0017", expectedUnitToString);
+ }
+ // Reference expression - X<T>.Y<K>[]:: form, with type arguments.
+ public void test0018() throws IOException {
+ String source =
+ "interface I {\n" +
+ " Object copy(X<String>.Y<Integer> [] p);\n" +
+ "}\n" +
+ "public class X<T> {\n" +
+ " class Y<K> {\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = X<String>.Y<Integer>[]::<String>clone;\n" +
+ " X<String>.Y<Integer>[] xs = null;\n" +
+ " i.copy(xs); \n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " Object copy(X<String>.Y<Integer>[] p);\n" +
+ "}\n" +
+ "public class X<T> {\n" +
+ " class Y<K> {\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " I i = X<String>.Y<Integer>[]::<String>clone;\n" +
+ " X<String>.Y<Integer>[] xs = null;\n" +
+ " i.copy(xs);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0018", expectedUnitToString);
+ }
+
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=384320, syntax error while mixing 308 and 335.
+ public void test0019() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo(X<String> s, int x);\n" +
+ "}\n" +
+ "public class X<T> {\n" +
+ " I i = X<@Foo({\"hello\"}) String>::foo;\n" +
+ " void foo(int x) {\n" +
+ " }\n" +
+ "}\n" +
+ "@interface Foo {\n" +
+ " String [] value();\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo(X<String> s, int x);\n" +
+ "}\n" +
+ "public class X<T> {\n" +
+ " I i = X<@Foo({\"hello\"}) String>::foo;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(int x) {\n" +
+ " }\n" +
+ "}\n" +
+ "@interface Foo {\n" +
+ " String[] value();\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0019", expectedUnitToString);
+ }
+
+ // Reference expression - Name::new forms, with/without type arguments.
+ public void test0020() throws IOException {
+ String source =
+ "interface I {\n" +
+ " Y foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " class Z extends Y {\n" +
+ " public Z(int x) {\n" +
+ " super(x);\n" +
+ " System.out.println(\"Z\"+x);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String [] args) {\n" +
+ " Y y;\n" +
+ " I i = Y::new;\n" +
+ " y = i.foo(10); \n" +
+ " i = X.Z::new;\n" +
+ " y = i.foo(20); \n" +
+ " i = W<Integer>::new;\n" +
+ " y = i.foo(23);\n" +
+ " }\n" +
+ "}\n" +
+ "class W<T> extends Y {\n" +
+ " public W(T x) {\n" +
+ " super(0);\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public Y(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "interface I {\n" +
+ " Y foo(int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " class Z extends Y {\n" +
+ " public Z(int x) {\n" +
+ " super(x);\n" +
+ " System.out.println((\"Z\" + x));\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " Y y;\n" +
+ " I i = Y::new;\n" +
+ " y = i.foo(10);\n" +
+ " i = X.Z::new;\n" +
+ " y = i.foo(20);\n" +
+ " i = W<Integer>::new;\n" +
+ " y = i.foo(23);\n" +
+ " }\n" +
+ "}\n" +
+ "class W<T> extends Y {\n" +
+ " public W(T x) {\n" +
+ " super(0);\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " public Y(int x) {\n" +
+ " super();\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0003", expectedUnitToString);
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385132
+ public void test385132() throws IOException {
+ String source = "::";
+ String expectedErrorString =
+ "----------\n" +
+ "1. ERROR in test385132 (at line 1)\n" +
+ " ::\n" +
+ " ^^\n" +
+ "Syntax error on token \"::\", delete this token\n" +
+ "----------\n";
+
+ checkParse(CHECK_PARSER , source.toCharArray(), expectedErrorString, "test385132", null);
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=385374, Support for 308 style type annotations on 335 constructs.
+ public void test385374() throws IOException {
+ String source =
+ "interface I {\n" +
+ " void foo();\n" +
+ "}\n" +
+ "@interface TypeAnnotation {\n" +
+ "}\n" +
+ "\n" +
+ "class X<T> {\n" +
+ " // Primitive array form\n" +
+ " I x1 = @TypeAnnotation int []::clone;\n" +
+ " // Primitive array form with dimension annotations.\n" +
+ " I x2 = @TypeAnnotation int @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" +
+ " // Primitive array form with dimension annotations and type parameter annotations.\n" +
+ " I x3 = @TypeAnnotation int @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
+ " // Reference type name form\n" +
+ " I x4 = @TypeAnnotation X::clone;\n" +
+ " // Reference type name array form\n" +
+ " I x5 = @TypeAnnotation X []::clone;\n" +
+ " // Reference type name array form with dimension annotations.\n" +
+ " I x6 = @TypeAnnotation X @ArrayAnnotation[]@ArrayAnnotation[]::clone; \n" +
+ " // Reference type name array form with dimension annotations and type parameter annotations.\n" +
+ " I x7 = @TypeAnnotation X @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
+ " // Generic type array form with dimension annotations and type parameter annotations.\n" +
+ " I x8 = @TypeAnnotation X<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
+ " // Qualified generic type array form with dimension annotations and type parameter annotations.\n" +
+ " I x9 = @TypeAnnotation X<@TypeParameterAnnotation String>.Y<@TypeParameterAnnotation String> @ArrayAnnotation[]@ArrayAnnotation[]::<@TypeParameterAnnotation String>clone; \n" +
+ "}\n";
+
+ String expectedUnitToString =
+ "interface I {\n" +
+ " void foo();\n" +
+ "}\n" +
+ "@interface TypeAnnotation {\n" +
+ "}\n" +
+ "class X<T> {\n" +
+ " I x1 = @TypeAnnotation int[]::clone;\n" +
+ " I x2 = @TypeAnnotation int @ArrayAnnotation [] @ArrayAnnotation []::clone;\n" +
+ " I x3 = @TypeAnnotation int @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" +
+ " I x4 = @TypeAnnotation X::clone;\n" +
+ " I x5 = @TypeAnnotation X[]::clone;\n" +
+ " I x6 = @TypeAnnotation X @ArrayAnnotation [] @ArrayAnnotation []::clone;\n" +
+ " I x7 = @TypeAnnotation X @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" +
+ " I x8 = @TypeAnnotation X<@TypeParameterAnnotation String> @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" +
+ " I x9 = @TypeAnnotation X<@TypeParameterAnnotation String>.Y<@TypeParameterAnnotation String> @ArrayAnnotation [] @ArrayAnnotation []::<@TypeParameterAnnotation String>clone;\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER | CHECK_JAVAC_PARSER , source.toCharArray(), null, "test385374", expectedUnitToString);
+ }
+ /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=385374, Support for 308 style type annotations on 335 constructs - make sure illegal modifiers are rejected
+ This test has been rendered meaningless as the grammar has been so throughly changed - Type annotations are not accepted via modifiers in the first place.
+ Disabling this test as we don't want fragile and unstable tests that are at the whimsy of the diagnose parser's complex algorithms.
+ */
+ public void test385374a() throws IOException {
+ // Nop.
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java
index f07295e..9d90885 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/RunCompletionParserTests.java
@@ -1,9 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
@@ -110,6 +114,17 @@
TestCase.RUN_ONLY_ID = null;
all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_7, tests_1_7));
}
+ if ((possibleComplianceLevels & AbstractCompilerTest.F_1_8) != 0) {
+ ArrayList tests_1_8 = (ArrayList)testClasses.clone();
+ tests_1_8.addAll(TEST_CLASSES_1_5);
+ // Reset forgotten subsets tests
+ TestCase.TESTS_PREFIX = null;
+ TestCase.TESTS_NAMES = null;
+ TestCase.TESTS_NUMBERS= null;
+ TestCase.TESTS_RANGE = null;
+ TestCase.RUN_ONLY_ID = null;
+ all.addTest(AbstractCompilerTest.buildComplianceTestSuite(ClassFileConstants.JDK1_8, tests_1_8));
+ }
return all;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
index e5a9a09..1ca2a31 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Technical University Berlin - adapted for Object Teams
@@ -163,27 +167,27 @@
"} \n";
String expectedSyntaxErrorDiagnosis =
- "----------\n" +
- "1. ERROR in <parenthesis mismatch> (at line 3)\n" +
- " [ arg1, \n" +
- " ^\n" +
- "Syntax error on token \"[\", invalid Type\n" +
- "----------\n" +
- "2. ERROR in <parenthesis mismatch> (at line 4)\n" +
- " { arg2, ] \n" +
- " ^\n" +
- "Syntax error on token \"{\", invalid Type\n" +
- "----------\n" +
- "3. ERROR in <parenthesis mismatch> (at line 4)\n" +
- " { arg2, ] \n" +
- " ^\n" +
- "Syntax error on token \"]\", invalid Type\n" +
- "----------\n" +
- "4. ERROR in <parenthesis mismatch> (at line 5)\n" +
- " arg3, \n" +
- " ^\n" +
- "Syntax error on token \",\", FormalParameter expected after this token\n" +
- "----------\n";
+ "----------\n" +
+ "1. ERROR in <parenthesis mismatch> (at line 3)\n" +
+ " [ arg1, \n" +
+ " ^\n" +
+ "Syntax error on token \"[\", byte expected\n" +
+ "----------\n" +
+ "2. ERROR in <parenthesis mismatch> (at line 4)\n" +
+ " { arg2, ] \n" +
+ " ^\n" +
+ "Syntax error on token \"{\", byte expected\n" +
+ "----------\n" +
+ "3. ERROR in <parenthesis mismatch> (at line 4)\n" +
+ " { arg2, ] \n" +
+ " ^\n" +
+ "Syntax error on token \"]\", byte expected\n" +
+ "----------\n" +
+ "4. ERROR in <parenthesis mismatch> (at line 5)\n" +
+ " arg3, \n" +
+ " ^\n" +
+ "Syntax error on token \",\", FormalParameter expected after this token\n" +
+ "----------\n";
String testName = "<parenthesis mismatch>";
checkParse(
@@ -270,12 +274,12 @@
"} \n";
String expectedSyntaxErrorDiagnosis =
- "----------\n"+
- "1. ERROR in <test> (at line 3)\n"+
- " i; \n"+
- " ^\n"+
- "Syntax error, insert \"AssignmentOperator Expression\" to complete Expression\n"+
- "----------\n";
+ "----------\n" +
+ "1. ERROR in <test> (at line 3)\n" +
+ " i; \n" +
+ " ^\n" +
+ "Syntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration\n" +
+ "----------\n";
String testName = "<test>";
checkParse(
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
index 44d8b3c..61516cf 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, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -44,7 +48,7 @@
super(testName);
}
-public static Test suite() {
+public static TestSuite getTestSuite(boolean addComplianceDiagnoseTest) {
ArrayList testClasses = new ArrayList();
/* completion tests */
@@ -70,7 +74,8 @@
testClasses.add(SyntaxErrorTest.class);
testClasses.add(DualParseSyntaxErrorTest.class);
testClasses.add(ParserTest.class);
- testClasses.add(ComplianceDiagnoseTest.class);
+ if (addComplianceDiagnoseTest)
+ testClasses.add(ComplianceDiagnoseTest.class);
TestSuite all = new TestSuite(TestAll.class.getName());
int possibleComplianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
@@ -128,7 +133,25 @@
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;
}
+public static Test suite() {
+ return getTestSuite(true);
+}
}
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..8be8789
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TypeAnnotationSyntaxTest.java
@@ -0,0 +1,3853 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
+ * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work)
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.parser;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.HashMap;
+import java.util.Map;
+import junit.framework.Test;
+import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.ast.Annotation;
+import org.eclipse.jdt.internal.compiler.ast.Argument;
+import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation;
+import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.NormalAnnotation;
+import org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation;
+import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
+
+public class TypeAnnotationSyntaxTest extends AbstractSyntaxTreeTest {
+
+ private static String jsr308TestScratchArea = "c:\\Jsr308TestScratchArea";
+ private static String referenceCompiler = "C:\\jdk-7-ea-bin-b75-windows-i586-30_oct_2009\\jdk7\\bin\\javac.exe";
+
+ static {
+// TESTS_NAMES = new String [] { "test0137" };
+ }
+ public static Class testClass() {
+ return TypeAnnotationSyntaxTest.class;
+ }
+ public void initialize(CompilerTestSetup setUp) {
+ super.initialize(setUp);
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+ }
+
+ static final class LocationPrinterVisitor extends ASTVisitor {
+ Annotation[] primaryAnnotations;
+ TypeReference enclosingReference;
+ Map locations;
+
+ public LocationPrinterVisitor() {
+ this.locations = new HashMap();
+ }
+
+ public Map getLocations() {
+ return this.locations;
+ }
+ public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
+ Annotation[] annotations = fieldDeclaration.annotations;
+ this.enclosingReference = fieldDeclaration.type;
+ this.primaryAnnotations = annotations;
+ return true;
+ }
+ public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
+ this.primaryAnnotations = methodDeclaration.annotations;
+ TypeReference returnType = methodDeclaration.returnType;
+ if (returnType != null) {
+ this.enclosingReference = returnType;
+ returnType.traverse(this, scope);
+ }
+ if (methodDeclaration.thrownExceptions != null) {
+ int thrownExceptionsLength = methodDeclaration.thrownExceptions.length;
+ for (int i = 0; i < thrownExceptionsLength; i++) {
+ TypeReference typeReference = methodDeclaration.thrownExceptions[i];
+ this.enclosingReference = typeReference;
+ this.primaryAnnotations = null;
+ typeReference.traverse(this, scope);
+ }
+ }
+ return false;
+ }
+ public boolean visit(Argument argument, ClassScope scope) {
+ Annotation[] annotations = argument.annotations;
+ this.enclosingReference = argument.type;
+ this.primaryAnnotations = annotations;
+ return true;
+ }
+ public boolean visit(Argument argument, BlockScope scope) {
+ Annotation[] annotations = argument.annotations;
+ this.enclosingReference = argument.type;
+ this.primaryAnnotations = annotations;
+ return true;
+ }
+ public boolean visit(MarkerAnnotation annotation, BlockScope scope) {
+ if (this.enclosingReference != null) {
+ storeLocations(annotation, Annotation.getLocations(this.enclosingReference, this.primaryAnnotations, annotation, null, 0));
+ }
+ return false;
+ }
+ public boolean visit(SingleMemberAnnotation annotation, BlockScope scope) {
+ if (this.enclosingReference != null) {
+ storeLocations(annotation, Annotation.getLocations(this.enclosingReference, this.primaryAnnotations, annotation, null, 0));
+ }
+ return false;
+ }
+ public boolean visit(NormalAnnotation annotation, BlockScope scope) {
+ if (this.enclosingReference != null) {
+ storeLocations(annotation, Annotation.getLocations(this.enclosingReference, this.primaryAnnotations, annotation, null, 0));
+ }
+ 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 += 2) {
+ if (i > 0) {
+ buffer.append(", ");
+ }
+ switch (tab[i]) {
+ case 0:
+ buffer.append("ARRAY");
+ break;
+ case 1:
+ buffer.append("INNER_TYPE");
+ break;
+ case 2:
+ buffer.append("WILDCARD");
+ break;
+ case 3:
+ buffer.append("TYPE_ARGUMENT(").append(tab[i+1]).append(')');
+ break;
+ }
+ }
+ buffer.append(']');
+ this.locations.put(key, String.valueOf(buffer));
+ }
+
+ public boolean visit(ArrayTypeReference arrayReference, BlockScope scope) {
+ if (this.enclosingReference == null) return false;
+ return true;
+ }
+ public boolean visit(ParameterizedSingleTypeReference typeReference, BlockScope scope) {
+ if (this.enclosingReference == null) return false;
+ return true;
+ }
+ public boolean visit(SingleTypeReference typeReference, BlockScope scope) {
+ if (this.enclosingReference == null) return false;
+ return true;
+ }
+ }
+public TypeAnnotationSyntaxTest(String testName){
+ super(testName, referenceCompiler, jsr308TestScratchArea);
+ if (referenceCompiler != null) {
+ File f = new File(jsr308TestScratchArea);
+ if (!f.exists()) {
+ f.mkdir();
+ }
+ if (f.exists()) {
+ try {
+ OutputStreamWriter w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "Marker.java")));
+ w.write("@interface Marker {}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "Normal.java")));
+ w.write("@interface Normal {\n\tint value() default 10;\n}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "SingleMember.java")));
+ w.write("@interface SingleMember {\n\tint value() default 10;\n}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "Positive.java")));
+ w.write("@interface Positive {}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "Negative.java")));
+ w.write("@interface Negative{}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "Readonly.java")));
+ w.write("@interface Readonly {}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "NonNull.java")));
+ w.write("@interface NonNull {}\n".toCharArray());
+ w.close();
+ w = new OutputStreamWriter(new FileOutputStream(new File(jsr308TestScratchArea + File.separator + "HashMap.java")));
+ w.write("class HashMap<X,Y> {\n class Iterator {}; \n}\n".toCharArray());
+ w.close();
+ CHECK_ALL |= CHECK_JAVAC_PARSER;
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+}
+
+static {
+// TESTS_NAMES = new String[] { "test0038", "test0039", "test0040a" };
+// TESTS_NUMBERS = new int[] { 133, 134, 135 };
+ if (!(new File(referenceCompiler).exists())) {
+ referenceCompiler = null;
+ jsr308TestScratchArea = null;
+ }
+}
+void traverse (File f) throws IOException {
+ if (f.isDirectory()) {
+ File [] files = f.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ traverse(files[i]);
+ }
+ } else {
+ if (f.getName().endsWith(".java")) {
+ System.out.println(f.getCanonicalPath());
+ char [] contents = new char[(int) f.length()];
+ FileInputStream fs = new FileInputStream(f);
+ InputStreamReader isr = new InputStreamReader(fs);
+ isr.read(contents);
+ checkParse(contents, null, f.getCanonicalPath(), null);
+ }
+ }
+}
+public void _test000() throws IOException {
+ traverse(new File("C:\\jsr308tests"));
+}
+
+public void test0001() throws IOException {
+ String source = "@Marker class A extends String {}\n;" +
+ "@Marker class B extends @Marker String {}\n" +
+ "@Marker class C extends @Marker @SingleMember(0) String {}\n" +
+ "@Marker class D extends @Marker @SingleMember(0) @Normal(Value = 0) String {}\n" +
+ "@Marker class E extends String {}\n;";
+
+ String expectedUnitToString =
+ "@Marker class A extends String {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class B extends @Marker String {\n" +
+ " B() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class C extends @Marker @SingleMember(0) String {\n" +
+ " C() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class D extends @Marker @SingleMember(0) @Normal(Value = 0) String {\n" +
+ " D() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class E extends String {\n" +
+ " E() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER , source.toCharArray(), null, "test0001", expectedUnitToString);
+}
+public void test0002() throws IOException {
+ String source = "class A extends String {}\n;" +
+ "class B extends @Marker String {}\n" +
+ "class C extends @Marker @SingleMember(0) String {}\n" +
+ "class D extends @Marker @SingleMember(0) @Normal(Value = 0) String {}\n" +
+ "class E extends String {}\n;";
+
+ String expectedUnitToString =
+ "class A extends String {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class B extends @Marker String {\n" +
+ " B() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class C extends @Marker @SingleMember(0) String {\n" +
+ " C() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class D extends @Marker @SingleMember(0) @Normal(Value = 0) String {\n" +
+ " D() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class E extends String {\n" +
+ " E() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0002", expectedUnitToString);
+}
+public void test0003() throws IOException {
+ String source = "@Marker class A implements Comparable, " +
+ " @Marker Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A implements Comparable, @Marker Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0003", expectedUnitToString);
+}
+public void test0004() throws IOException {
+ String source = "@Marker class A implements Comparable, " +
+ " @Marker @SingleMember(0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A implements Comparable, @Marker @SingleMember(0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0004", expectedUnitToString);
+}
+public void test0005() throws IOException {
+ String source = "@Marker class A implements Comparable, " +
+ " @Marker @SingleMember(0) @Normal(Value=0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A implements Comparable, @Marker @SingleMember(0) @Normal(Value = 0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0005", expectedUnitToString);
+}
+public void test0006() throws IOException {
+ String source = "@Marker class A implements @Marker Comparable, " +
+ " @Marker @SingleMember(0) @Normal(Value=0) Serializable," +
+ " @Marker Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A implements @Marker Comparable, @Marker @SingleMember(0) @Normal(Value = 0) Serializable, @Marker Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0006", expectedUnitToString);
+}
+public void test007() throws IOException {
+ String source = "@Marker class A extends Object implements Comparable, " +
+ " @Marker @SingleMember(10) @Normal(Value=0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A extends Object implements Comparable, @Marker @SingleMember(10) @Normal(Value = 0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0007", expectedUnitToString);
+}
+public void test0008() throws IOException {
+ String source = "@Marker class A extends @Marker Object implements Comparable, " +
+ " @Marker @SingleMember(0) @Normal(Value=0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A extends @Marker Object implements Comparable, @Marker @SingleMember(0) @Normal(Value = 0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0008", expectedUnitToString);
+}
+public void test0009() throws IOException {
+ String source = "@Marker class A extends @Marker @SingleMember(0) Object implements Comparable, " +
+ " @Marker @SingleMember(0) @Normal(Value=0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A extends @Marker @SingleMember(0) Object implements Comparable, @Marker @SingleMember(0) @Normal(Value = 0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0009", expectedUnitToString);
+}
+public void test0010() throws IOException {
+ String source = "@Marker class A extends @Marker @SingleMember(0) @Normal(Value=0) Object implements Comparable, " +
+ " @Marker @SingleMember(0) @Normal(Value=0) Serializable," +
+ " Cloneable {\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class A extends @Marker @SingleMember(0) @Normal(Value = 0) Object implements Comparable, @Marker @SingleMember(0) @Normal(Value = 0) Serializable, Cloneable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0010", expectedUnitToString);
+}
+public void test0011() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker String[] @Marker[][] s[] @SingleMember(0)[][] @Normal(Value = 0)[][];\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker String[] @Marker [][][] @SingleMember(0) [][] @Normal(Value = 0) [][] s;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0011", expectedUnitToString);
+}
+public void test0012() throws IOException {
+ String source = "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[] f[];\n" +
+ " @English String[] @NonNull[] s[] @Nullable[][];\n" +
+ " float[] p[];\n" +
+ "public static void main(String args[]) {\n" +
+ " @Readonly String @Nullable[] @NonNull[] s;\n" +
+ " s = new @Readonly String @NonNull[5] @Nullable[];\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[][] f;\n" +
+ " @English String[] @NonNull [][] @Nullable [][] s;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " @Readonly String @Nullable [] @NonNull [] s;\n" +
+ " s = new @Readonly String @NonNull [5] @Nullable [];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0012", expectedUnitToString);
+}
+public void test0013() throws IOException {
+ String source = "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[] f[];\n" +
+ " @English String[] @NonNull[] s[] @Nullable[][];\n" +
+ " float[] p[];\n" +
+ "public static void main(String args[]) {\n" +
+ " @Readonly String s;\n" +
+ " s = new @Readonly String @NonNull[] @Nullable[] { {\"Hello\"}, {\"World\"}} [0][0];\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[][] f;\n" +
+ " @English String[] @NonNull [][] @Nullable [][] s;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " @Readonly String s;\n" +
+ " s = new @Readonly String @NonNull [] @Nullable []{{\"Hello\"}, {\"World\"}}[0][0];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0013", expectedUnitToString);
+}
+public void test0014() throws IOException {
+ String source = "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[] f[];\n" +
+ " @English String[] @NonNull[] s[] @Nullable[][];\n" +
+ " float[] p[];\n" +
+ "public static int main(String args[])[] @Marker[][] @Marker @SingleMember(0) @Normal(Value=0)[][] {\n" +
+ " @Readonly String @Nullable[] @NonNull[] s;\n" +
+ " s = new @Readonly String @NonNull[5] @Nullable[];\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[][] f;\n" +
+ " @English String[] @NonNull [][] @Nullable [][] s;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static int[] @Marker [][] @Marker @SingleMember(0) @Normal(Value = 0) [][] main(String[] args) {\n" +
+ " @Readonly String @Nullable [] @NonNull [] s;\n" +
+ " s = new @Readonly String @NonNull [5] @Nullable [];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0014", expectedUnitToString);
+
+}
+public void test0015() throws IOException {
+ String source = "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[] f[];\n" +
+ " @English String[] @NonNull[] s[] @Nullable[][];\n" +
+ " float[] p[];\n" +
+ "public static int main(String args[])[] @Marker[][] @Marker @SingleMember(0) @Normal(Value=0)[][] {\n" +
+ " @Readonly String @Nullable[] @NonNull[] s;\n" +
+ " s = new @Readonly String @NonNull[5] @Nullable[];\n" +
+ "}\n" +
+ "@Marker public A () {}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " int[][] f;\n" +
+ " @English String[] @NonNull [][] @Nullable [][] s;\n" +
+ " float[][] p;\n" +
+ " public static int[] @Marker [][] @Marker @SingleMember(0) @Normal(Value = 0) [][] main(String[] args) {\n" +
+ " @Readonly String @Nullable [] @NonNull [] s;\n" +
+ " s = new @Readonly String @NonNull [5] @Nullable [];\n" +
+ " }\n" +
+ " public @Marker A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0015", expectedUnitToString);
+}
+// parameters
+public void test0016() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(int[] @SingleMember(10)[][] args[] @Normal(Value = 10)[][])[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(int[] @SingleMember(10) [][][] @Normal(Value = 10) [][] args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0016", expectedUnitToString);
+}
+public void test0017() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(String[] @SingleMember(10)[][] args[] @Normal(Value = 10)[][])[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(String[] @SingleMember(10) [][][] @Normal(Value = 10) [][] args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0017", expectedUnitToString);
+}
+public void test0018() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(HashMap<String, Object>[] @SingleMember(10)[][] args[] @Normal(Value = 10)[][])[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(HashMap<String, Object>[] @SingleMember(10) [][][] @Normal(Value = 10) [][] args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0018", expectedUnitToString);
+}
+public void test0019() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker [][] main(HashMap<String, Object>.Iterator[] @SingleMember(10) [][] args[] @Normal(Value = 10) [][])[] @Marker [][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(HashMap<String, Object>.Iterator[] @SingleMember(10) [][][] @Normal(Value = 10) [][] args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0019", expectedUnitToString);
+}
+// varargs annotation
+public void test0020() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(int[] @SingleMember(10)[][] @Marker ... args )[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(int[] @SingleMember(10) [][] @Marker ... args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0020", expectedUnitToString);
+}
+public void test0021() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(String[] @SingleMember(10)[][] @Marker ... args )[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(String[] @SingleMember(10) [][] @Marker ... args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0021", expectedUnitToString);
+}
+public void test0022() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(HashMap<Integer,String>[] @SingleMember(10)[][] @Marker ... args )[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(HashMap<Integer, String>[] @SingleMember(10) [][] @Marker ... args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0022", expectedUnitToString);
+}
+public void test0023() throws IOException {
+ String source = "public class A {\n" +
+ "@Marker public int[] @Marker[][] main(HashMap<Integer,String>.Iterator[] @SingleMember(10)[][] @Marker ... args )[] @Marker[][] {\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @Marker [][][] @Marker [][] main(HashMap<Integer, String>.Iterator[] @SingleMember(10) [][] @Marker ... args) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0023", expectedUnitToString);
+}
+// local variables
+public void test0024() throws IOException {
+ String source = "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ "public static void main(String args[]) {\n" +
+ " int[] f[];\n" +
+ " @English String[] @NonNull[] s[] @Nullable[][];\n" +
+ " float[] p[];\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A implements @Readonly Comparable, @NonNull Serializable, Cloneable {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " int[][] f;\n" +
+ " @English String[] @NonNull [][] @Nullable [][] s;\n" +
+ " float[][] p;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0024", expectedUnitToString);
+}
+// type parameter
+public void test0025() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> void foo() {\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer>void foo() {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0025", expectedUnitToString);
+}
+// Type
+public void test0026() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker int foo() {\n" +
+ " return 0;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> int bar() {\n" +
+ " return 0;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0026 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker int foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0026", null);
+}
+// Type
+public void test0027() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker String foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> String bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0027 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker String foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0027", null);
+}
+//Type
+public void test0028() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object> foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> HashMap<String, @NonNull Object> bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0028 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object> foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0028", null);
+}
+// Type
+public void test0029() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> HashMap<String, @NonNull Object>.Iterator bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0029 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0029", null);
+}
+//Type
+public void test0030() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator[] @NonEmpty[][] foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> HashMap<String, @NonNull Object>.Iterator[] @NonEmpty[][] bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0030 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>.Iterator[] @NonEmpty[][] foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0030", null);
+}
+//Type
+public void test0031() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker int[] @NonEmpty[][] foo() {\n" +
+ " return 0;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> int[] @NonEmpty[][] bar() {\n" +
+ " return 0;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0031 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker int[] @NonEmpty[][] foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0031", null);
+}
+// Type
+public void test0032() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker String[]@NonEmpty[][] foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> String[]@NonEmpty[][] bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0032 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker String[]@NonEmpty[][] foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0032", null);
+}
+//Type
+public void test0033() throws IOException {
+ String source = "class A {\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>[] @NonEmpty[][] foo() {\n" +
+ " return null;\n" +
+ "}\n" +
+ "public <Integer, @Positive Integer, @Negative Integer, Integer> HashMap<String, @NonNull Object>[]@NonEmpty[][] bar () {\n" +
+ " return null;\n" +
+ "}\n" +
+ "}\n";
+ String expectedError =
+ "----------\n" +
+ "1. ERROR in test0033 (at line 2)\n" +
+ " public <Integer, @Positive Integer, @Negative Integer, Integer> @Marker HashMap<@Readonly String, Object>[] @NonEmpty[][] foo() {\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), expectedError, "test0033", null);
+}
+// Type0 field declaration.
+public void test0034() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker int k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker int k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0034", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0035() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker String k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker String k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0035", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0036() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer> k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer> k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0036", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0037() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0037", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0038() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker int[] @NonEmpty[][] k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker int[] @NonEmpty [][] k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0038", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0039() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker String[] @NonEmpty[][]k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker String[] @NonEmpty [][] k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0039", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0040() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>[] @NonEmpty[][] k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>[] @NonEmpty [][] k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0040", expectedUnitToString);
+}
+//Type0 field declaration.
+public void test0041() throws IOException {
+ String source = "public class A {\n" +
+ " int[] f[];\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty[][] k;\n" +
+ " float[] p[];\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " int[][] f;\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty [][] k;\n" +
+ " float[][] p;\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0041", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0042() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker int foo() { return 0; }\n" +
+ " public int bar() { return 0; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int foo() {\n" +
+ " return 0;\n" +
+ " }\n" +
+ " public int bar() {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0042", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0043() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker String foo() { return null; }\n" +
+ " public String bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker String foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public String bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0043", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0044() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer> foo() { return null; }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer> bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer> foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer> bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0044", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0045() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator foo() { return null; }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer>.Iterator bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer>.Iterator bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0045", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0046() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker int[] foo() @NonEmpty[][] { return 0; }\n" +
+ " public int[] @NonEmpty[][] bar() { return 0; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker int[] @NonEmpty [][] foo() {\n" +
+ " return 0;\n" +
+ " }\n" +
+ " public int[] @NonEmpty [][] bar() {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0046", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0047() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker String[] foo() @NonEmpty[][] { return null; }\n" +
+ " public String[] @NonEmpty[][] bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker String[] @NonEmpty [][] foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public String[] @NonEmpty [][] bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0047", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0048() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>[] foo() @NonEmpty[][] { return null; }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer> [] @NonEmpty[][] bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>[] @NonEmpty [][] foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer>[] @NonEmpty [][] bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0048", expectedUnitToString);
+}
+//Type0 MethodHeaderName.
+public void test0049() throws IOException {
+ String source = "public class A {\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] foo() @NonEmpty[][] { return null; }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty[][] bar() { return null; }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty [][] foo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty [][] bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0049", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0050() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker int p;\n" +
+ " int q;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker int p;\n" +
+ " int q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0050", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0051() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker String p;\n" +
+ " String q;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker String p;\n" +
+ " String q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0051", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0052() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer> p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer> q;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer> p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer> q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0052", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0053() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer>.Iterator q;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer>.Iterator q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0053", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0054() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker int[] @NonNull[] p @NonEmpty[][];\n" +
+ " int[] @NonNull[] q @NonEmpty[][];\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker int[] @NonNull [] @NonEmpty [][] p;\n" +
+ " int[] @NonNull [] @NonEmpty [][] q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0054", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0055() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker String[] @NonNull[] p @NonEmpty[][];\n" +
+ " String[] @NonNull[] q @NonEmpty[][];\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker String[] @NonNull [] @NonEmpty [][] p;\n" +
+ " String[] @NonNull [] @NonEmpty [][] q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0055", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0056() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>[] @NonNull[] p @NonEmpty[][];\n" +
+ " HashMap<@Positive Integer, @Negative Integer>[] @NonNull[] q @NonEmpty[][];\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>[] @NonNull [] @NonEmpty [][] p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer>[] @NonNull [] @NonEmpty [][] q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0056", expectedUnitToString);
+}
+//Type0 local variable declaration
+public void test0057() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonNull[] p @NonEmpty[][];\n" +
+ " HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonNull[] @NonEmpty[][] q;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " @Marker HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonNull [] @NonEmpty [][] p;\n" +
+ " HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonNull [] @NonEmpty [][] q;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0057", expectedUnitToString);
+}
+//Type0 foreach
+public void test0058() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " String @NonNull[] @Marker[] s @Readonly[];\n" +
+ " for (@Readonly String @NonNull[] si @Marker[] : s) {}\n" +
+ " for (String @NonNull[] sii @Marker[] : s) {}\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " String @NonNull [] @Marker [] @Readonly [] s;\n" +
+ " for (@Readonly String @NonNull [] @Marker [] si : s) \n" +
+ " {\n" +
+ " }\n" +
+ " for (String @NonNull [] @Marker [] sii : s) \n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0058", expectedUnitToString);
+}
+//Type0 foreach
+public void test0059() throws IOException {
+ String source = "public class A {\n" +
+ " public void foo() {\n" +
+ " int @NonNull[] @Marker[] s @Readonly[];\n" +
+ " for (@Readonly int @NonNull[] si @Marker[] : s) {}\n" +
+ " for (int @NonNull[] sii @Marker[] : s) {}\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class A {\n" +
+ " public A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " int @NonNull [] @Marker [] @Readonly [] s;\n" +
+ " for (@Readonly int @NonNull [] @Marker [] si : s) \n" +
+ " {\n" +
+ " }\n" +
+ " for (int @NonNull [] @Marker [] sii : s) \n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0059", expectedUnitToString);
+}
+// cast expression
+public void test0060() throws IOException {
+ String source = "public class Clazz {\n" +
+ "public static void main(String[] args) {\n" +
+ "int x;\n" +
+ "x = (Integer)\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @Normal(Value=0)[][] )\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @SingleMember(0)[][] )\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @Marker[][] )\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>[] @Normal(Value=0)[][] )\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>[] @SingleMember(0)[][] )\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>[] @Marker[][] )\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly String[] @Normal(Value=0)[][] )\n" +
+ "(@Readonly String[] @SingleMember(0)[][] )\n" +
+ "(@Readonly String[] @Marker[][] )\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly int[] @Normal(Value=0)[][] )\n" +
+ "(@Readonly int[] @SingleMember(0)[][] )\n" +
+ "(@Readonly int[] @Marker[][] )\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator)\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, @Negative Integer>)\n" +
+ "(@Readonly Object)\n" +
+ "(@ReadOnly String)\n" +
+ "(@Readonly Object)\n" +
+ "(@Readonly int) 10;\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class Clazz {\n" +
+ " public Clazz() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " int x;\n" +
+ " x = (Integer) (@Readonly Object) (@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @Normal(Value = 0) [][]) (@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @SingleMember(0) [][]) (@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @Marker [][]) (@Readonly Object) (@Readonly HashMap<@Positive Integer, @Negative Integer>[] @Normal(Value = 0) [][]) (@Readonly HashMap<@Positive Integer, @Negative Integer>[] @SingleMember(0) [][]) (@Readonly HashMap<@Positive Integer, @Negative Integer>[] @Marker [][]) (@Readonly Object) (@Readonly String[] @Normal(Value = 0) [][]) (@Readonly String[] @SingleMember(0) [][]) (@Readonly String[] @Marker [][]) (@Readonly Object) (@Readonly int[] @Normal(Value = 0) [][]) (@Readonly int[] @SingleMember(0) [][]) (@Readonly int[] @Marker [][]) (@Readonly Object) (@Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator) (@Readonly Object) (@Readonly HashMap<@Positive Integer, @Negative Integer>) (@Readonly Object) (@ReadOnly String) (@Readonly Object) (@Readonly int) 10;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0060", expectedUnitToString);
+}
+//cast expression
+public void test0061() throws IOException {
+ String source = "public class Clazz {\n" +
+ "public static void main(String[] args) {\n" +
+ "int x;\n" +
+ "x = (Integer)\n" +
+ "(Object)\n" +
+ "(@Readonly HashMap<Integer, @Negative Integer>.Iterator[] @Normal(Value=0)[][] )\n" +
+ "(HashMap<@Positive Integer, Integer>.Iterator[] @SingleMember(0)[][] )\n" +
+ "(@Readonly HashMap<Integer, @Negative Integer>.Iterator[] @Marker[][] )\n" +
+ "(Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, Integer>[] @Normal(Value=0)[][] )\n" +
+ "(HashMap<Integer, @Negative Integer>[] @SingleMember(0)[][] )\n" +
+ "(@Readonly HashMap<@Positive Integer, Integer>[] @Marker[][] )\n" +
+ "(Object)\n" +
+ "(@Readonly String[] @Normal(Value=0)[][] )\n" +
+ "(String[] @SingleMember(0)[][] )\n" +
+ "(@Readonly String[] @Marker[][] )\n" +
+ "(Object)\n" +
+ "(@Readonly int[] @Normal(Value=0)[][] )\n" +
+ "(int[] @SingleMember(0)[][] )\n" +
+ "(@Readonly int[] @Marker[][] )\n" +
+ "(Object)\n" +
+ "(@Readonly HashMap<Integer, @Negative Integer>.Iterator)\n" +
+ "(Object)\n" +
+ "(@Readonly HashMap<@Positive Integer, Integer>)\n" +
+ "(Object)\n" +
+ "(@ReadOnly String)\n" +
+ "(Object)\n" +
+ "(@Readonly int) 10;\n" +
+ "}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class Clazz {\n" +
+ " public Clazz() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " int x;\n" +
+ " x = (Integer) (Object) (@Readonly HashMap<Integer, @Negative Integer>.Iterator[] @Normal(Value = 0) [][]) (HashMap<@Positive Integer, Integer>.Iterator[] @SingleMember(0) [][]) (@Readonly HashMap<Integer, @Negative Integer>.Iterator[] @Marker [][]) (Object) (@Readonly HashMap<@Positive Integer, Integer>[] @Normal(Value = 0) [][]) (HashMap<Integer, @Negative Integer>[] @SingleMember(0) [][]) (@Readonly HashMap<@Positive Integer, Integer>[] @Marker [][]) (Object) (@Readonly String[] @Normal(Value = 0) [][]) (String[] @SingleMember(0) [][]) (@Readonly String[] @Marker [][]) (Object) (@Readonly int[] @Normal(Value = 0) [][]) (int[] @SingleMember(0) [][]) (@Readonly int[] @Marker [][]) (Object) (@Readonly HashMap<Integer, @Negative Integer>.Iterator) (Object) (@Readonly HashMap<@Positive Integer, Integer>) (Object) (@ReadOnly String) (Object) (@Readonly int) 10;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0061", expectedUnitToString);
+}
+// instanceof checks
+public void test0062() throws IOException {
+ String source = "public class Clazz {\n" +
+ "public static void main(Object o) {\n" +
+ "if (o instanceof @Readonly String) {\n" +
+ "} else if (o instanceof @Readonly int[] @NonEmpty[][] ) {\n" +
+ "} else if (o instanceof @Readonly String[] @NonEmpty[][] ) {\n" +
+ "} else if (o instanceof @Readonly HashMap<?,?>[] @NonEmpty[][] ) {\n" +
+ "} else if (o instanceof @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty[][] ) {\n" +
+ "} else if (o instanceof @Readonly HashMap<?,?>) {\n" +
+ "} else if (o instanceof @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator) {\n" +
+ "}\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class Clazz {\n" +
+ " public Clazz() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(Object o) {\n" +
+ " if ((o instanceof @Readonly String))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly int[] @NonEmpty [][]))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly String[] @NonEmpty [][]))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly HashMap<?, ?>[] @NonEmpty [][]))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator[] @NonEmpty [][]))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly HashMap<?, ?>))\n" +
+ " {\n" +
+ " }\n" +
+ " else\n" +
+ " if ((o instanceof @Readonly HashMap<@Positive Integer, @Negative Integer>.Iterator))\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0062", expectedUnitToString);
+}
+// assorted unclassified
+public void test0063() throws IOException {
+ String source = "import java.util.HashMap;\n" +
+ "import java.util.Map; \n" +
+ "\n" +
+ "public class Clazz <@A M extends @B String, @C N extends @D Comparable> extends\n" +
+ " @E Object implements @F Comparable <@G Object> {\n" +
+ " \n" +
+ " Clazz(char[] ...args) { \n" +
+ " }\n" +
+ " \n" +
+ " int @I[] f @J[], g, h[], i@K[];\n" +
+ " int @L[][]@M[] f2; \n" +
+ " \n" +
+ " Clazz (int @N[] @O... a) {}\n" +
+ " int @R[]@S[] aa() {}\n" +
+ " \n" +
+ " int @T[]@U[]@V[] a () @W[]@X[]@Y[] { return null; }\n" +
+ " \n" +
+ " public void main(String @A[] @B ... args) throws @D Exception {\n" +
+ " \n" +
+ " HashMap<@E String, @F String> b1;\n" +
+ " \n" +
+ " int b; b = (@G int) 10;\n" +
+ " \n" +
+ " char @H[]@I[] ch; ch = (@K char @L[]@M[])(@N char @O[]@P[]) null;\n" +
+ " \n" +
+ " int[] i; i = new @Q int @R[10];\n" +
+ " \n" +
+ " \n" +
+ " Integer w; w = new X<@S String, @T Integer>().get(new @U Integer(12));\n" +
+ " throw new @V Exception(\"test\");\n" +
+ " boolean c; c = null instanceof @W String;\n" +
+ " } \n" +
+ " public <@X X, @Y Y> void foo(X x, Y @Z... y) { \n" +
+ " \n" +
+ "}\n" +
+ " \n" +
+ " void foo(Map<? super @A Object, ? extends @B String> m){}\n" +
+ " public int compareTo(Object arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "\n" +
+ "}\n" +
+ "class X<@C K, @D T extends @E Object & @F Comparable<? super @G T>> {\n" +
+ " \n" +
+ " public Integer get(Integer integer) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+
+
+ String expectedUnitToString = "import java.util.HashMap;\n" +
+ "import java.util.Map;\n" +
+ "public class Clazz<@A M extends @B String, @C N extends @D Comparable> extends @E Object implements @F Comparable<@G Object> {\n" +
+ " int @I [] @J [] f;\n" +
+ " int @I [] g;\n" +
+ " int @I [][] h;\n" +
+ " int @I [] @K [] i;\n" +
+ " int @L [][] @M [] f2;\n" +
+ " Clazz(char[]... args) {\n" +
+ " super();\n" +
+ " }\n" +
+ " Clazz(int @N [] @O ... a) {\n" +
+ " super();\n" +
+ " }\n" +
+ " int @R [] @S [] aa() {\n" +
+ " }\n" +
+ " int @T [] @U [] @V [] @W [] @X [] @Y [] a() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public void main(String @A [] @B ... args) throws @D Exception {\n" +
+ " HashMap<@E String, @F String> b1;\n" +
+ " int b;\n" +
+ " b = (@G int) 10;\n" +
+ " char @H [] @I [] ch;\n" +
+ " ch = (@K char @L [] @M []) (@N char @O [] @P []) null;\n" +
+ " int[] i;\n" +
+ " i = new @Q int @R [10];\n" +
+ " Integer w;\n" +
+ " w = new X<@S String, @T Integer>().get(new @U Integer(12));\n" +
+ " throw new @V Exception(\"test\");\n" +
+ " boolean c;\n" +
+ " c = (null instanceof @W String);\n" +
+ " }\n" +
+ " public <@X X, @Y Y>void foo(X x, Y @Z ... y) {\n" +
+ " }\n" +
+ " void foo(Map<? super @A Object, ? extends @B String> m) {\n" +
+ " }\n" +
+ " public int compareTo(Object arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n" +
+ "class X<@C K, @D T extends @E Object & @F Comparable<? super @G T>> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public Integer get(Integer integer) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ // indexing parser avoids creating lots of nodes, so parse tree comes out incorrectly.
+ // this is not bug, but intended behavior - see IndexingParser.newSingleNameReference(char[], long)
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0063", expectedUnitToString);
+}
+//assorted unclassified
+public void test0064() throws IOException {
+ String source = "class X<T extends @E Object & @F Comparable<? super T>> {}\n";
+ String expectedUnitToString = "class X<T extends @E Object & @F Comparable<? super T>> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ // indexing parser avoids creating lots of nodes, so parse tree comes out incorrectly.
+ // this is not bug, but intended behavior - see IndexingParser.newSingleNameReference(char[], long)
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test064", expectedUnitToString);
+}
+//type class literal expression
+public void test0066() throws IOException {
+ String source = "public class X {\n" +
+ " <T extends Y<@A String @C[][]@B[]> & Cloneable> void foo(T t) {}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " <T extends Y<@A String @C [][] @B []> & Cloneable>void foo(T t) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0066", expectedUnitToString);
+}
+//check locations
+public void test0067() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @H String @E[] @F[] @G[] field;\n" +
+ " @A Map<@B String, @C List<@D Object>> field2;\n" +
+ " @A Map<@B String, @H String @E[] @F[] @G[]> field3;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @H String @E [] @F [] @G [] field;\n" +
+ " @A Map<@B String, @C List<@D Object>> field2;\n" +
+ " @A Map<@B String, @H String @E [] @F [] @G []> field3;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0067", expectedUnitToString);
+}
+//check locations
+public void test0068() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @H String @E[] @F[] @G[] field;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @H String @E [] @F [] @G [] field;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ LocationPrinterVisitor visitor = new LocationPrinterVisitor();
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0068", expectedUnitToString, visitor);
+ Map locations = visitor.getLocations();
+ assertEquals("Wrong size", 4, locations.size());
+ assertEquals("Wrong location", null, locations.get("@E"));
+ assertEquals("Wrong location", "[ARRAY]", locations.get("@F"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY]", locations.get("@G"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY]", 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", "[TYPE_ARGUMENT(0)]", locations.get("@B"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(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", "[TYPE_ARGUMENT(0)]", locations.get("@B"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1)]", locations.get("@E"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), ARRAY]", locations.get("@F"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), ARRAY, ARRAY]", locations.get("@G"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), ARRAY, ARRAY, ARRAY]", 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", "[TYPE_ARGUMENT(0)]", locations.get("@B"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1)]", locations.get("@C"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), TYPE_ARGUMENT(0), ARRAY, ARRAY, ARRAY]", locations.get("@H"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), TYPE_ARGUMENT(0)]", locations.get("@E"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), TYPE_ARGUMENT(0), ARRAY, ARRAY]", 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", "[ARRAY]", locations.get("@I"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY]", locations.get("@J"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY]", locations.get("@A"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(0)]", locations.get("@B"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(1)]", locations.get("@C"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(1), TYPE_ARGUMENT(0), ARRAY, ARRAY, ARRAY]", locations.get("@H"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(1), TYPE_ARGUMENT(0)]", locations.get("@E"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(1), TYPE_ARGUMENT(0), ARRAY, ARRAY]", 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", "[ARRAY, ARRAY]", locations.get("@J"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY]", locations.get("@A"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(0)]", locations.get("@B"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(1)]", locations.get("@C"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(1), TYPE_ARGUMENT(0), ARRAY, ARRAY, ARRAY]", locations.get("@H"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(1), TYPE_ARGUMENT(0)]", locations.get("@E"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(1), TYPE_ARGUMENT(0), ARRAY, ARRAY]", 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", "[ARRAY]", locations.get("@F"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY]", locations.get("@J"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY]", locations.get("@A"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(0)]", locations.get("@C"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(0), TYPE_ARGUMENT(0)]", locations.get("@E"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(0), TYPE_ARGUMENT(0), ARRAY, ARRAY]", locations.get("@G"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(0), TYPE_ARGUMENT(0), ARRAY, ARRAY, ARRAY]", locations.get("@H"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(1), ARRAY]", locations.get("@D"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(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", "[ARRAY]", locations.get("@I"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY]", locations.get("@F"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY]", locations.get("@J"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, ARRAY]", locations.get("@A"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(0)]", locations.get("@C"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(0), TYPE_ARGUMENT(0)]", locations.get("@E"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(0), TYPE_ARGUMENT(0), ARRAY, ARRAY]", locations.get("@G"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(0), TYPE_ARGUMENT(0), ARRAY, ARRAY, ARRAY]", locations.get("@H"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(1)]", locations.get("@B"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY, ARRAY, TYPE_ARGUMENT(1), TYPE_ARGUMENT(0), ARRAY]", 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", "[TYPE_ARGUMENT(0)]", locations.get("@B"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1)]", locations.get("@C"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), TYPE_ARGUMENT(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", "[ARRAY]", locations.get("@F"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY]", locations.get("@G"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY]", 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", "[TYPE_ARGUMENT(0)]", locations.get("@B"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(0), TYPE_ARGUMENT(0), ARRAY, ARRAY, ARRAY]", locations.get("@C"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(0), TYPE_ARGUMENT(0)]", locations.get("@D"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(0), TYPE_ARGUMENT(0), ARRAY]", locations.get("@E"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(0), TYPE_ARGUMENT(0), ARRAY, ARRAY]", locations.get("@F"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1)]", locations.get("@G"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), TYPE_ARGUMENT(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", "[TYPE_ARGUMENT(0)]", locations.get("@B"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(0), TYPE_ARGUMENT(0), ARRAY, ARRAY, ARRAY]", locations.get("@C"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(0), TYPE_ARGUMENT(0)]", locations.get("@D"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(0), TYPE_ARGUMENT(0), ARRAY]", locations.get("@E"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(0), TYPE_ARGUMENT(0), ARRAY, ARRAY]", locations.get("@F"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1)]", locations.get("@G"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), TYPE_ARGUMENT(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", "[TYPE_ARGUMENT(1), WILDCARD]", 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", "[ARRAY]", locations.get("@F"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY]", locations.get("@G"));
+ assertEquals("Wrong location", "[ARRAY, ARRAY, ARRAY]", 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", "[TYPE_ARGUMENT(0)]", locations.get("@B"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1)]", locations.get("@E"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), ARRAY]", locations.get("@F"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), ARRAY, ARRAY]", locations.get("@G"));
+ assertEquals("Wrong location", "[TYPE_ARGUMENT(1), ARRAY, ARRAY, ARRAY]", locations.get("@H"));
+}
+public void test0083() throws IOException {
+ String source =
+ "@Marker class A {}\n;" +
+ "@Marker class B extends @Marker A {}\n" +
+ "@Marker class C extends @Marker @SingleMember(0) A {}\n" +
+ "@Marker class D extends @Marker @SingleMember(0) @Normal(value = 0) A {}\n" +
+ "@Marker class E extends B {}\n;";
+
+ String expectedUnitToString =
+ "@Marker class A {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class B extends @Marker A {\n" +
+ " B() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class C extends @Marker @SingleMember(0) A {\n" +
+ " C() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class D extends @Marker @SingleMember(0) @Normal(value = 0) A {\n" +
+ " D() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class E extends B {\n" +
+ " E() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0083", expectedUnitToString);
+}
+
+// To test Parser.consumeAdditionalBound() with Type annotations
+public void test0084() throws IOException {
+ String source =
+ "@Marker interface I<@Negative T> {}\n" +
+ "@SingleMember(0) interface J<@Positive T> {}\n" +
+ "@Marker class A implements I<@SingleMember(0) A>, J<@Marker A> {}\n" +
+ "@Normal(value = 1) class X<E extends @Positive A & @Marker I<A> & @Marker @SingleMember(1) J<@Readonly A>> {\n" +
+ "}";
+ String expectedUnitToString =
+ "@Marker interface I<@Negative T> {\n" +
+ "}\n" +
+ "@SingleMember(0) interface J<@Positive T> {\n" +
+ "}\n" +
+ "@Marker class A implements I<@SingleMember(0) A>, J<@Marker A> {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Normal(value = 1) class X<E extends @Positive A & @Marker I<A> & @Marker @SingleMember(1) J<@Readonly A>> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0084", expectedUnitToString );
+}
+
+// To test Parser.consumeAdditionalBound() with Type annotations
+public void test0085() throws IOException {
+ String source =
+ "import java.io.Serializable;\n" +
+ "\n" +
+ "@SingleMember(10) class X<T extends @Marker Serializable & @Normal(value = 10) Runnable, V extends @Marker T> {\n" +
+ " @Negative T t;\n" +
+ " @Marker X(@Readonly T t) {\n" +
+ " this.t = t;\n" +
+ " }\n" +
+ " void foo(@Marker X this) {\n" +
+ " (this == null ? t : t).run();\n" +
+ " ((@Marker V) t).run();\n" +
+ " }\n" +
+ " public static void main(@Readonly String @Marker [] args) {\n" +
+ " new @Marker X<@Marker A, @Negative A>(new @Marker A()).foo();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class A implements @Marker Serializable, @SingleMember(1) Runnable {\n" +
+ " public void run() {\n" +
+ " System.out.print(\"AA\");\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "import java.io.Serializable;\n" +
+ "@SingleMember(10) class X<T extends @Marker Serializable & @Normal(value = 10) Runnable, V extends @Marker T> {\n" +
+ " @Negative T t;\n" +
+ " @Marker X(@Readonly T t) {\n" +
+ " super();\n" +
+ " this.t = t;\n" +
+ " }\n" +
+ " void foo(@Marker X this) {\n" +
+ " ((this == null) ? t : t).run();\n" +
+ " ((@Marker V) t).run();\n" +
+ " }\n" +
+ " public static void main(@Readonly String @Marker [] args) {\n" +
+ " new @Marker X<@Marker A, @Negative A>(new @Marker A()).foo();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class A implements @Marker Serializable, @SingleMember(1) Runnable {\n" +
+ " A() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void run() {\n" +
+ " System.out.print(\"AA\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0085", expectedUnitToString );
+}
+
+// To test Parser.classInstanceCreation() with type annotations
+public void test0086() throws IOException {
+ String source =
+ "class X {\n" +
+ " @Marker X() {\n" +
+ " System.out.print(\"new X created\");\n" +
+ " }\n" +
+ " void f() throws @Marker InstantiationException {\n" +
+ " X testX;\n" +
+ " testX = new @Readonly @Negative X();\n" +
+ " Double d;\n" +
+ " d = new @Marker @Positive Double(1.1);\n" +
+ " throw new @Positive @Normal(value = 10) InstantiationException(\"test\");\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " @Marker X() {\n" +
+ " super();\n" +
+ " System.out.print(\"new X created\");\n" +
+ " }\n" +
+ " void f() throws @Marker InstantiationException {\n" +
+ " X testX;\n" +
+ " testX = new @Readonly @Negative X();\n" +
+ " Double d;\n" +
+ " d = new @Marker @Positive Double(1.1);\n" +
+ " throw new @Positive @Normal(value = 10) InstantiationException(\"test\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0086", expectedUnitToString );
+}
+
+// To test Parser.classInstanceCreation() with type annotations
+public void test0087() throws IOException {
+ String source =
+ "class X {\n" +
+ " @Marker X() {\n" +
+ " System.out.print(\"new X created\");\n" +
+ " }\n" +
+ " @Marker class Inner {\n" +
+ " @Normal(value = 10) Inner(){\n" +
+ " System.out.print(\"X.Inner created\");\n" +
+ " }\n" +
+ " }\n" +
+ " public String getString(){\n" +
+ " return \"hello\";\n" +
+ " }\n" +
+ " void f(@Marker X this) {\n" +
+ " String testString;\n" +
+ " testString = new @Readonly @Negative X().getString();\n" +
+ " X.Inner testInner;\n" +
+ " testInner = new @Readonly X.Inner();\n" +
+ " int i;\n" +
+ " for(i = 0; i < 10; i++)\n" +
+ " System.out.print(\"test\");\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " @Marker class Inner {\n" +
+ " @Normal(value = 10) Inner() {\n" +
+ " super();\n" +
+ " System.out.print(\"X.Inner created\");\n" +
+ " }\n" +
+ " }\n" +
+ " @Marker X() {\n" +
+ " super();\n" +
+ " System.out.print(\"new X created\");\n" +
+ " }\n" +
+ " public String getString() {\n" +
+ " return \"hello\";\n" +
+ " }\n" +
+ " void f(@Marker X this) {\n" +
+ " String testString;\n" +
+ " testString = new @Readonly @Negative X().getString();\n" +
+ " X.Inner testInner;\n" +
+ " testInner = new @Readonly X.Inner();\n" +
+ " int i;\n" +
+ " for (i = 0; (i < 10); i ++) \n" +
+ " System.out.print(\"test\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0087", expectedUnitToString );
+}
+
+// To test Parser.classInstanceCreation() with type annotations
+public void test0088() throws IOException {
+ String source =
+ "import java.io.Serializable;\n" +
+ "class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker Serializable() {\n" +
+ " };\n" +
+ " new @Positive @Marker Serializable() {\n" +
+ " public long serialVersion;\n" +
+ " };\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.io.Serializable;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker Serializable() {\n" +
+ " };\n" +
+ " new @Positive @Marker Serializable() {\n" +
+ " public long serialVersion;\n" +
+ " };\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0088", expectedUnitToString );
+}
+
+// To test Parser.classInstanceCreation() with type annotations
+public void test0089() throws IOException {
+ String source =
+ "import java.io.Serializable;\n" +
+ "class X<T>{\n" +
+ " public void f() {\n" +
+ " X testX;\n" +
+ " testX = new @Marker @SingleMember(10) X<@Negative Integer>();\n" +
+ " System.out.print(\"object created\");\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.io.Serializable;\n" +
+ "class X<T> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void f() {\n" +
+ " X testX;\n" +
+ " testX = new @Marker @SingleMember(10) X<@Negative Integer>();\n" +
+ " System.out.print(\"object created\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0089", expectedUnitToString );
+}
+
+// To test Parser.classInstanceCreation() with type annotations
+public void test0090() throws IOException {
+ String source =
+ "class X <@Marker T extends @Readonly String> {\n" +
+ " T foo(T t) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Readonly X<String>().baz(\"SUCCESS\");\n" + // Parser.classInstanceCreation called
+ " }\n" +
+ " void baz(final T t) {\n" +
+ " new @Readonly @Marker Object() {\n" + // Parser.classInstanceCreation called
+ " void print() {\n" +
+ " }\n" +
+ " }.print();\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<@Marker T extends @Readonly String> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " T foo(T t) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Readonly X<String>().baz(\"SUCCESS\");\n" +
+ " }\n" +
+ " void baz(final T t) {\n" +
+ " new @Readonly @Marker Object() {\n" +
+ " void print() {\n" +
+ " }\n" +
+ "}.print();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0090", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithInitializer() with Type Annotations
+public void test0091() throws IOException {
+ String source =
+ "class X <@Marker T extends @Readonly String> {\n" +
+ " public static void main(String[] args) {\n" +
+ " int [] x1;\n" +
+ " x1 = new int @Marker @SingleMember(2) [] {-1, -2};\n" +
+ " Integer [][] x2;\n" +
+ " x2 = new @Positive Integer @Marker @SingleMember(3) [] @SingleMember(3) [] {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<@Marker T extends @Readonly String> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " int[] x1;\n" +
+ " x1 = new int @Marker @SingleMember(2) []{(- 1), (- 2)};\n" +
+ " Integer[][] x2;\n" +
+ " x2 = new @Positive Integer @Marker @SingleMember(3) [] @SingleMember(3) []{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0091", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithInitializer() with Type Annotations
+public void test0092() throws IOException {
+ String source =
+ "class X {\n" +
+ " static class T {\n" +
+ " public @Readonly Object @Normal(value = 10) [] f() {\n" +
+ " return new @Readonly Object @Normal(value = 10) [] {this, T.this};\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " static class T {\n" +
+ " T() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Readonly Object @Normal(value = 10) [] f() {\n" +
+ " return new @Readonly Object @Normal(value = 10) []{this, T.this};\n" +
+ " }\n" +
+ " }\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0092", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithInitializer() with Type Annotations
+public void test0093() throws IOException {
+ String source =
+ "class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " java.util.Arrays.asList(new @Readonly Object @SingleMember(1) [] {\"1\"});\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " java.util.Arrays.asList(new @Readonly Object @SingleMember(1) []{\"1\"});\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0093", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithInitializer() with Type Annotations
+public void test0094() throws IOException {
+ String source =
+ "class X {\n" +
+ " public boolean test() {\n" +
+ " String[] s;\n" +
+ " s = foo(new @Marker String @SingleMember(1) []{\"hello\"});\n" +
+ " return s != null;\n" +
+ " }\n" +
+ " public <@Marker F> F @SingleMember(1) [] foo(F[] f) {\n" +
+ " return f;\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public boolean test() {\n" +
+ " String[] s;\n" +
+ " s = foo(new @Marker String @SingleMember(1) []{\"hello\"});\n" +
+ " return (s != null);\n" +
+ " }\n" +
+ " public <@Marker F>F @SingleMember(1) [] foo(F[] f) {\n" +
+ " return f;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0094", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithInitializer() with Type Annotations
+public void test0095() throws IOException {
+ String source =
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "@Marker class Deejay {\n" +
+ " @Marker class Counter<@Marker T> {}\n" +
+ " public void f(String[] args) {\n" +
+ " Counter<@Positive Integer> songCounter;\n" +
+ " songCounter = new Counter<@Positive Integer>();\n" +
+ " Counter<@Readonly String> genre;\n" +
+ " genre = new Counter<@Readonly String>();\n" +
+ " List<@Marker Counter<?>> list1;\n" +
+ " list1 = Arrays.asList(new @Marker Counter<?> @Normal(value = 2) @Marker [] {songCounter, genre});\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "@Marker class Deejay {\n" +
+ " @Marker class Counter<@Marker T> {\n" +
+ " Counter() {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " Deejay() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void f(String[] args) {\n" +
+ " Counter<@Positive Integer> songCounter;\n" +
+ " songCounter = new Counter<@Positive Integer>();\n" +
+ " Counter<@Readonly String> genre;\n" +
+ " genre = new Counter<@Readonly String>();\n" +
+ " List<@Marker Counter<?>> list1;\n" +
+ " list1 = Arrays.asList(new @Marker Counter<?> @Normal(value = 2) @Marker []{songCounter, genre});\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0095", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithoutInitializer() with Type Annotations
+public void test0096() throws IOException {
+ String source =
+ "class X <@Marker T extends @Readonly String> {\n" +
+ " public static void main(String[] args) {\n" +
+ " int [] x1;\n" +
+ " x1 = new int @Marker @SingleMember(10) [10];\n" +
+ " Integer [][] x2;\n" +
+ " x2 = new @Positive Integer @Marker [10] @Normal(value = 10) [10];\n" +
+ " char[][] tokens;\n" +
+ " tokens = new char @SingleMember(0) [0] @Normal(value = 10) @Marker [];\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<@Marker T extends @Readonly String> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " int[] x1;\n" +
+ " x1 = new int @Marker @SingleMember(10) [10];\n" +
+ " Integer[][] x2;\n" +
+ " x2 = new @Positive Integer @Marker [10] @Normal(value = 10) [10];\n" +
+ " char[][] tokens;\n" +
+ " tokens = new char @SingleMember(0) [0] @Normal(value = 10) @Marker [];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0096", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithoutInitializer() with Type Annotations
+public void test0097() throws IOException {
+ String source =
+ "class X {\n" +
+ " public @Readonly Object @Normal(value = 10) [] f(@Marker X this) {\n" +
+ " return new @Readonly Object @Normal(value = 10) [10];\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public @Readonly Object @Normal(value = 10) [] f(@Marker X this) {\n" +
+ " return new @Readonly Object @Normal(value = 10) [10];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0097", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithoutInitializer() with Type Annotations
+public void test0098() throws IOException {
+ String source =
+ "class X {\n" +
+ " public boolean test() {\n" +
+ " String[] s;\n" +
+ " s = foo(new @Marker String @SingleMember(1) [10]);\n" +
+ " return s != null;\n" +
+ " }\n" +
+ " public <@Marker F> F @SingleMember(1) [] foo(F[] f) {\n" +
+ " return f;\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public boolean test() {\n" +
+ " String[] s;\n" +
+ " s = foo(new @Marker String @SingleMember(1) [10]);\n" +
+ " return (s != null);\n" +
+ " }\n" +
+ " public <@Marker F>F @SingleMember(1) [] foo(F[] f) {\n" +
+ " return f;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0098", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithoutInitializer() with Type Annotations
+public void test0099() throws IOException {
+ String source =
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "class X<@Marker T> {\n" +
+ " public void test() {\n" +
+ " List<@Marker X<?>> a;\n" +
+ " a = Arrays.asList(new @Marker X<?> @SingleMember(0) [0]);\n" +
+ " String @Marker [] @SingleMember(1) [] x;\n" +
+ " x = new @Readonly String @Normal(value = 5) [5] @SingleMember(1) [1];\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "class X<@Marker T> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void test() {\n" +
+ " List<@Marker X<?>> a;\n" +
+ " a = Arrays.asList(new @Marker X<?> @SingleMember(0) [0]);\n" +
+ " String @Marker [] @SingleMember(1) [] x;\n" +
+ " x = new @Readonly String @Normal(value = 5) [5] @SingleMember(1) [1];\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0099", expectedUnitToString );
+}
+
+// To test Parser.consumeArrayCreationExpressionWithoutInitializer() with Type Annotations
+public void test0100() throws IOException {
+ String source =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " public Integer[] getTypes() {\n" +
+ " List<@Positive Integer> list;\n" +
+ " list = new ArrayList<@Positive Integer>();\n" +
+ " return list == null \n" +
+ " ? new @Positive Integer @SingleMember(0) [0] \n" +
+ " : list.toArray(new @Positive Integer @Marker [list.size()]);\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public Integer[] getTypes() {\n" +
+ " List<@Positive Integer> list;\n" +
+ " list = new ArrayList<@Positive Integer>();\n" +
+ " return ((list == null) ? new @Positive Integer @SingleMember(0) [0] : list.toArray(new @Positive Integer @Marker [list.size()]));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0100", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithGenericsArray() with Type Annotations
+public void test0101() throws IOException {
+ String source =
+ "import java.util.*;\n" +
+ "\n" +
+ "@Marker class X {\n" +
+ " Vector<Object> data;\n" +
+ " public void t() {\n" +
+ " Vector<@Readonly Object> v;\n" +
+ " v = (@Marker @SingleMember(0) Vector<@Readonly Object>) data.elementAt(0);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "import java.util.*;\n" +
+ "@Marker class X {\n" +
+ " Vector<Object> data;\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void t() {\n" +
+ " Vector<@Readonly Object> v;\n" +
+ " v = (@Marker @SingleMember(0) Vector<@Readonly Object>) data.elementAt(0);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0101", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithGenericsArray() with Type Annotations
+// To test Parser.consumeClassHeaderExtends() with Type Annotations
+public void test0102() throws IOException {
+ String source =
+ "class X<E> {\n" +
+ " X<@Readonly String> bar() {\n" +
+ " return (@Marker AX<@Readonly String>) new X<@Readonly String>();\n" +
+ " }\n" +
+ " X<@Readonly String> bar(Object o) {\n" +
+ " return (@Marker AX<@Readonly String>) o;\n" +
+ " }\n" +
+ " X<@Negative E> foo(Object o) {\n" +
+ " return (@Marker @Normal(value = 10) AX<@Negative E>) o;\n" +
+ " } \n" +
+ " X<E> baz(Object o) {\n" +
+ " return (@Marker AX<E>) null;\n" +
+ " }\n" +
+ " X<String> baz2(BX bx) {\n" +
+ " return (@Marker @SingleMember(10) X<String>) bx;\n" +
+ " }\n" +
+ "}\n" +
+ "@Normal(value = 1) class AX<@Marker F> extends @Marker X<@SingleMember(10)F> {}\n" +
+ "@Normal(value = 2) class BX extends @Marker @SingleMember(1) AX<@Readonly String> {}\n";
+ String expectedUnitToString =
+ "class X<E> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " X<@Readonly String> bar() {\n" +
+ " return (@Marker AX<@Readonly String>) new X<@Readonly String>();\n" +
+ " }\n" +
+ " X<@Readonly String> bar(Object o) {\n" +
+ " return (@Marker AX<@Readonly String>) o;\n" +
+ " }\n" +
+ " X<@Negative E> foo(Object o) {\n" +
+ " return (@Marker @Normal(value = 10) AX<@Negative E>) o;\n" +
+ " }\n" +
+ " X<E> baz(Object o) {\n" +
+ " return (@Marker AX<E>) null;\n" +
+ " }\n" +
+ " X<String> baz2(BX bx) {\n" +
+ " return (@Marker @SingleMember(10) X<String>) bx;\n" +
+ " }\n" +
+ "}\n" +
+ "@Normal(value = 1) class AX<@Marker F> extends @Marker X<@SingleMember(10) F> {\n" +
+ " AX() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Normal(value = 2) class BX extends @Marker @SingleMember(1) AX<@Readonly String> {\n" +
+ " BX() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0102", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithGenericsArray() with Type Annotations
+public void test0103() throws IOException {
+ String source =
+ "import java.lang.reflect.Array;\n" +
+ "@Marker class X<@Readonly T> {\n" +
+ " T @SingleMember(0) [] theArray;\n" +
+ " public X(Class<T> clazz) {\n" +
+ " theArray = (@Marker @SingleMember(0) T @Normal(value = 10) []) Array.newInstance(clazz, 10); // Compiler warning\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.lang.reflect.Array;\n" +
+ "@Marker class X<@Readonly T> {\n" +
+ " T @SingleMember(0) [] theArray;\n" +
+ " public X(Class<T> clazz) {\n" +
+ " super();\n" +
+ " theArray = (@Marker @SingleMember(0) T @Normal(value = 10) []) Array.newInstance(clazz, 10);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0103", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithGenericsArray() with Type Annotations
+public void test0104() throws IOException {
+ String source =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " void method(Object o) {\n" +
+ " if (o instanceof String[]){\n" +
+ " String[] s;\n" +
+ " s = (@Marker @Readonly String @Marker []) o;\n" +
+ " }\n" +
+ " if (o instanceof @Readonly List<?>[]) {\n" +
+ " List<?>[] es;\n" +
+ " es = (@Marker List<?> @SingleMember(0) []) o;\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void method(Object o) {\n" +
+ " if ((o instanceof String[]))\n" +
+ " {\n" +
+ " String[] s;\n" +
+ " s = (@Marker @Readonly String @Marker []) o;\n" +
+ " }\n" +
+ " if ((o instanceof @Readonly List<?>[]))\n" +
+ " {\n" +
+ " List<?>[] es;\n" +
+ " es = (@Marker List<?> @SingleMember(0) []) o;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0104", expectedUnitToString );
+}
+
+
+// To test Parser.consumeCastExpressionWithPrimitiveType() with Type Annotations
+public void test0105() throws IOException {
+ String source =
+ "import java.util.HashMap;\n" +
+ "class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " HashMap<Byte, Byte> subst;\n" +
+ " subst = new HashMap<Byte, Byte>();\n" +
+ " subst.put((@Marker byte)1, (@Positive byte)1);\n" +
+ " if (1 + subst.get((@Positive @Normal(value = 10) byte)1) > 0.f) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " } \n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "import java.util.HashMap;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " HashMap<Byte, Byte> subst;\n" +
+ " subst = new HashMap<Byte, Byte>();\n" +
+ " subst.put((@Marker byte) 1, (@Positive byte) 1);\n" +
+ " if (((1 + subst.get((@Positive @Normal(value = 10) byte) 1)) > 0.f))\n" +
+ " {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0105", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithPrimitiveType() with Type Annotations
+public void test0106() throws IOException {
+ String source =
+ "class X{\n" +
+ " private float x, y, z;\n" +
+ " float magnitude () {\n" +
+ " return (@Marker @Positive float) Math.sqrt((x*x) + (y*y) + (z*z));\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X {\n" +
+ " private float x;\n" +
+ " private float y;\n" +
+ " private float z;\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " float magnitude() {\n" +
+ " return (@Marker @Positive float) Math.sqrt((((x * x) + (y * y)) + (z * z)));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0106", expectedUnitToString );
+}
+
+// To test Parser.consumeCastExpressionWithQualifiedGenericsArray() with Type Annotations
+// Javac version b76 crashes on type annotations on type arguments to parameterized classes
+// in a qualified generic reference
+public void test0107() throws IOException {
+ String source =
+ "class C1<T> {\n" +
+ " class C11 { }\n" +
+ " @Marker class C12 {\n" +
+ " T t;\n" +
+ " C1<@Readonly T>.C11 m() {\n" +
+ " C1<@Readonly T>.C11[] ts;\n" +
+ " ts = (@Marker C1<@Readonly T>.C11[]) new @Marker C1<?>.C11 @Normal(value = 5) [5];\n" +
+ " return ts;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class C1<T> {\n" +
+ " class C11 {\n" +
+ " C11() {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " @Marker class C12 {\n" +
+ " T t;\n" +
+ " C12() {\n" +
+ " super();\n" +
+ " }\n" +
+ " C1<@Readonly T>.C11 m() {\n" +
+ " C1<@Readonly T>.C11[] ts;\n" +
+ " ts = (@Marker C1<@Readonly T>.C11[]) new @Marker C1<?>.C11 @Normal(value = 5) [5];\n" +
+ " return ts;\n" +
+ " }\n" +
+ " }\n" +
+ " C1() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0107", expectedUnitToString );
+}
+
+// To test Parser.consumeFormalParameter() with Type Annotations
+public void test0108() throws IOException {
+ String source =
+ "class X {\n" +
+ " int field;" +
+ " public void test(@Marker X x,@Positive int i){\n" +
+ " x.field = i;\n" +
+ " }\n" +
+ " public static void main(@Readonly String args @Normal(10) []){" +
+ " System.exit(0);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X {\n" +
+ " int field;\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void test(@Marker X x, @Positive int i) {\n" +
+ " x.field = i;\n" +
+ " }\n" +
+ " public static void main(@Readonly String @Normal(10) [] args) {\n" +
+ " System.exit(0);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0108", expectedUnitToString );
+}
+
+// To test Parser.consumeFormalParameter() with Type Annotations
+public void test0109() throws IOException {
+ String source =
+ "class X<@Marker T> {\n" +
+ " T field;" +
+ " public void test(@Marker @SingleMember(1) X<? extends @Marker Object> x,@Positive T i){\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<@Marker T> {\n" +
+ " T field;\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void test(@Marker @SingleMember(1) X<? extends @Marker Object> x, @Positive T i) {\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0109", expectedUnitToString );
+}
+
+// To test Parser.consumeClassInstanceCreationExpressionQualifiedWithTypeArguments()
+// with Type Annotations
+// Javac b76 crashes with type annotations in qualified class instance creation expression
+public void test0110() throws IOException {
+ String source =
+ "class X {\n" +
+ " class MX {\n" +
+ " @Marker <T> MX(T t){\n" +
+ " System.out.println(t);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X().new <@Readonly String> @Marker MX(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X {\n" +
+ " class MX {\n" +
+ " @Marker <T>MX(T t) {\n" +
+ " super();\n" +
+ " System.out.println(t);\n" +
+ " }\n" +
+ " }\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X().new <@Readonly String>@Marker MX(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0110", expectedUnitToString);
+}
+
+// To test Parser.consumeClassInstanceCreationExpressionWithTypeArguments()
+// with Type Annotations
+public void test0111() throws IOException {
+ String source =
+ "class X {\n" +
+ " public <T> X(T t){\n" +
+ " System.out.println(t);\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new <@Readonly String> @Marker @SingleMember(0) X(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X {\n" +
+ " public <T>X(T t) {\n" +
+ " super();\n" +
+ " System.out.println(t);\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new <@Readonly String>@Marker @SingleMember(0) X(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0111", expectedUnitToString);
+}
+
+// To test Parser.consumeEnhancedForStatementHeaderInit() with Type Annotations
+public void test0112() throws IOException {
+ String source =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " List list() { return null; }\n" +
+ " void m2() { for (@SingleMember(10) Iterator<@Marker X> i = list().iterator(); i.hasNext();); }\n" +
+ " void m3() {\n" +
+ " Integer [] array;\n" +
+ " array = new Integer [] {1, 2, 3};\n" +
+ " List<List<X>> xList;\n" +
+ " xList = null;\n" +
+ " for(@Positive @SingleMember(10) Integer i: array) {}\n" +
+ " for(@Marker @Normal(value = 5) List<@Readonly X> x: xList) {}\n" +
+ " }" +
+ "}\n";
+ String expectedUnitToString =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " List list() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " void m2() {\n" +
+ " for (@SingleMember(10) Iterator<@Marker X> i = list().iterator();; i.hasNext(); ) \n" +
+ " ;\n" +
+ " }\n" +
+ " void m3() {\n" +
+ " Integer[] array;\n" +
+ " array = new Integer[]{1, 2, 3};\n" +
+ " List<List<X>> xList;\n" +
+ " xList = null;\n" +
+ " for (@Positive @SingleMember(10) Integer i : array) \n" +
+ " {\n" +
+ " }\n" +
+ " for (@Marker @Normal(value = 5) List<@Readonly X> x : xList) \n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_COMPLETION_PARSER & ~CHECK_SELECTION_PARSER & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0112", expectedUnitToString );
+ expectedUnitToString =
+ "import java.util.*;\n" +
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " List list() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " void m2() {\n" +
+ " for (@SingleMember(10) Iterator<@Marker X> i;; i.hasNext(); ) \n" +
+ " ;\n" +
+ " }\n" +
+ " void m3() {\n" +
+ " Integer[] array;\n" +
+ " array = new Integer[]{1, 2, 3};\n" +
+ " List<List<X>> xList;\n" +
+ " xList = null;\n" +
+ " for (@Positive @SingleMember(10) Integer i : array) \n" +
+ " {\n" +
+ " }\n" +
+ " for (@Marker @Normal(value = 5) List<@Readonly X> x : xList) \n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_COMPLETION_PARSER & CHECK_SELECTION_PARSER, source.toCharArray(), null, "test0112", expectedUnitToString );
+}
+
+// To test Parser.consumeEnterAnonymousClassBody() with Type Annotations
+public void test0113() throws IOException {
+ String source =
+ "@Marker class X {\n" +
+ " void f(@Normal(value = 5) X this) {\n" +
+ " new @Marker @SingleMember(10) Object() {\n" +
+ " void foo(){\n" +
+ " System.out.println(\"test\");\n" +
+ " }\n" +
+ " }.foo();\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "@Marker class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void f(@Normal(value = 5) X this) {\n" +
+ " new @Marker @SingleMember(10) Object() {\n" +
+ " void foo() {\n" +
+ " System.out.println(\"test\");\n" +
+ " }\n" +
+ "}.foo();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_DOCUMENT_ELEMENT_PARSER, source.toCharArray(), null, "test0113", expectedUnitToString );
+}
+
+// To test Parser.consumeEnterAnonymousClassBody() with Type Annotations
+public void test0114() throws IOException {
+ String source =
+ "class Toplevel2{\n" +
+ " public boolean foo(){\n" +
+ " Toplevel2 o;\n" +
+ " o = new @Marker @Normal(value = 5) Toplevel2() { \n" +
+ " public boolean foo() { return false; } // no copy in fact\n" +
+ " };\n" +
+ " return o.foo();\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class Toplevel2 {\n" +
+ " Toplevel2() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public boolean foo() {\n" +
+ " Toplevel2 o;\n" +
+ " o = new @Marker @Normal(value = 5) Toplevel2() {\n" +
+ " public boolean foo() {\n" +
+ " return false;\n" +
+ " }\n" +
+ "};\n" +
+ " return o.foo();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_DOCUMENT_ELEMENT_PARSER, source.toCharArray(), null, "test0114", expectedUnitToString );
+}
+
+// To test Parser.consumeEnterAnonymousClassBody() with Type Annotations
+public void test0115() throws IOException {
+ String source =
+ "class X <T> {\n" +
+ " T foo(T t) {\n" +
+ " System.out.println(t);\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String @Normal(value = 5) [] args) {\n" +
+ " new @Marker X<@SingleMember(10) @Normal(value = 5) XY>() {\n" +
+ " void run() {\n" +
+ " foo(new @Marker XY());\n" +
+ " }\n" +
+ " }.run();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class XY {\n" +
+ " public String toString() {\n" +
+ " return \"SUCCESS\";\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<T> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " T foo(T t) {\n" +
+ " System.out.println(t);\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String @Normal(value = 5) [] args) {\n" +
+ " new @Marker X<@SingleMember(10) @Normal(value = 5) XY>() {\n" +
+ " void run() {\n" +
+ " foo(new @Marker XY());\n" +
+ " }\n" +
+ "}.run();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class XY {\n" +
+ " XY() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public String toString() {\n" +
+ " return \"SUCCESS\";\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_DOCUMENT_ELEMENT_PARSER, source.toCharArray(), null, "test0115", expectedUnitToString );
+}
+
+// To test Parser.consumeInsideCastExpressionLL1() with Type Annotations
+public void test0116() throws IOException {
+ String source =
+ "class X{\n" +
+ " public void test1(){\n" +
+ " throw (@Marker Error) null; \n" +
+ " } \n" +
+ " public void test2(){\n" +
+ " String s;\n" +
+ " s = (@Marker @SingleMember(10) String) null;\n" +
+ " byte b;\n" +
+ " b = 0;\n" +
+ " Byte i;\n" +
+ " i = (@Positive Byte) b;\n" +
+ " } \n" +
+ " public void test3(java.io.Serializable name) {\n" +
+ " Object temp;\n" +
+ " temp = (Object)name;\n" +
+ " System.out.println( (String)temp );\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void test1() {\n" +
+ " throw (@Marker Error) null;\n" +
+ " }\n" +
+ " public void test2() {\n" +
+ " String s;\n" +
+ " s = (@Marker @SingleMember(10) String) null;\n" +
+ " byte b;\n" +
+ " b = 0;\n" +
+ " Byte i;\n" +
+ " i = (@Positive Byte) b;\n" +
+ " }\n" +
+ " public void test3(java.io.Serializable name) {\n" +
+ " Object temp;\n" +
+ " temp = (Object) name;\n" +
+ " System.out.println((String) temp);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0116", expectedUnitToString );
+}
+
+// To test Parser.consumeInstanceOfExpression() with Type Annotations
+public void test0117() throws IOException {
+ String source =
+ "import java.util.*;\n" +
+ "class X <@NonNull T>{\n" +
+ " public void test1(Object obj) {\n" +
+ " if(obj instanceof @Marker @NonNull X) {\n" +
+ " X newX;\n" +
+ " newX = (@NonNull X) obj;\n" +
+ " }\n" +
+ " }\n" +
+ " @NonNull T foo(@NonNull T t) {\n" +
+ " if (t instanceof @NonNull @Marker List<?> @Normal(value = 10) []) {\n" +
+ " List<?> @SingleMember (10) [] es;\n" +
+ " es = (@Marker List<?> @SingleMember(10) []) t;\n" +
+ " }\n" +
+ " if (t instanceof @Marker @Normal(value = 5) X<?>) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " return t;\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "import java.util.*;\n" +
+ "class X<@NonNull T> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void test1(Object obj) {\n" +
+ " if ((obj instanceof @Marker @NonNull X))\n" +
+ " {\n" +
+ " X newX;\n" +
+ " newX = (@NonNull X) obj;\n" +
+ " }\n" +
+ " }\n" +
+ " @NonNull T foo(@NonNull T t) {\n" +
+ " if ((t instanceof @NonNull @Marker List<?> @Normal(value = 10) []))\n" +
+ " {\n" +
+ " List<?> @SingleMember(10) [] es;\n" +
+ " es = (@Marker List<?> @SingleMember(10) []) t;\n" +
+ " }\n" +
+ " if ((t instanceof @Marker @Normal(value = 5) X<?>))\n" +
+ " {\n" +
+ " return t;\n" +
+ " }\n" +
+ " return t;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER , source.toCharArray(), null, "test0117", expectedUnitToString );
+}
+
+// To test Parser.consumeInstanceOfExpressionWithName() with Type Annotations
+public void test0118() throws IOException {
+ String source =
+ "class Outer<E> {\n" +
+ " Inner inner;\n" +
+ " class Inner {\n" +
+ " E e;\n" +
+ " @NonNull E getOtherElement(Object other) {\n" +
+ " if (!(other instanceof @Marker @SingleMember(10) Outer<?>.Inner))\n" +
+ " throw new @Marker IllegalArgumentException(String.valueOf(other));\n" +
+ " Inner that;\n" +
+ " that = (@Marker Inner) other;\n" +
+ " return that.e;\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "class Outer<E> {\n" +
+ " class Inner {\n" +
+ " E e;\n" +
+ " Inner() {\n" +
+ " super();\n" +
+ " }\n" +
+ " @NonNull E getOtherElement(Object other) {\n" +
+ " if ((! (other instanceof @Marker @SingleMember(10) Outer<?>.Inner)))\n" +
+ " throw new @Marker IllegalArgumentException(String.valueOf(other));\n" +
+ " Inner that;\n" +
+ " that = (@Marker Inner) other;\n" +
+ " return that.e;\n" +
+ " }\n" +
+ " }\n" +
+ " Inner inner;\n" +
+ " Outer() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER , source.toCharArray(), null, "test0118", expectedUnitToString );
+}
+
+// To test Parser.consumeTypeArgument() with Type Annotations
+public void test0119() throws IOException {
+ String source =
+ "class X<@SingleMember(1) Xp1 extends @Readonly String, @NonNull Xp2 extends @NonNull Comparable> extends @Marker XS<@SingleMember(10) Xp2> {\n" +
+ "\n" +
+ " public static void main(String @Marker [] args) {\n" +
+ " Integer w;\n" +
+ " w = new @Marker X<@Readonly @SingleMember(10) String,@Positive Integer>().get(new @Positive Integer(12));\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " Xp2 get(@Marker X this, Xp2 t) {\n" +
+ " System.out.print(\"{X::get}\");\n" +
+ " return super.get(t);\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class XS <@NonNull XSp1> {\n" +
+ " XSp1 get(XSp1 t) {\n" +
+ " @NonNull @SingleMember(10) Y.M mObject;\n" +
+ " mObject = new @SingleMember(10) @NonNull Y.M();\n" +
+ " System.out.print(\"{XS::get}\");\n" +
+ " return t;\n" +
+ " }\n" +
+ "}\n" +
+ "class X2<T,E>{}\n" +
+ "@Marker class Y extends @Marker X2<@NonNull Y.M, @NonNull @SingleMember(1) Y.N> {\n" +
+ " static class M{}\n" +
+ " static class N extends M{}\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<@SingleMember(1) Xp1 extends @Readonly String, @NonNull Xp2 extends @NonNull Comparable> extends @Marker XS<@SingleMember(10) Xp2> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String @Marker [] args) {\n" +
+ " Integer w;\n" +
+ " w = new @Marker X<@Readonly @SingleMember(10) String, @Positive Integer>().get(new @Positive Integer(12));\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " Xp2 get(@Marker X this, Xp2 t) {\n" +
+ " System.out.print(\"{X::get}\");\n" +
+ " return super.get(t);\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class XS<@NonNull XSp1> {\n" +
+ " XS() {\n" +
+ " super();\n" +
+ " }\n" +
+ " XSp1 get(XSp1 t) {\n" +
+ " @NonNull @SingleMember(10) Y.M mObject;\n" +
+ " mObject = new @SingleMember(10) @NonNull Y.M();\n" +
+ " System.out.print(\"{XS::get}\");\n" +
+ " return t;\n" +
+ " }\n" +
+ "}\n" +
+ "class X2<T, E> {\n" +
+ " X2() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class Y extends @Marker X2<@NonNull Y.M, @NonNull @SingleMember(1) Y.N> {\n" +
+ " static class M {\n" +
+ " M() {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " static class N extends M {\n" +
+ " N() {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0119", expectedUnitToString );
+}
+
+// To test Parser.consumeTypeArgument() with Type Annotations
+public void test0120() throws IOException {
+ String source =
+ "class X<A1, A2, A3, A4, A5, A6, A7, A8> {\n" +
+ "}\n" +
+ "class Y {\n" +
+ " @Marker X<int @Marker [], short @SingleMember(1) [] @Marker [], long[] @NonNull [][], float[] @Marker [] @Normal(value = 5) [][], double[][]@Marker [] @SingleMember(10) [][], boolean[][][][][][], char[] @Marker [][][][][][], Object[][]@Marker [] @SingleMember(10) [] @Normal(value = 5) [][][][][]> x;\n" +
+ "}\n";
+ String expectedUnitToString =
+ "class X<A1, A2, A3, A4, A5, A6, A7, A8> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {\n" +
+ " @Marker X<int @Marker [], short @SingleMember(1) [] @Marker [], long[] @NonNull [][], float[] @Marker [] @Normal(value = 5) [][], double[][] @Marker [] @SingleMember(10) [][], boolean[][][][][][], char[] @Marker [][][][][][], Object[][] @Marker [] @SingleMember(10) [] @Normal(value = 5) [][][][][]> x;\n" +
+ " Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0120", expectedUnitToString );
+}
+
+// To test Parser.consumeTypeArgumentReferenceType1() with Type Annotations
+public void test0121() throws IOException {
+ String source =
+ "@Marker class X <@NonNull T> {\n" +
+ " protected T t;\n" +
+ " @Marker X(@NonNull T t) {\n" +
+ " this.t = t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X<@Marker X<@Readonly @NonNull String>> xs;\n" +
+ " xs = new @Marker X<@Marker X<@Readonly @NonNull String>>(new @Marker X<@Readonly @NonNull @SingleMember(10) String>(\"SUCCESS\"));\n" +
+ " System.out.println(xs.t.t);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class X<@NonNull T> {\n" +
+ " protected T t;\n" +
+ " @Marker X(@NonNull T t) {\n" +
+ " super();\n" +
+ " this.t = t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X<@Marker X<@Readonly @NonNull String>> xs;\n" +
+ " xs = new @Marker X<@Marker X<@Readonly @NonNull String>>(new @Marker X<@Readonly @NonNull @SingleMember(10) String>(\"SUCCESS\"));\n" +
+ " System.out.println(xs.t.t);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_INDEXING_PARSER, source.toCharArray(), null, "test0121", expectedUnitToString );
+}
+
+// To test Parser.consumeTypeParameter1WithExtendsAndBounds() and Parser.consumeWildcardBoundsSuper() with
+// Type Annotations
+public void test0122() throws IOException {
+ String source =
+ "@Marker class Foo extends @Marker Foo1 implements @Marker @SingleMember(10) Comparable<@Marker Foo1> {\n" +
+ " public int compareTo(Foo1 arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n" +
+ "class Foo1 {}\n" +
+ "@Marker class X<@NonNull T extends @NonNull @Normal (value = 5) Object & @Marker Comparable<? super @NonNull T>> {\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X<@Marker Foo>();\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class Foo extends @Marker Foo1 implements @Marker @SingleMember(10) Comparable<@Marker Foo1> {\n" +
+ " Foo() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public int compareTo(Foo1 arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n" +
+ "class Foo1 {\n" +
+ " Foo1() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class X<@NonNull T extends @NonNull @Normal(value = 5) Object & @Marker Comparable<? super @NonNull T>> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X<@Marker Foo>();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0122", expectedUnitToString );
+}
+
+// To test Parser.consumeTypeParameter1WithExtendsAndBounds() with Type Annotations
+public void test0123() throws IOException {
+ String source =
+ "@Marker class Foo extends @Marker Foo1 implements @Marker @SingleMember(10) Comparable {\n" +
+ " public int compareTo(Object arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n" +
+ "class Foo1 {}\n" +
+ "@Marker class X<@NonNull T extends @NonNull @Normal (value = 5) Object & @Marker Comparable, @NonNull V extends @Readonly Object> {\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X<@Marker Foo, @SingleMember(0) Foo1>();\n" +
+ " Class <@NonNull Foo> c;\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "@Marker class Foo extends @Marker Foo1 implements @Marker @SingleMember(10) Comparable {\n" +
+ " Foo() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public int compareTo(Object arg0) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n" +
+ "class Foo1 {\n" +
+ " Foo1() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@Marker class X<@NonNull T extends @NonNull @Normal(value = 5) Object & @Marker Comparable, @NonNull V extends @Readonly Object> {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new @Marker @SingleMember(10) X<@Marker Foo, @SingleMember(0) Foo1>();\n" +
+ " Class<@NonNull Foo> c;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(source.toCharArray(), null, "test0123", expectedUnitToString );
+}
+//To test type annotations on static class member access in a declaration
+public void test0125() throws IOException {
+ String source =
+ "public class X extends @A(\"Hello, World!\") Y<@B @C('(') String[] @D[]> {}";
+ String expectedUnitToString =
+ "public class X extends @A(\"Hello, World!\") Y<@B @C(\'(\') String[] @D []> {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0125", expectedUnitToString );
+}
+//To test type annotations on static class member access in a declaration
+public void test0126() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A(\"Hello, World!\") @B @C('(') String@E[] @D[] f;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A(\"Hello, World!\") @B @C(\'(\') String @E [] @D [] f;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0126", expectedUnitToString );
+}
+//To test type annotations on static class member access in a declaration
+public void test0127() throws IOException {
+ String source =
+ "public class X {\n" +
+ " @A(\"Hello, World!\") Y<@B @C('(') String[] @D[]> f;\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " @A(\"Hello, World!\") Y<@B @C(\'(\') String[] @D []> f;\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0127", expectedUnitToString );
+}
+//type class literal expression
+public void test0128() throws IOException {
+ String source =
+ "public class X {\n" +
+ " public boolean foo(String s) {\n" +
+ " return (s instanceof @C('_') Object[]);\n" +
+ " }\n" +
+ " public Object foo1(String s) {\n" +
+ " return new @B(3) @A(\"new Object\") Object[] {};\n" +
+ " }\n" +
+ " public Class foo2(String s) {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public Class foo3(String s) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public boolean foo(String s) {\n" +
+ " return (s instanceof @C(\'_\') Object[]);\n" +
+ " }\n" +
+ " public Object foo1(String s) {\n" +
+ " return new @B(3) @A(\"new Object\") Object[]{};\n" +
+ " }\n" +
+ " public Class foo2(String s) {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public Class foo3(String s) {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0128", expectedUnitToString );
+}
+//instanceof checks
+public void test0129() throws IOException {
+ String source = "public class Clazz {\n" +
+ "public static void main(Object o) {\n" +
+ "if (o instanceof @Readonly String) {\n" +
+ "}\n" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class Clazz {\n" +
+ " public Clazz() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(Object o) {\n" +
+ " if ((o instanceof @Readonly String))\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0129", expectedUnitToString);
+}
+//instanceof checks
+public void test0130() throws IOException {
+ String source = "public class Clazz {\n" +
+ "public static void foo() {\n" +
+ " if (o instanceof @Readonly String[]) {}" +
+ "}\n" +
+ "}";
+ String expectedUnitToString =
+ "public class Clazz {\n" +
+ " public Clazz() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void foo() {\n" +
+ " if ((o instanceof @Readonly String[]))\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_ALL & ~CHECK_JAVAC_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+//cast
+public void test0131() throws IOException {
+ String source =
+ "public class X {\n" +
+ " public void foo(Object o) {\n" +
+ " if (o instanceof String[][]) {\n" +
+ " String[][] tab = (@C('_') @B(3) String[] @A[]) o;\n" +
+ " System.out.println(tab.length);\n" +
+ " }\n" +
+ " System.out.println(o);\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo(Object o) {\n" +
+ " if ((o instanceof String[][]))\n" +
+ " {\n" +
+ " String[][] tab = (@C(\'_\') @B(3) String[] @A []) o;\n" +
+ " System.out.println(tab.length);\n" +
+ " }\n" +
+ " System.out.println(o);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+//cast
+public void test0132() throws IOException {
+ String source =
+ "public class X {\n" +
+ " public void foo(Object o) {\n" +
+ " if (o instanceof String[][]) {\n" +
+ " String[][] tab = (@C('_') @B(3) String@D[] @A[]) o;\n" +
+ " System.out.println(tab.length);\n" +
+ " }\n" +
+ " System.out.println(o);\n" +
+ " }\n" +
+ "}";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo(Object o) {\n" +
+ " if ((o instanceof String[][]))\n" +
+ " {\n" +
+ " String[][] tab = (@C(\'_\') @B(3) String @D [] @A []) o;\n" +
+ " System.out.println(tab.length);\n" +
+ " }\n" +
+ " System.out.println(o);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+//generic type arguments in a generic method invocation
+public void test0133() throws IOException {
+ String source =
+ "public class X {\n" +
+ " static <T, U> T foo(T t, U u) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(X.<@D() @A(value = \"hello\") String, @B X>foo(\"SUCCESS\", null));\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static <T, U>T foo(T t, U u) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(X.<@D() @A(value = \"hello\") String, @B X>foo(\"SUCCESS\", null));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+//generic type arguments in a generic method invocation
+public void test0134() throws IOException {
+ String source =
+ "public class X {\n" +
+ "\n" +
+ " <T, U> T foo(T t, U u) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X x = new X();\n" +
+ " System.out.println(x.<@D() @A(value = \"hello\") String, @B X>foo(\"SUCCESS\", null));\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " <T, U>T foo(T t, U u) {\n" +
+ " return t;\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X x = new X();\n" +
+ " System.out.println(x.<@D() @A(value = \"hello\") String, @B X>foo(\"SUCCESS\", null));\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+//generic type arguments in a generic constructor invocation
+public void test0135() throws IOException {
+ String source =
+ "public class X {\n" +
+ " <T, U> X(T t, U u) {\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X x = new <@D() @A(value = \"hello\") String, @B X> X();\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class X {\n" +
+ " <T, U>X(T t, U u) {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X x = new <@D() @A(value = \"hello\") String, @B X>X();\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=383600 -- Receiver annotation - new syntax.
+public void test0136() throws IOException {
+ String source =
+ "public class X<T> {\n" +
+ " public class Y<K> {\n" +
+ " void foo(@Marker X<T> this) {\n" +
+ " }\n" +
+ " public class Z {\n" +
+ " Z(@D() @A(value = \"hello\") X<T>.Y<K> X.Y.this) {\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X<String>().new Y<Integer>().new Z();\n" +
+ " }\n" +
+ "}\n";
+ String expectedUnitToString =
+ "public class X<T> {\n" +
+ " public class Y<K> {\n" +
+ " public class Z {\n" +
+ " Z(@D() @A(value = \"hello\") X<T>.Y<K> X.Y.this) {\n" +
+ " super();\n" +
+ " }\n" +
+ " }\n" +
+ " public Y() {\n" +
+ " super();\n" +
+ " }\n" +
+ " void foo(@Marker X<T> this) {\n" +
+ " }\n" +
+ " }\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " new X<String>().new Y<Integer>().new Z();\n" +
+ " }\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0130", expectedUnitToString);
+}
+// Support type annotations for wildcard
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=388085
+public void test0137() throws IOException {
+ String source =
+ "class X {\n" +
+ " public void main(Four<@Marker ? super String, @Marker ? extends Object> param) {\n" +
+ " One<@Marker ? extends Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String,@Marker ? extends Object>>>> one = null;\n" +
+ " Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String,@Marker ? extends Object>>> two = null;\n" +
+ " Three<@Marker ? extends Four<@Marker ? super String,@Marker ? extends Object>> three = null;\n" +
+ " Four<@Marker ? super String,@Marker ? extends Object> four = param;\n" +
+ " }\n" +
+ "}\n" +
+ "class One<R> {}\n" +
+ "class Two<S> {}\n" +
+ "class Three<T> {}\n" +
+ "class Four<U, V> {}\n" +
+ "@interface Marker {}";
+ String expectedUnitToString =
+ "class X {\n" +
+ " X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void main(Four<@Marker ? super String, @Marker ? extends Object> param) {\n" +
+ " One<@Marker ? extends Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String, @Marker ? extends Object>>>> one = null;\n" +
+ " Two<@Marker ? extends Three<@Marker ? extends Four<@Marker ? super String, @Marker ? extends Object>>> two = null;\n" +
+ " Three<@Marker ? extends Four<@Marker ? super String, @Marker ? extends Object>> three = null;\n" +
+ " Four<@Marker ? super String, @Marker ? extends Object> four = param;\n" +
+ " }\n" +
+ "}\n" +
+ "class One<R> {\n" +
+ " One() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class Two<S> {\n" +
+ " Two() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class Three<T> {\n" +
+ " Three() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "class Four<U, V> {\n" +
+ " Four() {\n" +
+ " super();\n" +
+ " }\n" +
+ "}\n" +
+ "@interface Marker {\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0137", expectedUnitToString);
+}
+public void test0138() throws IOException {
+ String source =
+ "import java.lang.annotation.Target;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "public class X {\n" +
+ " public void foo() {\n" +
+ " int @Marker [][][] i = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [bar()] @Marker @Marker2 [];\n" +
+ " int @Marker [][][] j = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [X.bar2(2)] @Marker @Marker2 [];\n" +
+ " }\n" +
+ " public int bar() {\n" +
+ " return 2;\n" +
+ " }\n" +
+ " public static int bar2(int k) {\n" +
+ " return k;\n" +
+ " }\n" +
+ "}\n" +
+ "@Target (java.lang.annotation.ElementType.TYPE_USE)\n" +
+ "@interface Marker {}\n" +
+ "@Target (java.lang.annotation.ElementType.TYPE_USE)\n" +
+ "@interface Marker2 {}\n";
+ String expectedUnitToString =
+ "import java.lang.annotation.Target;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " super();\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " int @Marker [][][] i = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [bar()] @Marker @Marker2 [];\n" +
+ " int @Marker [][][] j = new @Marker2 int @Marker @Marker2 [2] @Marker @Marker2 [X.bar2(2)] @Marker @Marker2 [];\n" +
+ " }\n" +
+ " public int bar() {\n" +
+ " return 2;\n" +
+ " }\n" +
+ " public static int bar2(int k) {\n" +
+ " return k;\n" +
+ " }\n" +
+ "}\n" +
+ "@Target(java.lang.annotation.ElementType.TYPE_USE) @interface Marker {\n" +
+ "}\n" +
+ "@Target(java.lang.annotation.ElementType.TYPE_USE) @interface Marker2 {\n" +
+ "}\n";
+ checkParse(CHECK_PARSER, source.toCharArray(), null, "test0137", expectedUnitToString);
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java
new file mode 100644
index 0000000..eefd2eb
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 GK Software AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * Stephan Herrmann - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.io.File;
+import java.util.Map;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.tests.compiler.Activator;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.osgi.framework.Bundle;
+
+public abstract class AbstractNullAnnotationTest extends AbstractComparableTest {
+
+ // class libraries including our default null annotation types:
+ String[] LIBS;
+
+ // names and content of custom annotations used in a few tests:
+ static final String CUSTOM_NONNULL_NAME = "org/foo/NonNull.java";
+ static final String CUSTOM_NONNULL_CONTENT =
+ "package org.foo;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({METHOD,PARAMETER,LOCAL_VARIABLE})\n" +
+ "public @interface NonNull {\n" +
+ "}\n";
+ static final String CUSTOM_NONNULL_CONTENT_JSR308 =
+ "package org.foo;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({METHOD,PARAMETER,LOCAL_VARIABLE,TYPE_USE})\n" +
+ "public @interface NonNull {\n" +
+ "}\n";
+ static final String CUSTOM_NULLABLE_NAME = "org/foo/Nullable.java";
+ static final String CUSTOM_NULLABLE_CONTENT = "package org.foo;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({METHOD,PARAMETER,LOCAL_VARIABLE})\n" +
+ "public @interface Nullable {\n" +
+ "}\n";
+ static final String CUSTOM_NULLABLE_CONTENT_JSR308 = "package org.foo;\n" +
+ "import static java.lang.annotation.ElementType.*;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target({METHOD,PARAMETER,LOCAL_VARIABLE,TYPE_USE})\n" +
+ "public @interface Nullable {\n" +
+ "}\n";
+
+ public AbstractNullAnnotationTest(String name) {
+ super(name);
+ }
+
+ /**
+ * @deprecated indirectly uses deprecated class PackageAdmin
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ if (this.LIBS == null) {
+ String[] defaultLibs = getDefaultClassPaths();
+ int len = defaultLibs.length;
+ this.LIBS = new String[len+1];
+ System.arraycopy(defaultLibs, 0, this.LIBS, 0, len);
+ String version = this.complianceLevel >= ClassFileConstants.JDK1_8 ? "[2.0.0,3.0.0)" : "[1.1.0,2.0.0)";
+ Bundle[] bundles = Activator.getPackageAdmin().getBundles("org.eclipse.jdt.annotation", version);
+ File bundleFile = FileLocator.getBundleFile(bundles[0]);
+ if (bundleFile.isDirectory())
+ this.LIBS[len] = bundleFile.getPath()+"/bin";
+ else
+ this.LIBS[len] = bundleFile.getPath();
+ }
+ }
+
+ // Conditionally augment problem detection settings
+ static boolean setNullRelatedOptions = true;
+
+ protected Map getCompilerOptions() {
+ Map defaultOptions = super.getCompilerOptions();
+ if (setNullRelatedOptions) {
+ defaultOptions.put(JavaCore.COMPILER_PB_NULL_REFERENCE, JavaCore.ERROR);
+ defaultOptions.put(JavaCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE, JavaCore.ERROR);
+ defaultOptions.put(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK, JavaCore.ERROR);
+ defaultOptions.put(JavaCore.COMPILER_PB_INCLUDE_ASSERTS_IN_NULL_ANALYSIS, JavaCore.ENABLED);
+
+ defaultOptions.put(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION_FOR_INTERFACE_METHOD_IMPLEMENTATION, JavaCore.DISABLED);
+
+ // enable null annotations:
+ defaultOptions.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
+ // leave other new options at these defaults:
+// defaultOptions.put(CompilerOptions.OPTION_ReportNullContractViolation, JavaCore.ERROR);
+// defaultOptions.put(CompilerOptions.OPTION_ReportPotentialNullContractViolation, JavaCore.ERROR);
+// defaultOptions.put(CompilerOptions.OPTION_ReportNullContractInsufficientInfo, CompilerOptions.WARNING);
+
+// defaultOptions.put(CompilerOptions.OPTION_NullableAnnotationName, "org.eclipse.jdt.annotation.Nullable");
+// defaultOptions.put(CompilerOptions.OPTION_NonNullAnnotationName, "org.eclipse.jdt.annotation.NonNull");
+ }
+ return defaultOptions;
+ }
+ void runNegativeTestWithLibs(String[] testFiles, String expectedErrorLog) {
+ runNegativeTest(
+ testFiles,
+ expectedErrorLog,
+ this.LIBS,
+ false /*shouldFlush*/);
+ }
+ void runNegativeTestWithLibs(boolean shouldFlushOutputDirectory, String[] testFiles, Map customOptions, String expectedErrorLog) {
+ runNegativeTest(
+ shouldFlushOutputDirectory,
+ testFiles,
+ this.LIBS,
+ customOptions,
+ expectedErrorLog,
+ // runtime options
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+ }
+ void runNegativeTestWithLibs(String[] testFiles, Map customOptions, String expectedErrorLog) {
+ runNegativeTestWithLibs(false /* flush output directory */, testFiles, customOptions, expectedErrorLog);
+ }
+ void runConformTestWithLibs(String[] testFiles, Map customOptions, String expectedCompilerLog) {
+ runConformTestWithLibs(false /* flush output directory */, testFiles, customOptions, expectedCompilerLog);
+ }
+ void runConformTestWithLibs(String[] testFiles, Map customOptions, String expectedCompilerLog, String expectedOutput) {
+ runConformTest(
+ false, /* flush output directory */
+ testFiles,
+ this.LIBS,
+ customOptions,
+ expectedCompilerLog,
+ expectedOutput,
+ "",/* expected error */
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+ }
+ void runConformTestWithLibs(boolean shouldFlushOutputDirectory, String[] testFiles, Map customOptions, String expectedCompilerLog) {
+ runConformTest(
+ shouldFlushOutputDirectory,
+ testFiles,
+ this.LIBS,
+ customOptions,
+ expectedCompilerLog,
+ "",/* expected output */
+ "",/* expected error */
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+ }
+ void runConformTest(String[] testFiles, Map customOptions, String expectedOutputString) {
+ runConformTest(
+ testFiles,
+ expectedOutputString,
+ null /*classLibraries*/,
+ true /*shouldFlushOutputDirectory*/,
+ null /*vmArguments*/,
+ customOptions,
+ null /*customRequestor*/);
+
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
index d8a6c4f..c607684 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
@@ -4,12 +4,19 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
* Technical University Berlin - adapted for Object Teams
- * Stephan Herrmann - Contributions for
+ * Stephan Herrmann - Contribution for
* bug 335093 - [compiler][null] minimal hook for future null annotation support
+ * bug 388800 - [1.8] adjust tests to 1.8 JRE
+ * bug 402237 - [1.8][compiler] investigate differences between compilers re MethodVerifyTest
+ * bug 391376 - [1.8] check interaction of default methods with bridge methods and generics
* Bug 412203 - [compiler] Internal compiler error: java.lang.IllegalArgumentException: info cannot be null
* Jesper S Moller - Contributions for bug 378674 - "The method can be declared as static" is wrong
*******************************************************************************/
@@ -66,8 +73,159 @@
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.core.search.JavaSearchParticipant;
import org.eclipse.jdt.internal.core.search.indexing.BinaryIndexer;
+import org.osgi.framework.Bundle;
public abstract class AbstractRegressionTest extends AbstractCompilerTest implements StopableTestCase {
+
+ // for compiling against JRE 8:
+ static final boolean IS_JRE_8;
+ static final String COMPARATOR_IMPL_JRE8;
+ static final String COMPARATOR_RAW_IMPL_JRE8;
+ static final String COLLECTION_IMPL_JRE8;
+ static final String COLLECTION_RAW_IMPL_JRE8;
+ static final String LIST_IMPL_JRE8;
+ static final String COLLECTION_AND_LIST_IMPL_JRE8;
+ static final String COLLECTION_AND_LIST_RAW_IMPL_JRE8;
+ static final String LIST_RAW_IMPL_JRE8;
+ static final String ITERABLE_IMPL_JRE8;
+ static final String ITERABLE_RAW_IMPL_JRE8;
+ static final String ITERATOR_IMPL_JRE8;
+ static final String ITERATOR_RAW_IMPL_JRE8;
+ static final String MAP_IMPL_JRE8;
+ static final String MAP_RAW_IMPL_JRE8;
+
+ static {
+ String javaVersion = System.getProperty("java.specification.version");
+ IS_JRE_8 = "1.8".equals(javaVersion);
+ if (IS_JRE_8) { // TODO(stephan) accommodate future versions ...
+ COMPARATOR_IMPL_JRE8 = // replace '*' with T, '%' with U, $ with S
+ " public java.util.Comparator<*> reverseOrder() { return null;}\n" +
+ " public java.util.Comparator<*> reversed() { return null;}\n" +
+ " public java.util.Comparator<*> thenComparing(java.util.Comparator<? super *> other) { return null;}\n" +
+ " public <% extends java.lang.Comparable<? super %>> java.util.Comparator<*> thenComparing(java.util.function.Function<? super *, ? extends %> keyExtractor, java.util.Comparator<? super %> keyComparator) { return null;}\n" +
+ " public <% extends java.lang.Comparable<? super %>> java.util.Comparator<*> thenComparing(java.util.function.Function<? super *, ? extends %> keyExtractor) { return null;}\n" +
+ " public java.util.Comparator<*> thenComparing(java.util.function.ToIntFunction<? super *> keyExtractor) { return null;}\n" +
+ " public java.util.Comparator<*> thenComparing(java.util.function.ToLongFunction<? super *> keyExtractor) { return null;}\n" +
+ " public java.util.Comparator<*> thenComparing(java.util.function.ToDoubleFunction<? super *> keyExtractor) { return null;}\n";
+ COMPARATOR_RAW_IMPL_JRE8 =
+ " public java.util.Comparator reverseOrder() { return null;}\n" +
+ " public java.util.Comparator reversed() { return null;}\n" +
+ " public java.util.Comparator thenComparing(java.util.Comparator other) { return null;}\n" +
+ " public java.util.Comparator thenComparing(java.util.function.Function keyExtractor, java.util.Comparator keyComparator) { return null;}\n" +
+ " public java.util.Comparator thenComparing(java.util.function.Function keyExtractor) { return null;}\n" +
+ " public java.util.Comparator thenComparing(java.util.function.ToIntFunction keyExtractor) { return null;}\n" +
+ " public java.util.Comparator thenComparing(java.util.function.ToLongFunction keyExtractor) { return null;}\n" +
+ " public java.util.Comparator thenComparing(java.util.function.ToDoubleFunction keyExtractor) { return null;}\n";
+ COLLECTION_IMPL_JRE8 =
+ " public boolean removeAll(java.util.function.Predicate<? super *> filter) { return false;}\n" +
+ " public boolean removeIf(java.util.function.Predicate<? super *> filter) { return false;}\n" +
+ " public java.util.stream.Stream<*> stream() { return null;}\n" +
+ " public java.util.stream.Stream<*> parallelStream() { return null;}\n";
+ COLLECTION_AND_LIST_IMPL_JRE8 =
+ " public boolean removeAll(java.util.function.Predicate<? super *> filter) { return false;}\n" +
+ " public boolean removeIf(java.util.function.Predicate<? super *> filter) { return false;}\n" +
+ " public java.util.stream.Stream<*> stream() { return null;}\n" +
+ " public java.util.stream.Stream<*> parallelStream() { return null;}\n" +
+ " public void sort(java.util.Comparator<? super *> comparator) {}\n" +
+ " public void parallelSort(java.util.Comparator<? super *> comparator) {}\n" +
+ " public void replaceAll(java.util.function.UnaryOperator<*> operator) {}\n";
+ COLLECTION_RAW_IMPL_JRE8 =
+ " public @SuppressWarnings(\"rawtypes\") boolean removeAll(java.util.function.Predicate filter) { return false;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") boolean removeIf(java.util.function.Predicate filter) { return false;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") java.util.stream.Stream stream() { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") java.util.stream.Stream parallelStream() { return null;}\n";
+ LIST_IMPL_JRE8 = // replace '*' with your concrete type argument
+ " public void sort(java.util.Comparator<? super *> comparator) {}\n" +
+ " public void parallelSort(java.util.Comparator<? super *> comparator) {}\n" +
+ " public void replaceAll(java.util.function.UnaryOperator<*> operator) {}\n";
+ LIST_RAW_IMPL_JRE8 =
+ " public @SuppressWarnings(\"rawtypes\") void sort(java.util.Comparator comparator) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void parallelSort(java.util.Comparator comparator) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void replaceAll(java.util.function.UnaryOperator operator) {}\n";
+ COLLECTION_AND_LIST_RAW_IMPL_JRE8 =
+ " public @SuppressWarnings(\"rawtypes\") boolean removeAll(java.util.function.Predicate filter) { return false;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") boolean removeIf(java.util.function.Predicate filter) { return false;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") java.util.stream.Stream stream() { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") java.util.stream.Stream parallelStream() { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void sort(java.util.Comparator comparator) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void parallelSort(java.util.Comparator comparator) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void replaceAll(java.util.function.UnaryOperator operator) {}\n";
+ ITERABLE_IMPL_JRE8 = // replace '*' with your concrete type argument
+ " public void forEach(java.util.function.Consumer<? super *> block){}\n" +
+ " public void forEachRemaining(java.util.function.Consumer<? super *> action) {}\n" +
+ " public java.util.Spliterator<*> spliterator() {return null;}\n";
+ ITERABLE_RAW_IMPL_JRE8 =
+ " public @SuppressWarnings(\"rawtypes\") void forEach(java.util.function.Consumer action) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void forEachRemaining(java.util.function.Consumer action) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") java.util.Spliterator spliterator() {return null;}\n";
+ ITERATOR_IMPL_JRE8 = // replace '*' with your concrete type argument
+ "public void forEach(java.util.function.Consumer<? super *> action) {}\n" +
+ "public void forEachRemaining(java.util.function.Consumer<? super *> action) {}\n";
+ ITERATOR_RAW_IMPL_JRE8 =
+ " public @SuppressWarnings(\"rawtypes\") void forEach(java.util.function.Consumer block) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void forEachRemaining(java.util.function.Consumer action) {}\n";
+ MAP_IMPL_JRE8 = // '*' for 'K', '%' for 'V'
+ " public boolean remove(Object key, Object value) { return false;}\n" +
+ " public % getOrDefault(Object key, % defaultValue) {return defaultValue;}\n" +
+ " public void forEach(java.util.function.BiConsumer<? super *, ? super %> block) {}\n" +
+ " public void replaceAll(java.util.function.BiFunction<? super *, ? super %, ? extends %> function) {}\n" +
+ " public % putIfAbsent(* key, % value) { return null;}\n" +
+ " public boolean replace(* key, % oldValue, % newValue) { return false;}\n" +
+ " public % replace(* key, % value) { return null;}\n" +
+ " public % computeIfAbsent(* key, java.util.function.Function<? super *, ? extends %> mappingFunction) { return null;}\n" +
+ " public % computeIfPresent(* key, java.util.function.BiFunction<? super *, ? super %, ? extends %> remappingFunction) { return null;}\n" +
+ " public % compute(* key, java.util.function.BiFunction<? super *, ? super %, ? extends %> remappingFunction) { return null;}\n" +
+ " public % merge(* key, % value, java.util.function.BiFunction<? super %, ? super %, ? extends %> remappingFunction) { return null;}\n";
+ MAP_RAW_IMPL_JRE8 =
+ " public boolean remove(Object key, Object value) { return false;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object getOrDefault(Object key, Object defaultValue) { return defaultValue;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void forEach(java.util.function.BiConsumer block) {}\n" +
+ " public @SuppressWarnings(\"rawtypes\") void replaceAll(java.util.function.BiFunction function) {}\n" +
+ " public Object putIfAbsent(Object key, Object value) { return null;}\n" +
+ " public boolean replace(Object key, Object oldValue, Object newValue) { return false;}\n" +
+ " public Object replace(Object key, Object value) { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object computeIfAbsent(Object key, java.util.function.Function mappingFunction) { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object computeIfPresent(Object key, java.util.function.BiFunction remappingFunction) { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object compute(Object key, java.util.function.BiFunction remappingFunction) { return null;}\n" +
+ " public @SuppressWarnings(\"rawtypes\") Object merge(Object key, Object value, java.util.function.BiFunction remappingFunction) { return null;}\n";
+ } else {
+ COMPARATOR_IMPL_JRE8 = "";
+ COMPARATOR_RAW_IMPL_JRE8 = "";
+ COLLECTION_IMPL_JRE8 = "";
+ COLLECTION_RAW_IMPL_JRE8 = "";
+ LIST_IMPL_JRE8 = "";
+ COLLECTION_AND_LIST_IMPL_JRE8 = "";
+ COLLECTION_AND_LIST_RAW_IMPL_JRE8 = "";
+ LIST_RAW_IMPL_JRE8 = "";
+ ITERABLE_IMPL_JRE8 = "";
+ ITERABLE_RAW_IMPL_JRE8 = "";
+ ITERATOR_IMPL_JRE8 = "\n\n";
+ ITERATOR_RAW_IMPL_JRE8 = "\n\n";
+ MAP_IMPL_JRE8 = "";
+ MAP_RAW_IMPL_JRE8 = "";
+ }
+ }
+ String getCollectionAndListRawImplJRE8() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return COLLECTION_AND_LIST_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", "");
+ return COLLECTION_AND_LIST_RAW_IMPL_JRE8;
+ }
+ String getListRawImplJRE8() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return LIST_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", "");
+ return LIST_RAW_IMPL_JRE8;
+ }
+ String getIterableRawImplJRE8() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return ITERABLE_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", "");
+ return ITERABLE_RAW_IMPL_JRE8;
+ }
+ String getCollectionRawImplJRE8() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return COLLECTION_RAW_IMPL_JRE8.replaceAll("@SuppressWarnings\\(\"rawtypes\"\\)", "");
+ return COLLECTION_RAW_IMPL_JRE8;
+ }
+
// javac comparison related types, fields and methods - see runJavac for
// details
static class JavacCompiler {
@@ -130,6 +288,8 @@
this.version = JavaCore.VERSION_1_6;
} else if (rawVersion.indexOf("1.7") != -1) {
this.version = JavaCore.VERSION_1_7;
+ } else if (rawVersion.indexOf("1.8") != -1) {
+ this.version = JavaCore.VERSION_1_8;
} else {
throw new RuntimeException("unknown javac version: " + rawVersion);
}
@@ -169,6 +329,14 @@
if ("1.7.0-ea".equals(rawVersion)) {
return 0000;
}
+ if ("1.7.0_10".equals(rawVersion)) {
+ return 1000;
+ }
+ }
+ if (version == JavaCore.VERSION_1_8) {
+ if ("1.8.0-ea".equals(rawVersion)) {
+ return 0000;
+ }
}
throw new RuntimeException("unknown raw javac version: " + rawVersion);
}
@@ -493,7 +661,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) {
@@ -603,7 +774,15 @@
return compiler.compliance != ClassFileConstants.JDK1_5 ||
compiler.minor != 1600 ? null : this;
}
- }: null;
+ }: null,
+ Javac8AcceptsDefaultMethodInAnnotationType = RUN_JAVAC ?
+ new JavacHasABug(
+ MismatchType.EclipseErrorsJavacNone,
+ ClassFileConstants.JDK1_8, 23 /* TODO: insert minor when fixed */) : null,
+ Javac8ProducesIllegalAccessError = RUN_JAVAC ?
+ new JavacHasABug(
+ MismatchType.StandardOutputMismatch,
+ ClassFileConstants.JDK1_8, 23 /* TODO: insert minor when fixed */) : null;
}
}
@@ -845,6 +1024,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 \"")
@@ -1024,12 +1205,14 @@
return DefaultJavaRuntimeEnvironment.getDefaultClassPaths();
}
/** Get class library paths built from default class paths plus the JDT null annotations. */
- protected String[] getLibsWithNullAnnotations() throws IOException {
+ protected String[] getLibsWithNullAnnotations(long sourceLevel) throws IOException {
String[] defaultLibs = getDefaultClassPaths();
int len = defaultLibs.length;
String[] libs = new String[len+1];
System.arraycopy(defaultLibs, 0, libs, 0, len);
- File bundleFile = FileLocator.getBundleFile(Platform.getBundle("org.eclipse.jdt.annotation"));
+ String version = sourceLevel < ClassFileConstants.JDK1_8 ? "[1.1.0,2.0.0)" : "[2.0.0,3.0.0)";
+ Bundle[] bundles = Platform.getBundles("org.eclipse.jdt.annotation", version);
+ File bundleFile = FileLocator.getBundleFile(bundles[0]);
if (bundleFile.isDirectory())
libs[len] = bundleFile.getPath()+"/bin";
else
@@ -1044,6 +1227,9 @@
public boolean proceedOnErrors() {
return true;
}
+ public boolean ignoreAllErrors() {
+ return false;
+ }
};
}
/*
@@ -1852,6 +2038,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,
@@ -2101,7 +2314,9 @@
// javac options
javacTestOptions /* javac test options */);
}
- private void runTest(
+//{ObjectTeams: made accessible to sub-classes:
+ protected void runTest(
+// SH}
// test directory preparation
boolean shouldFlushOutputDirectory,
String[] testFiles,
@@ -2638,7 +2853,8 @@
false /* do not perform statements recovery */,
null /* no custom requestor */,
// compiler results
- true /* expecting compiler errors */,
+ expectedCompilerLog == null || /* expecting compiler errors */
+ expectedCompilerLog.indexOf("ERROR") != -1,
expectedCompilerLog /* expected compiler log */,
// runtime options
false /* do not force execution */,
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
index a44a371..73dfe0d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java
@@ -5,9 +5,16 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contribution for
+ * bug 388739 - [1.8][compiler] consider default methods when detecting whether a class needs to be declared abstract
+ * bug 399567 - [1.8] Different error message from the reference compiler
+ * bug 401796 - [1.8][compiler] don't treat default methods as overriding an independent inherited abstract method
* bug 395681 - [compiler] Improve simulation of javac6 behavior from bug 317719 after fixing bug 388795
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -493,8 +500,49 @@
"----------\n"
);
}
- //https://bugs.eclipse.org/bugs/show_bug.cgi?id=123943 - case 2
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=123943 - case 2
+ // see also Bug 399567 - [1.8] Different error message from the reference compiler
public void test009() {
+ String[] testFiles =
+ new String[] {
+ "T.java",
+ "import java.util.*;\n" +
+ "public class T {\n" +
+ " void test() {\n" +
+ " OrderedSet<String> os = null;\n" +
+ " os.add(\"hello\");\n" +
+ " OrderedSet<Integer> os2 = null;\n" +
+ " os2.add(1);\n" +
+ " }\n" +
+ "}\n" +
+ "interface OrderedSet<E> extends List<E>, Set<E> { boolean add(E o); }\n"
+ };
+ if (!IS_JRE_8 || this.complianceLevel < ClassFileConstants.JDK1_8)
+ this.runConformTest(testFiles, "");
+ else
+ this.runNegativeTest(
+ testFiles,
+ "----------\n" +
+ "1. WARNING in T.java (at line 5)\n" +
+ " os.add(\"hello\");\n" +
+ " ^^\n" +
+ "Null pointer access: The variable os can only be null at this location\n" +
+ "----------\n" +
+ "2. WARNING in T.java (at line 7)\n" +
+ " os2.add(1);\n" +
+ " ^^^\n" +
+ "Null pointer access: The variable os2 can only be null at this location\n" +
+ "----------\n" +
+ "3. ERROR in T.java (at line 10)\n" +
+ " interface OrderedSet<E> extends List<E>, Set<E> { boolean add(E o); }\n" +
+ " ^^^^^^^^^^\n" +
+ "Duplicate default methods named spliterator with the parameters () and () are inherited from the types Set<E> and List<E>\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=123943 variant to make it pass on JRE8
+ public void test009a() {
+ if (!IS_JRE_8 || this.complianceLevel < ClassFileConstants.JDK1_8)
+ return;
this.runConformTest(
new String[] {
"T.java",
@@ -506,8 +554,11 @@
" OrderedSet<Integer> os2 = null;\n" +
" os2.add(1);\n" +
" }\n" +
- "}" +
- "interface OrderedSet<E> extends List<E>, Set<E> { boolean add(E o); }\n"
+ "}\n" +
+ "interface OrderedSet<E> extends List<E>, Set<E> {\n" +
+ " boolean add(E o);\n" +
+ " default Spliterator<E> spliterator() { return null; }\n" +
+ "}\n"
},
""
);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
index 0c3182a..e12c964 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
@@ -4,6 +4,10 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
@@ -15,6 +19,9 @@
* bug 386356 - Type mismatch error with annotations and generics
* bug 331649 - [compiler][null] consider null annotations for fields
* bug 376590 - Private fields with @Inject are ignored by unused field validation
+ * Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
+ * Jesper S Moller - Contributions for
+ * bug 384567 - [1.5][compiler] Compiler accepts illegal modifiers on package declaration
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -1031,6 +1038,30 @@
"----------\n");
}
+ // check annotation member modifiers (validity unchanged despite grammar change from JSR 335 - default methods)
+ // and https://bugs.eclipse.org/bugs/show_bug.cgi?id=3383968
+ public void test039a() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public @interface X {\n" +
+ " strictfp double val() default 0.1;\n" +
+ " synchronized String id() default \"zero\";\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " strictfp double val() default 0.1;\n" +
+ " ^^^^^\n" +
+ "Illegal modifier for the annotation attribute X.val; only public & abstract are permitted\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " synchronized String id() default \"zero\";\n" +
+ " ^^^^\n" +
+ "Illegal modifier for the annotation attribute X.id; only public & abstract are permitted\n" +
+ "----------\n");
+ }
+
// check annotation array field initializer
public void test040() {
this.runNegativeTest(
@@ -8765,6 +8796,7 @@
IErrorHandlingPolicy errorHandlingPolicy = new IErrorHandlingPolicy() {
public boolean proceedOnErrors() { return true; }
public boolean stopOnFirstError() { return false; }
+ public boolean ignoreAllErrors() { return false; }
};
Map options = getCompilerOptions();
options.put(CompilerOptions.OPTION_Process_Annotations, CompilerOptions.ENABLED);
@@ -9908,40 +9940,51 @@
"----------\n" +
"7. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
- " ^^^^^^^^^^^^^^^^\n" +
- "Syntax error on tokens, delete these tokens\n" +
+ " ^^^^\n" +
+ "Syntax error, insert \"Identifier (\" to complete MethodHeaderName\n" +
"----------\n" +
"8. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
- " ^^^^\n" +
- "Syntax error, insert \"enum Identifier\" to complete EnumHeaderName\n" +
+ " ^^^^\n" +
+//{ObjectTeams: starting from here the OT/J grammar produces different errors:
+// different:
+ "Syntax error, insert \")\" to complete MethodSpecLong\n" +
"----------\n" +
"9. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^\n" +
- "Syntax error, insert \"EnumBody\" to complete EnumDeclaration\n" +
+ "Syntax error, insert \"<-\" to complete CallinBindingLeft\n" +
+//
"----------\n" +
"10. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^\n" +
+// new
+ "Syntax error, insert \"MethodSpecsLong EmptyParameterMappings\" to complete InvalidCallinBinding\n" +
+ "----------\n" +
+// number changes beyond this point
+ "11. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+ " org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
+ " ^^^^\n" +
"Syntax error, insert \"}\" to complete ClassBody\n" +
"----------\n" +
- "11. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+ "12. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Return type for the method is missing\n" +
"----------\n" +
- "12. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+ "13. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^\n" +
"NonNull cannot be resolved to a type\n" +
"----------\n" +
- "13. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+ "14. ERROR in snippet\\Bug366003.java (at line 13)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^^\n" +
"Nullable cannot be resolved to a type\n" +
"----------\n" +
- "14. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+ "15. ERROR in snippet\\Bug366003.java (at line 13)\n" +
+// SH}
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^\n" +
"Syntax error, insert \";\" to complete ConstructorDeclaration\n" +
@@ -9994,40 +10037,51 @@
"----------\n" +
"6. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
- " ^^^^^^^^^^^^^^^^\n" +
- "Syntax error on tokens, delete these tokens\n" +
+ " ^^^^\n" +
+ "Syntax error, insert \"Identifier (\" to complete MethodHeaderName\n" +
"----------\n" +
"7. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^\n" +
- "Syntax error, insert \"enum Identifier\" to complete EnumHeaderName\n" +
+//{ObjectTeams: starting from here the OT/J grammar produces different errors:
+// different:
+ "Syntax error, insert \")\" to complete MethodSpecLong\n" +
"----------\n" +
"8. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^\n" +
- "Syntax error, insert \"EnumBody\" to complete EnumDeclaration\n" +
+ "Syntax error, insert \"<-\" to complete CallinBindingLeft\n" +
+//
"----------\n" +
+// new
"9. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^\n" +
+ "Syntax error, insert \"MethodSpecsLong EmptyParameterMappings\" to complete InvalidCallinBinding\n" +
+// number changes beyond this point
+ "----------\n" +
+ "10. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+ " org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
+ " ^^^^\n" +
"Syntax error, insert \"}\" to complete ClassBody\n" +
"----------\n" +
- "10. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+ "11. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Return type for the method is missing\n" +
"----------\n" +
- "11. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+ "12. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^\n" +
"NonNull cannot be resolved to a type\n" +
"----------\n" +
- "12. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+ "13. ERROR in snippet\\Bug366003.java (at line 11)\n" +
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^^^^^^^^\n" +
"Nullable cannot be resolved to a type\n" +
"----------\n" +
- "13. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+ "14. ERROR in snippet\\Bug366003.java (at line 11)\n" +
+// SH}
" org.eclipse.User.User(@NonNull String name, int uid, @Nullable String email)\n" +
" ^\n" +
"Syntax error, insert \";\" to complete ConstructorDeclaration\n" +
@@ -10049,34 +10103,45 @@
"1. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^^^\n" +
- "Syntax error on token \"org\", delete this token\n" +
+ "Syntax error, insert \"Identifier (\" to complete MethodHeaderName\n" +
"----------\n" +
"2. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
- " ^^^\n" +
- "Syntax error, insert \"enum Identifier\" to complete EnumHeaderName\n" +
+ " ^^^\n" +
+//{ObjectTeams: starting from here the OT/J grammar produces different errors:
+// different:
+ "Syntax error, insert \")\" to complete MethodSpecLong\n" +
"----------\n" +
"3. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^^^\n" +
- "Syntax error, insert \"EnumBody\" to complete EnumDeclaration\n" +
- "----------\n" +
+ "Syntax error, insert \"<-\" to complete CallinBindingLeft\n" +
+//
+ "----------\n" +
+// new
"4. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^^^\n" +
+ "Syntax error, insert \"MethodSpecsLong EmptyParameterMappings\" to complete InvalidCallinBinding\n" +
+// number changes beyond this point
+ "----------\n" +
+ "5. ERROR in snippet\\Bug366003.java (at line 5)\n" +
+ " org.User(@Bla String a)\n" +
+ " ^^^\n" +
"Syntax error, insert \"}\" to complete ClassBody\n" +
"----------\n" +
- "5. ERROR in snippet\\Bug366003.java (at line 5)\n" +
+ "6. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^^^^^^^^^^^^^^^^^^^\n" +
"Return type for the method is missing\n" +
"----------\n" +
- "6. ERROR in snippet\\Bug366003.java (at line 5)\n" +
+ "7. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^^^\n" +
"Bla cannot be resolved to a type\n" +
- "----------\n" +
- "7. ERROR in snippet\\Bug366003.java (at line 5)\n" +
+ "----------\n" +
+// SH}
+ "8. ERROR in snippet\\Bug366003.java (at line 5)\n" +
" org.User(@Bla String a)\n" +
" ^\n" +
"Syntax error, insert \";\" to complete ConstructorDeclaration\n" +
@@ -10098,26 +10163,26 @@
" }\n" +
"}\n"
},
- "----------\n" +
- "1. ERROR in snippet\\Bug366003.java (at line 7)\n" +
- " e } catch (@Blah Exception eSecond) {\n" +
- " ^\n" +
- "Syntax error, insert \"AssignmentOperator Expression\" to complete Assignment\n" +
- "----------\n" +
- "2. ERROR in snippet\\Bug366003.java (at line 7)\n" +
- " e } catch (@Blah Exception eSecond) {\n" +
- " ^\n" +
- "Syntax error, insert \";\" to complete BlockStatements\n" +
- "----------\n" +
- "3. ERROR in snippet\\Bug366003.java (at line 8)\n" +
- " e }\n" +
- " ^\n" +
- "Syntax error, insert \"AssignmentOperator Expression\" to complete Expression\n" +
- "----------\n" +
- "4. ERROR in snippet\\Bug366003.java (at line 8)\n" +
- " e }\n" +
- " ^\n" +
- "Syntax error, insert \";\" to complete BlockStatements\n" +
+ "----------\n" +
+ "1. ERROR in snippet\\Bug366003.java (at line 7)\n" +
+ " e } catch (@Blah Exception eSecond) {\n" +
+ " ^\n" +
+ "Syntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration\n" +
+ "----------\n" +
+ "2. ERROR in snippet\\Bug366003.java (at line 7)\n" +
+ " e } catch (@Blah Exception eSecond) {\n" +
+ " ^\n" +
+ "Syntax error, insert \";\" to complete BlockStatements\n" +
+ "----------\n" +
+ "3. ERROR in snippet\\Bug366003.java (at line 8)\n" +
+ " e }\n" +
+ " ^\n" +
+ "Syntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration\n" +
+ "----------\n" +
+ "4. ERROR in snippet\\Bug366003.java (at line 8)\n" +
+ " e }\n" +
+ " ^\n" +
+ "Syntax error, insert \";\" to complete BlockStatements\n" +
"----------\n");
}
public void testBug366003e() {
@@ -10305,7 +10370,7 @@
customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);
customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);
customOptions.put(CompilerOptions.OPTION_AnnotationBasedNullAnalysis, CompilerOptions.ENABLED);
- customOptions.put(CompilerOptions.OPTION_NonNullAnnotationName, "p.NonNull");
+ customOptions.put(CompilerOptions.OPTION_NonNullByDefaultAnnotationName, "p.NonNullByDefault");
this.runNegativeTest(
true,
new String[] {
@@ -10328,7 +10393,7 @@
" public E2(long l) {}\n" +
"}\n" +
"class E3 {\n" +
- " @p.NonNull\n" +
+ " @p.NonNullByDefault\n" +
" private E3() {}\n" +
" public E3(long l) {}\n" +
"}\n" +
@@ -10338,12 +10403,12 @@
" private E4() {}\n" +
" public E4(long l) {}\n" +
"}\n",
- "p/NonNull.java",
+ "p/NonNullByDefault.java",
"package p;\n" +
"import static java.lang.annotation.ElementType.*;\n" +
"import java.lang.annotation.*;\n" +
- "@Target({TYPE, METHOD,PARAMETER,CONSTRUCTOR})\n" +
- "public @interface NonNull {\n" +
+ "@Target({TYPE, METHOD,CONSTRUCTOR})\n" +
+ "public @interface NonNullByDefault {\n" +
"}",
"p/Annot.java",
"package p;\n" +
@@ -10456,7 +10521,7 @@
customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);
customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR);
customOptions.put(CompilerOptions.OPTION_AnnotationBasedNullAnalysis, CompilerOptions.ENABLED);
- customOptions.put(CompilerOptions.OPTION_NonNullAnnotationName, "p.NonNull");
+ customOptions.put(CompilerOptions.OPTION_NonNullByDefaultAnnotationName, "p.NonNullByDefault");
this.runNegativeTest(
true,
new String[] {
@@ -10474,7 +10539,7 @@
" private class E22{}\n" +
"}\n" +
"class E3 {\n" +
- " @p.NonNull\n" +
+ " @p.NonNullByDefault\n" +
" private class E33{}\n" +
"}\n" +
"class E4 {\n" +
@@ -10482,12 +10547,12 @@
" @p.Annot\n" +
" private class E44{}\n" +
"}\n",
- "p/NonNull.java",
+ "p/NonNullByDefault.java",
"package p;\n" +
"import static java.lang.annotation.ElementType.*;\n" +
"import java.lang.annotation.*;\n" +
- "@Target({TYPE, METHOD,PARAMETER,LOCAL_VARIABLE})\n" +
- "public @interface NonNull {\n" +
+ "@Target({TYPE, METHOD,PARAMETER})\n" +
+ "public @interface NonNullByDefault {\n" +
"}",
"p/Annot.java",
"package p;\n" +
@@ -10889,4 +10954,45 @@
checkDisassembledClassFile(OUTPUT_DIR + File.separator +"X.class", "X", expectedOutput, ClassFileBytesDisassembler.DETAILED);
}
+// check invalid and annotations on package
+public void test384567() {
+ this.runNegativeTest(
+ new String[] {
+ "xy/X.java",
+ "public final synchronized @Foo private package xy;\n" +
+ "class X {\n" +
+ "}\n" +
+ "\n" +
+ "@interface Foo {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in xy\\X.java (at line 1)\n" +
+ " public final synchronized @Foo private package xy;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Syntax error, modifiers are not allowed here\n" +
+ "----------\n" +
+ "2. ERROR in xy\\X.java (at line 1)\n" +
+ " public final synchronized @Foo private package xy;\n" +
+ " ^^^^\n" +
+ "Package annotations must be in file package-info.java\n" +
+ "----------\n");
+}
+//check invalid modifiers on package
+public void test384567_2() {
+ this.runNegativeTest(
+ new String[] {
+ "xy/X.java",
+ "public final synchronized private package xy;\n" +
+ "class X {\n" +
+ "}\n" +
+ "\n"
+ },
+ "----------\n" +
+ "1. ERROR in xy\\X.java (at line 1)\n" +
+ " public final synchronized private package xy;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Syntax error, modifiers are not allowed here\n" +
+ "----------\n");
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java
index 1205491..c8a3131 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,8 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for Bug 331872 - [compiler] NPE in Scope.createArrayType when attempting qualified access from type parameter
+ * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
+ * Bug 409247 - [1.8][compiler] Verify error with code allocating multidimensional array
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
import java.io.File;
@@ -575,4 +577,19 @@
"The method foo(Object[]) is undefined for the type X<p>\n" +
"----------\n");
}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=409247 - [1.8][compiler] Verify error with code allocating multidimensional array
+public void test019() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " X [][][] x = new X[10][10][];\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n",
+ },
+ "SUCCESS");
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java
index fa1fba2..eda35e6 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java
@@ -1,10 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann <stephan@cs.tu-berlin.de> - Contributions for
@@ -902,7 +906,7 @@
"1. WARNING in X.java (at line 19)\n" +
" public void valueChanged(TreeSelectionEvent e) {\n" +
" ^\n" +
- "The parameter e is hiding another local variable defined in an enclosing type scope\n" +
+ "The parameter e is hiding another local variable defined in an enclosing scope\n" +
"----------\n" +
"2. ERROR in X.java (at line 23)\n" +
" static {\n" +
@@ -917,7 +921,7 @@
"4. WARNING in X.java (at line 26)\n" +
" public void actionPerformed(ActionEvent e) {\n" +
" ^\n" +
- "The parameter e is hiding another local variable defined in an enclosing type scope\n" +
+ "The parameter e is hiding another local variable defined in an enclosing scope\n" +
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=111898
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 80c081a..4d6707e 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
@@ -24,8 +28,10 @@
* bug 388281 - [compiler][null] inheritance of null annotations as an option
* bug 381443 - [compiler][null] Allow parameter widening from @NonNull to unannotated
* bug 383368 - [compiler][null] syntactic null analysis for field references
+ * Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
* Jesper Steen Moller - Contributions for
* bug 404146 - [1.7][compiler] nested try-catch-finally-blocks leads to unrunnable Java byte code
+ * bug 407297 - [1.8][compiler] Control generation of parameter names by option
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -1581,8 +1587,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" +
@@ -1655,6 +1662,7 @@
" -repeat <n> repeat compilation process <n> times for perf analysis\n" +
" -inlineJSR inline JSR bytecode (implicit if target >= 1.5)\n" +
" -enableJavadoc consider references in javadoc\n" +
+ " -parameters generate method parameters attribute (for target >= 1.8)\n" +
" -Xemacs used to enable emacs-style output in the console.\n" +
" It does not affect the xml log output\n" +
" -missingNullDefault report missing default nullness annotation\n" +
@@ -1937,7 +1945,8 @@
" <option key=\"org.eclipse.jdt.core.compiler.annotation.nonnullbydefault\" value=\"org.eclipse.jdt.annotation.NonNullByDefault\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.annotation.nullable\" value=\"org.eclipse.jdt.annotation.Nullable\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.annotation.nullanalysis\" value=\"disabled\"/>\n" +
- " <option key=\"org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode\" value=\"disabled\"/>\n" +
+ " <option key=\"org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode\" value=\"disabled\"/>\n" +
+ " <option key=\"org.eclipse.jdt.core.compiler.codegen.methodParameters\" value=\"do not generate\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.codegen.shareCommonFinallyBlocks\" value=\"disabled\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.codegen.targetPlatform\" value=\"1.5\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.codegen.unusedLocal\" value=\"optimize out\"/>\n" +
@@ -12702,12 +12711,12 @@
"2. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" +
" @Nullable Object foo(Object o, Object o2) { return null; }\n" +
" ^^^^^^\n" +
- "Missing nullable annotation: inherited method from X declares this parameter as @Nullable\n" +
+ "Missing nullable annotation: inherited method from X specifies this parameter as @Nullable\n" +
"----------\n" +
"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" +
" @Nullable Object foo(Object o, Object o2) { return null; }\n" +
" ^^^^^^\n" +
- "Missing non-null annotation: inherited method from X declares this parameter as @NonNull\n" +
+ "Missing non-null annotation: inherited method from X specifies this parameter as @NonNull\n" +
"----------\n" +
"3 problems (3 warnings)",
true);
@@ -12751,12 +12760,12 @@
"2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" +
" @Nullable Object foo(Object o, Object o2) { return null; }\n" +
" ^^^^^^\n" +
- "Missing nullable annotation: inherited method from X declares this parameter as @Nullable\n" +
+ "Missing nullable annotation: inherited method from X specifies this parameter as @Nullable\n" +
"----------\n" +
"3. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" +
" @Nullable Object foo(Object o, Object o2) { return null; }\n" +
" ^^^^^^\n" +
- "Missing non-null annotation: inherited method from X declares this parameter as @NonNull\n" +
+ "Missing non-null annotation: inherited method from X specifies this parameter as @NonNull\n" +
"----------\n" +
"3 problems (3 errors)",
true);
@@ -12840,7 +12849,7 @@
new String[] {
"X1.java",
"public class X1 {\n" +
- " Zork;\n" +
+ " Zork z;\n" +
"}\n",
"org/eclipse/jdt/annotation/NonNull.java",
NONNULL_ANNOTATION_CONTENT,
@@ -12861,9 +12870,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);
@@ -13514,7 +13523,8 @@
"import java.lang.annotation.*;\n" +
"public class X {\n" +
" @NonNull Object foo(@Nullable Object o, @NonNull Object o2) {\n" +
- " return new X().bar();\n" +
+ " Object o3 = new X().bar();\n" + // need a local to involve flow analysis
+ " return o3;\n" +
" }\n" +
" @Nullable Object bar() {\n" +
" return null;\n" +
@@ -13742,12 +13752,12 @@
"2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" +
" @Nullable Object foo(Object o, Object o2) { return null; }\n" +
" ^^^^^^\n" +
- "Missing nullable annotation: inherited method from X declares this parameter as @Nullable\n" +
+ "Missing nullable annotation: inherited method from X specifies this parameter as @Nullable\n" +
"----------\n" +
"3. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" +
" @Nullable Object foo(Object o, Object o2) { return null; }\n" +
" ^^^^^^\n" +
- "Missing non-null annotation: inherited method from X declares this parameter as @NonNull\n" +
+ "Missing non-null annotation: inherited method from X specifies this parameter as @NonNull\n" +
"----------\n" +
"3 problems (2 errors, 1 warning)",
false/*don't flush*/);
@@ -13796,7 +13806,7 @@
"2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" +
" @Nullable Object foo(Object o, Object o2) { return null; }\n" +
" ^^^^^^\n" +
- "Missing nullable annotation: inherited method from X declares this parameter as @Nullable\n" +
+ "Missing nullable annotation: inherited method from X specifies this parameter as @Nullable\n" +
"----------\n" +
"2 problems (2 errors)",
false/*don't flush*/);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_8.java
new file mode 100644
index 0000000..7aca6c9
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_8.java
@@ -0,0 +1,513 @@
+/*******************************************************************************
+ * Copyright (c) 2013 GoPivotal, Inc. All Rights Reserved.
+ * 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:
+ * Andy Clement (GoPivotal, Inc) aclement@gopivotal.com - Contributions for
+ * Bug 407191 - [1.8] Binary access support for type annotations
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
+import org.eclipse.jdt.internal.compiler.codegen.AnnotationTargetTypeConstants;
+import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
+import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair;
+import org.eclipse.jdt.internal.compiler.env.IBinaryField;
+import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
+import org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation;
+
+public class ClassFileReaderTest_1_8 extends AbstractRegressionTest {
+ static {
+ }
+
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+ }
+ public static Class testClass() {
+ return ClassFileReaderTest_1_8.class;
+ }
+
+ public ClassFileReaderTest_1_8(String name) {
+ super(name);
+ }
+
+ // Needed to run tests individually from JUnit
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.complianceLevel = ClassFileConstants.JDK1_8;
+ }
+
+ public void test001_classTypeParameter() throws Exception {
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "public class X<@Foo T1,@Bar(iii=99) T2> {}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int iii() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader classFileReader = getInternalClassFile("", "X", "X", source);
+
+ IBinaryTypeAnnotation[] typeAnnotations = classFileReader.getTypeAnnotations();
+ assertEquals(2,typeAnnotations.length);
+
+ assertEquals("@LFoo; CLASS_TYPE_PARAMETER(type_parameter_index=0)", printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LBar;(iii=(int)99) CLASS_TYPE_PARAMETER(type_parameter_index=1)", printTypeAnnotation(typeAnnotations[1]));
+ }
+
+ public void test001a_classTypeParameterDifferingRetentions() throws Exception {
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "public class X<@Foo T1,@Bar(iii=99) T2> {}\n" +
+ "@Retention(RetentionPolicy.RUNTIME)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int iii() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader classFileReader = getInternalClassFile("", "X", "X", source);
+
+ IBinaryTypeAnnotation[] typeAnnotations = classFileReader.getTypeAnnotations();
+ assertEquals(2,typeAnnotations.length);
+
+ assertEquals("@LBar;(iii=(int)99) CLASS_TYPE_PARAMETER(type_parameter_index=1)", printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LFoo; CLASS_TYPE_PARAMETER(type_parameter_index=0)", printTypeAnnotation(typeAnnotations[1]));
+ }
+
+ public void test002_methodTypeParameter() throws Exception {
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "public class X {\n" +
+ " <@Foo T1, @Bar(3) T2> void foo(T1 t1,T2 t2) {}\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int value() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader cfr = getInternalClassFile("", "X", "X", source);
+
+ IBinaryMethod method = getMethod(cfr,"foo");
+ assertNotNull(method);
+ IBinaryTypeAnnotation[] typeAnnotations = method.getTypeAnnotations();
+ assertNotNull(typeAnnotations);
+ assertEquals(2,typeAnnotations.length);
+ assertEquals("@LFoo; METHOD_TYPE_PARAMETER(type_parameter_index=0)",printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LBar;(value=(int)3) METHOD_TYPE_PARAMETER(type_parameter_index=1)",printTypeAnnotation(typeAnnotations[1]));
+ }
+
+ public void test003_classExtends() throws Exception {
+ this.complianceLevel = ClassFileConstants.JDK1_8;
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "public class X extends @Foo @Bar(iii=34) Object implements java.io.@Bar(iii=1) Serializable {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int iii() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader classFileReader = getInternalClassFile("", "X", "X", source);
+
+ IBinaryTypeAnnotation[] typeAnnotations = classFileReader.getTypeAnnotations();
+ assertEquals(3,typeAnnotations.length);
+ assertEquals("@LFoo; CLASS_EXTENDS(type_index=-1)", printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LBar;(iii=(int)34) CLASS_EXTENDS(type_index=-1)", printTypeAnnotation(typeAnnotations[1]));
+ assertEquals("@LBar;(iii=(int)1) CLASS_EXTENDS(type_index=0)", printTypeAnnotation(typeAnnotations[2]));
+ }
+
+ public void test004_classExtends() throws Exception {
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "public class X extends Y<@Foo String,@Bar Integer> implements I<@Foo String> {\n" +
+ "}\n" +
+ "class Y<T1, T2> {}\n" +
+ "interface I<T1> {}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int iii() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader classFileReader = getInternalClassFile("", "X", "X", source);
+
+ IBinaryTypeAnnotation[] typeAnnotations = classFileReader.getTypeAnnotations();
+ assertEquals(3,typeAnnotations.length);
+ assertEquals("@LFoo; CLASS_EXTENDS(type_index=-1), location=[TYPE_ARGUMENT(0)]", printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LBar; CLASS_EXTENDS(type_index=-1), location=[TYPE_ARGUMENT(1)]", printTypeAnnotation(typeAnnotations[1]));
+ assertEquals("@LFoo; CLASS_EXTENDS(type_index=0), location=[TYPE_ARGUMENT(0)]", printTypeAnnotation(typeAnnotations[2]));
+ }
+
+ public void test005_classTypeParameterBound() throws Exception {
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "public class X<U, T extends Y<@Foo String @Bar(1)[][]@Bar(2)[]> & @Bar(3) Cloneable> {}\n" +
+ "class Y<T> {}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int value() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader classFileReader = getInternalClassFile("", "X", "X", source);
+
+ IBinaryTypeAnnotation[] typeAnnotations = classFileReader.getTypeAnnotations();
+ assertEquals(4,typeAnnotations.length);
+ assertEquals("@LFoo; CLASS_TYPE_PARAMETER_BOUND(type_parameter_index=1, bound_index=0), location=[TYPE_ARGUMENT(0), ARRAY, ARRAY, ARRAY]", printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LBar;(value=(int)1) CLASS_TYPE_PARAMETER_BOUND(type_parameter_index=1, bound_index=0), location=[TYPE_ARGUMENT(0)]", printTypeAnnotation(typeAnnotations[1]));
+ assertEquals("@LBar;(value=(int)2) CLASS_TYPE_PARAMETER_BOUND(type_parameter_index=1, bound_index=0), location=[TYPE_ARGUMENT(0), ARRAY, ARRAY]", printTypeAnnotation(typeAnnotations[2]));
+ assertEquals("@LBar;(value=(int)3) CLASS_TYPE_PARAMETER_BOUND(type_parameter_index=1, bound_index=1)", printTypeAnnotation(typeAnnotations[3]));
+ }
+
+ public void test006_methodTypeParameterBound() throws Exception {
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "public class X{\n" +
+ " <T extends Y<@Foo Z @Bar(1)[][]@Bar(2)[]> & @Bar(3) Cloneable> void foo(T t) {}\n" +
+ "}\n" +
+ "class Y<T> {}\n" +
+ "class Z {}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int value() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader cfr = getInternalClassFile("", "X", "X", source);
+
+ IBinaryMethod method = getMethod(cfr,"foo");
+ assertNotNull(method);
+ IBinaryTypeAnnotation[] typeAnnotations = method.getTypeAnnotations();
+ assertNotNull(typeAnnotations);
+ assertEquals(4,typeAnnotations.length);
+ assertEquals("@LFoo; METHOD_TYPE_PARAMETER_BOUND(type_parameter_index=0, bound_index=0), location=[TYPE_ARGUMENT(0), ARRAY, ARRAY, ARRAY]",printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LBar;(value=(int)1) METHOD_TYPE_PARAMETER_BOUND(type_parameter_index=0, bound_index=0), location=[TYPE_ARGUMENT(0)]", printTypeAnnotation(typeAnnotations[1]));
+ assertEquals("@LBar;(value=(int)2) METHOD_TYPE_PARAMETER_BOUND(type_parameter_index=0, bound_index=0), location=[TYPE_ARGUMENT(0), ARRAY, ARRAY]", printTypeAnnotation(typeAnnotations[2]));
+ assertEquals("@LBar;(value=(int)3) METHOD_TYPE_PARAMETER_BOUND(type_parameter_index=0, bound_index=1)", printTypeAnnotation(typeAnnotations[3]));
+ }
+
+ public void test007_field() throws Exception {
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "import java.util.Map;\n" +
+ "public class X{\n" +
+ " @Foo Map<@Bar(1) String, @Bar(2) String @Bar(3)[] @Bar(4)[] @Bar(5)[]> field3;\n" +
+ "}\n" +
+ "class Y<T> {}\n" +
+ "class Z {}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int value() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader cfr = getInternalClassFile("", "X", "X", source);
+
+ IBinaryField field = getField(cfr,"field3");
+ assertNotNull(field);
+ IBinaryTypeAnnotation[] typeAnnotations = field.getTypeAnnotations();
+ assertNotNull(typeAnnotations);
+ assertEquals(6,typeAnnotations.length);
+ assertEquals("@LFoo; FIELD",printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LBar;(value=(int)1) FIELD, location=[TYPE_ARGUMENT(0)]", printTypeAnnotation(typeAnnotations[1]));
+ assertEquals("@LBar;(value=(int)2) FIELD, location=[TYPE_ARGUMENT(1), ARRAY, ARRAY, ARRAY]", printTypeAnnotation(typeAnnotations[2]));
+ assertEquals("@LBar;(value=(int)3) FIELD, location=[TYPE_ARGUMENT(1)]", printTypeAnnotation(typeAnnotations[3]));
+ assertEquals("@LBar;(value=(int)4) FIELD, location=[TYPE_ARGUMENT(1), ARRAY]", printTypeAnnotation(typeAnnotations[4]));
+ assertEquals("@LBar;(value=(int)5) FIELD, location=[TYPE_ARGUMENT(1), ARRAY, ARRAY]", printTypeAnnotation(typeAnnotations[5]));
+ }
+
+ public void test008_methodReturn() throws Exception {
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "import java.util.Map;\n" +
+ "public class X{\n" +
+ " @Bar(3) @Foo int foo() {\n" +
+ " return 1;\n" +
+ " }\n" +
+ " @Bar(3) int @Foo [] foo2() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int value() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader cfr = getInternalClassFile("", "X", "X", source);
+
+ IBinaryMethod method = getMethod(cfr,"foo");
+ assertNotNull(method);
+ IBinaryTypeAnnotation[] typeAnnotations = method.getTypeAnnotations();
+ assertNotNull(typeAnnotations);
+ assertEquals(2,typeAnnotations.length);
+ assertEquals("@LBar;(value=(int)3) METHOD_RETURN",printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LFoo; METHOD_RETURN", printTypeAnnotation(typeAnnotations[1]));
+
+ method = getMethod(cfr,"foo2");
+ assertNotNull(method);
+ typeAnnotations = method.getTypeAnnotations();
+ assertNotNull(typeAnnotations);
+ assertEquals(2,typeAnnotations.length);
+ assertEquals("@LBar;(value=(int)3) METHOD_RETURN, location=[ARRAY]",printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LFoo; METHOD_RETURN", printTypeAnnotation(typeAnnotations[1]));
+ }
+
+ public void test009_methodReceiver() throws Exception {
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "import java.util.Map;\n" +
+ "public class X{\n" +
+ " void foo(@Bar(3) X this) {}\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int value() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader cfr = getInternalClassFile("", "X", "X", source);
+
+ IBinaryMethod method = getMethod(cfr,"foo");
+ assertNotNull(method);
+ IBinaryTypeAnnotation[] typeAnnotations = method.getTypeAnnotations();
+ assertNotNull(typeAnnotations);
+ assertEquals(1,typeAnnotations.length);
+ assertEquals("@LBar;(value=(int)3) METHOD_RECEIVER", printTypeAnnotation(typeAnnotations[0]));
+ }
+
+ public void test010_methodFormalParameter() throws Exception {
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "import java.util.Map;\n" +
+ "public class X{\n" +
+ " void foo(@Bar(3) String s, @Foo int i) {}\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int value() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader cfr = getInternalClassFile("", "X", "X", source);
+
+ IBinaryMethod method = getMethod(cfr,"foo");
+ assertNotNull(method);
+ IBinaryTypeAnnotation[] typeAnnotations = method.getTypeAnnotations();
+ assertNotNull(typeAnnotations);
+ assertEquals(2,typeAnnotations.length);
+ assertEquals("@LBar;(value=(int)3) METHOD_FORMAL_PARAMETER(method_formal_parameter_index=0)",printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LFoo; METHOD_FORMAL_PARAMETER(method_formal_parameter_index=1)",printTypeAnnotation(typeAnnotations[1]));
+ }
+
+ public void test011_throws() throws Exception {
+ String source =
+ "import java.lang.annotation.*;\n" +
+ "import java.util.Map;\n" +
+ "public class X{\n" +
+ " void foo() throws @Foo Exception, @Bar(1) Throwable {}\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Foo {\n" +
+ "}\n" +
+ "@Retention(RetentionPolicy.CLASS)\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "@interface Bar {\n" +
+ " int value() default -1;\n" +
+ "}";
+
+ org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader cfr = getInternalClassFile("", "X", "X", source);
+
+ IBinaryMethod method = getMethod(cfr,"foo");
+ assertNotNull(method);
+ IBinaryTypeAnnotation[] typeAnnotations = method.getTypeAnnotations();
+ assertNotNull(typeAnnotations);
+ assertEquals(2,typeAnnotations.length);
+ assertEquals("@LFoo; THROWS(throws_type_index=0)",printTypeAnnotation(typeAnnotations[0]));
+ assertEquals("@LBar;(value=(int)1) THROWS(throws_type_index=1)",printTypeAnnotation(typeAnnotations[1]));
+ }
+
+ /**
+ * Produce a nicely formatted type annotation for testing. Exercises the API for type annotations.
+ * Output examples:<br>
+ * <tt>@Foo(id=34) CLASS_EXTENDS, type_index=-1, location=[ARRAY, INNER_TYPE, TYPE_ARGUMENT(0)]</tt><br>
+ */
+ private String printTypeAnnotation(IBinaryTypeAnnotation typeAnnotation) {
+ StringBuffer sb = new StringBuffer();
+ // The annotation:
+ IBinaryAnnotation annotation = typeAnnotation.getAnnotation();
+ sb.append('@').append(annotation.getTypeName());
+ IBinaryElementValuePair[] pairs = annotation.getElementValuePairs();
+ if (pairs.length != 0) {
+ sb.append('(');
+ for (int i = 0; i < pairs.length; i++) {
+ if (i > 0) {
+ sb.append(',');
+ }
+ sb.append(pairs[i].getName()).append('=').append(pairs[i].getValue());
+ }
+ sb.append(')');
+ }
+ sb.append(' ');
+
+ // target type
+ int targetType = typeAnnotation.getTargetType();
+ switch (targetType) {
+ case AnnotationTargetTypeConstants.CLASS_TYPE_PARAMETER:
+ sb.append("CLASS_TYPE_PARAMETER(type_parameter_index=").append(typeAnnotation.getTypeParameterIndex()).append(')');
+ break;
+ case AnnotationTargetTypeConstants.METHOD_TYPE_PARAMETER:
+ sb.append("METHOD_TYPE_PARAMETER(type_parameter_index=").append(typeAnnotation.getTypeParameterIndex()).append(')');
+ break;
+ case AnnotationTargetTypeConstants.CLASS_EXTENDS:
+ sb.append("CLASS_EXTENDS(type_index=").append((short)typeAnnotation.getSupertypeIndex()).append(')');
+ break;
+ case AnnotationTargetTypeConstants.CLASS_TYPE_PARAMETER_BOUND:
+ sb.append("CLASS_TYPE_PARAMETER_BOUND(type_parameter_index=").
+ append(typeAnnotation.getTypeParameterIndex()).
+ append(", bound_index=").append(typeAnnotation.getBoundIndex()).
+ append(')');
+ break;
+ case AnnotationTargetTypeConstants.METHOD_TYPE_PARAMETER_BOUND:
+ sb.append("METHOD_TYPE_PARAMETER_BOUND(type_parameter_index=").
+ append(typeAnnotation.getTypeParameterIndex()).
+ append(", bound_index=").append(typeAnnotation.getBoundIndex()).
+ append(')');
+ break;
+ case AnnotationTargetTypeConstants.FIELD:
+ sb.append("FIELD");
+ break;
+ case AnnotationTargetTypeConstants.METHOD_RETURN:
+ sb.append("METHOD_RETURN");
+ break;
+ case AnnotationTargetTypeConstants.METHOD_RECEIVER:
+ sb.append("METHOD_RECEIVER");
+ break;
+ case AnnotationTargetTypeConstants.METHOD_FORMAL_PARAMETER :
+ sb.append("METHOD_FORMAL_PARAMETER(method_formal_parameter_index=").
+ append(typeAnnotation.getMethodFormalParameterIndex()).append(')');
+ break;
+ case AnnotationTargetTypeConstants.THROWS :
+ sb.append("THROWS(throws_type_index=").
+ append(typeAnnotation.getThrowsTypeIndex()).append(')');
+ break;
+ default: throw new IllegalStateException("nyi "+targetType);
+ }
+
+ // location
+ int[] typepath = typeAnnotation.getTypePath();
+
+ if (typepath != IBinaryTypeAnnotation.NO_TYPE_PATH) {
+ sb.append(", location=["); //$NON-NLS-1$
+ for (int i = 0, max = typepath.length; i < max; i += 2) {
+ if (i > 0) {
+ sb.append(", "); //$NON-NLS-1$
+ }
+ switch (typepath[i]) {
+ case 0:
+ sb.append("ARRAY"); //$NON-NLS-1$
+ break;
+ case 1:
+ sb.append("INNER_TYPE"); //$NON-NLS-1$
+ break;
+ case 2:
+ sb.append("WILDCARD"); //$NON-NLS-1$
+ break;
+ case 3:
+ sb.append("TYPE_ARGUMENT(").append(typepath[i+1]).append(')'); //$NON-NLS-1$
+ break;
+ }
+ }
+ sb.append(']');
+ }
+ return sb.toString();
+ }
+
+ private IBinaryMethod getMethod(ClassFileReader cfr,String methodname) {
+ IBinaryMethod[] methods = cfr.getMethods();
+ if (methods == null) {
+ return null;
+ }
+ char[] methodnameAsCharArray = methodname.toCharArray();
+ for (int i = 0, max = methods.length; i < max; i++) {
+ if (CharOperation.equals(methods[i].getSelector(),methodnameAsCharArray)) {
+ return methods[i];
+ }
+ }
+ return null;
+ }
+
+ private IBinaryField getField(ClassFileReader cfr,String fieldname) {
+ IBinaryField[] fields = cfr.getFields();
+ if (fields == null) {
+ return null;
+ }
+ char[] fieldnameAsCharArray = fieldname.toCharArray();
+ for (int i = 0, max = fields.length; i < max; i++) {
+ if (CharOperation.equals(fields[i].getName(),fieldnameAsCharArray)) {
+ return fields[i];
+ }
+ }
+ return null;
+ }
+
+}
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 92eba22..5b13a5b 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
@@ -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
* Benjamin Muskalla - Contribution for bug 239066
@@ -16,11 +20,23 @@
* bug 365662 - [compiler][null] warn on contradictory and redundant null annotations
* bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
* bug 374605 - Unreasonable warning for enum-based switch statements
+ * bug 382353 - [1.8][compiler] Implementation property modifiers should be accepted on default methods.
+ * bug 382347 - [1.8][compiler] Compiler accepts incorrect default method inheritance
* bug 388281 - [compiler][null] inheritance of null annotations as an option
* bug 381443 - [compiler][null] Allow parameter widening from @NonNull to unannotated
+ * bug 392862 - [1.8][compiler][null] Evaluate null annotations on array types
* bug 331649 - [compiler][null] consider null annotations for fields
* bug 382789 - [compiler][null] warn when syntactically-nonnull expression is compared against null
+ * bug 402028 - [1.8][compiler] null analysis for reference expressions
+ * bug 401796 - [1.8][compiler] don't treat default methods as overriding an independent inherited abstract method
+ * bug 404649 - [1.8][compiler] detect illegal reference to indirect or redundant super
* bug 400761 - [compiler][null] null may be return as boolean without a diagnostic
+ * Bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
+ * Bug 415043 - [1.8][null] Follow-up re null type annotations after bug 392099
+ * Jesper S Moller - Contributions for
+ * bug 382701 - [1.8][compiler] Implement semantic analysis of Lambda expressions & Reference expression
+ * bug 382721 - [1.8][compiler] Effectively final variables needs special treatment
+ * bug 384567 - [1.5][compiler] Compiler accepts illegal modifiers on package declaration
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -369,6 +385,7 @@
expectedProblemAttributes.put("ArgumentTypeNotFound", DEPRECATED);
expectedProblemAttributes.put("ArgumentTypeNotVisible", DEPRECATED);
expectedProblemAttributes.put("ArrayConstantsOnlyInArrayInitializers", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("ArrayReferencePotentialNullReference", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("ArrayReferenceRequired", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("AssignmentHasNoEffect", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("AssignmentToMultiCatchParameter", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
@@ -413,24 +430,34 @@
expectedProblemAttributes.put("ComparingIdentical", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("ConflictingImport", new ProblemAttributes(CategorizedProblem.CAT_IMPORT));
expectedProblemAttributes.put("ConflictingNullAnnotations", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("ConstructedArrayIncompatible", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("ConstructionTypeMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("ConflictingInheritedNullAnnotations", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("ConstructorReferenceNotBelow18", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("ConstructorVarargsArgumentNeedCast", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("CorruptedSignature", new ProblemAttributes(CategorizedProblem.CAT_BUILDPATH));
+ expectedProblemAttributes.put("DanglingReference", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("DeadCode", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("DefaultMethodNotBelow18", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("DefaultMethodOverridesObjectMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("DereferencingNullableExpression", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("DiamondNotBelow17", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("DirectInvocationOfAbstractMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("DisallowedTargetForAnnotation", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("DisallowedExplicitThisParameter", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("DiscouragedReference", new ProblemAttributes(CategorizedProblem.CAT_RESTRICTION));
expectedProblemAttributes.put("DuplicateAnnotation", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("DuplicateAnnotationMember", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("DuplicateBlankFinalFieldInitialization", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("DuplicateBounds", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("DuplicateBoundInIntersectionCast", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("DuplicateCase", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("DuplicateDefaultCase", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("DuplicateField", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("DuplicateFinalLocalInitialization", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("DuplicateImport", new ProblemAttributes(CategorizedProblem.CAT_IMPORT));
expectedProblemAttributes.put("DuplicateInheritedMethods", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("DuplicateInheritedDefaultMethods", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("DuplicateLabel", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("DuplicateMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("DuplicateMethodErasure", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
@@ -459,11 +486,15 @@
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("FieldComparisonYieldsFalse", 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));
expectedProblemAttributes.put("FieldMissingDeprecatedAnnotation", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
@@ -486,10 +517,12 @@
expectedProblemAttributes.put("HierarchyCircularitySelfReference", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("HierarchyHasProblems", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalAbstractModifierCombinationForMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("IllegalStrictfpForAbstractInterfaceMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalAccessFromTypeVariable", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
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));
@@ -499,8 +532,10 @@
expectedProblemAttributes.put("IllegalHexaLiteral", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("IllegalInstanceofParameterizedType", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("IllegalInstanceofTypeParameter", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
+ expectedProblemAttributes.put("IllegalBasetypeInIntersectionCast", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalModifierCombinationFinalAbstractForClass", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalModifierCombinationFinalVolatileForField", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("IllegalModifierCombinationForInterfaceMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalModifierForAnnotationField", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("IllegalModifierForAnnotationMemberType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalModifierForAnnotationMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
@@ -515,6 +550,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("IllegalModifierForInterfaceMethod18", 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));
@@ -522,16 +558,24 @@
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("IllegalModifiers", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("IllegalPrimitiveOrArrayTypeForEnclosingInstance", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalQualifiedEnumConstantLabel", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalQualifiedParameterizedTypeAllocation", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("IllegalQualifierForExplicitThis", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("IllegalQualifierForExplicitThis2", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("IllegalReturnNullityRedefinition", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("IllegalRedefinitionToNonNullParameter", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("IllegalStaticModifierForMemberType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("IllegalTypeAnnotationsInStaticMemberAccess", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("IllegalTypeForExplicitThis", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("IllegalTypeVariableSuperReference", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("IllegalUnderscorePosition", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("IllegalUsageOfQualifiedTypeReference", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("IllegalUsageOfTypeAnnotations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("IllegalVararg", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("IllegalVarargInLambda", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForField", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForMemberType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
@@ -544,11 +588,14 @@
expectedProblemAttributes.put("IncompatibleExceptionInInheritedMethodThrowsClause", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IncompatibleExceptionInThrowsClause", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT));
+ expectedProblemAttributes.put("IncompatibleLambdaParameterType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("IncompatibleMethodReference", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IncompatibleReturnType", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("IncompatibleReturnTypeForNonInheritedInterfaceMethod", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT));
expectedProblemAttributes.put("IncompatibleTypesInConditionalOperator", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IncompatibleTypesInEqualityOperator", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IncompatibleTypesInForeach", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+
expectedProblemAttributes.put("IncorrectArityForParameterizedConstructor", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IncorrectArityForParameterizedMethod", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IncorrectArityForParameterizedType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
@@ -558,6 +605,7 @@
expectedProblemAttributes.put("IndirectAccessToStaticField", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
expectedProblemAttributes.put("IndirectAccessToStaticMethod", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
expectedProblemAttributes.put("IndirectAccessToStaticType", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
+ expectedProblemAttributes.put("InheritedDefaultMethodConflictsWithOtherInherited", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("InheritedFieldHidesEnclosingName", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("InheritedIncompatibleReturnType", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("InheritedMethodHidesEnclosingName", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
@@ -572,9 +620,12 @@
expectedProblemAttributes.put("InterfaceInheritedNameHidesEnclosingName", DEPRECATED);
expectedProblemAttributes.put("InterfaceInternalNameProvided", DEPRECATED);
expectedProblemAttributes.put("InterfaceNotFound", DEPRECATED);
+ expectedProblemAttributes.put("InterfaceNotFunctionalInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("InterfaceNotVisible", DEPRECATED);
expectedProblemAttributes.put("InternalTypeNameProvided", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("IntersectionCastNotBelow18", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("InvalidAnnotationMemberType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("InvalidArrayConstructorReference", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("InvalidBinary", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidBreak", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("InvalidCatchBlockSequence", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
@@ -592,6 +643,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));
@@ -611,6 +663,7 @@
expectedProblemAttributes.put("InvalidUsageOfEnumDeclarations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfForeachStatements", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfStaticImports", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("InvalidUsageOfTypeAnnotations", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfTypeArguments", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfTypeParameters", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("InvalidUsageOfTypeParametersForAnnotationDeclaration", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
@@ -687,6 +740,10 @@
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("LambdaDescriptorMentionsUnmentionable", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
+ expectedProblemAttributes.put("LambdaExpressionNotBelow18", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("LambdaRedeclaresArgument", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
+ expectedProblemAttributes.put("LambdaRedeclaresLocal", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("LocalVariableCanOnlyBeNull", DEPRECATED);
expectedProblemAttributes.put("LocalVariableCannotBeNull", DEPRECATED);
expectedProblemAttributes.put("LocalVariableHidingField", new ProblemAttributes(CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT));
@@ -703,9 +760,12 @@
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("MethodReferenceSwingsBothWays", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
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));
@@ -725,6 +785,8 @@
expectedProblemAttributes.put("MissingTypeInMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("MissingValueForAnnotationMember", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("MultiCatchNotBelow17", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
+ expectedProblemAttributes.put("MultipleFunctionalInterfaces", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("StaticInterfaceMethodNotBelow18", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("MustDefineEitherDimensionExpressionsOrInitializer", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("MustSpecifyPackage", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("NativeMethodsCannotBeStrictfp", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
@@ -734,6 +796,7 @@
expectedProblemAttributes.put("NeedToEmulateMethodAccess", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
expectedProblemAttributes.put("NoAdditionalBoundAfterTypeVariable", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("NoFieldOnBaseType", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("NoGenericLambda", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("NoImplicitStringConversionForCharArrayExpression", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("NoMessageSendOnArrayType", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("NoMessageSendOnBaseType", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
@@ -751,6 +814,7 @@
expectedProblemAttributes.put("NonStaticAccessToStaticMethod", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
expectedProblemAttributes.put("NonStaticContextForEnumMemberType", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("NonStaticFieldFromStaticInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("NonStaticOrAlienTypeReceiver", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("NonStaticTypeFromStaticInvocation", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("NotVisibleConstructor", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("NotVisibleConstructorInDefaultConstructor", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
@@ -759,10 +823,14 @@
expectedProblemAttributes.put("NotVisibleMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("NotVisibleType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("NullableFieldReference", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("NullAnnotationUnsupportedLocation", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("NullExpressionReference", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("NullLocalVariableComparisonYieldsFalse", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("NullLocalVariableInstanceofYieldsFalse", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("NullLocalVariableReference", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("NullityMismatchingTypeAnnotation", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("NullityMismatchTypeArgument", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("NullityUncheckedTypeAnnotationDetail", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("NullSourceString", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("NullUnboxing", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("NumericValueOutOfRange", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
@@ -770,6 +838,7 @@
expectedProblemAttributes.put("ObjectCannotHaveSuperTypes", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("ObjectHasNoSuperclass", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("ObjectMustBeClass", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
+ expectedProblemAttributes.put("OuterLocalMustBeEffectivelyFinal", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("OuterLocalMustBeFinal", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("OverridingDeprecatedMethod", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("OverridingMethodWithoutSuperInvocation", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
@@ -817,6 +886,8 @@
expectedProblemAttributes.put("RedundantSpecificationOfTypeArguments", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
expectedProblemAttributes.put("RedundantLocalVariableNullAssignment", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("RedundantNullAnnotation", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
+ expectedProblemAttributes.put("RedundantNullCheckAgainstNonNullType", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("RedundantNullCheckOnField", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("RedundantNullCheckOnNonNullExpression", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("RedundantNullCheckOnNonNullSpecdField", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("RedundantNullCheckOnNonNullLocalVariable", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
@@ -828,6 +899,10 @@
expectedProblemAttributes.put("RedundantNullDefaultAnnotationType", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
expectedProblemAttributes.put("RedundantNullDefaultAnnotationMethod", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
expectedProblemAttributes.put("RedundantSuperinterface", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
+ expectedProblemAttributes.put("ReferenceExpressionParameterMismatchPromisedNullable", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("ReferenceExpressionParameterRequiredNonnullUnchecked", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("ReferenceExpressionReturnNullRedef", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
+ expectedProblemAttributes.put("ReferenceExpressionReturnNullRedefUnchecked", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("ReferenceToForwardField", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("RequiredNonNullButProvidedNull", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("RequiredNonNullButProvidedPotentialNull", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
@@ -850,7 +925,10 @@
expectedProblemAttributes.put("StaticInheritedMethodConflicts", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("StaticMemberOfParameterizedType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("StaticMethodRequested", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
+ expectedProblemAttributes.put("StaticMethodShouldBeAccessedStatically", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("StringConstantIsExceedingUtf8Limit", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
+ expectedProblemAttributes.put("SuperAccessCannotBypassDirectSuper", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("SuperCallCannotBypassOverride", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
expectedProblemAttributes.put("SuperInterfaceMustBeAnInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("SuperInterfacesCollide", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("SuperTypeUsingWildcard", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
@@ -863,6 +941,7 @@
expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM));
expectedProblemAttributes.put("SwitchOnEnumNotBelow15", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("SwitchOnStringsNotBelow17", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("TargetTypeNotAFunctionalInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("Task", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("ThisInStaticContext", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("ThisSuperDuringConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_MEMBER));
@@ -949,6 +1028,7 @@
expectedProblemAttributes.put("UnusedWarningToken", new ProblemAttributes(CategorizedProblem.CAT_UNNECESSARY_CODE));
expectedProblemAttributes.put("UseAssertAsAnIdentifier", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
expectedProblemAttributes.put("UseEnumAsAnIdentifier", new ProblemAttributes(CategorizedProblem.CAT_CODE_STYLE));
+ expectedProblemAttributes.put("IllegalUseOfUnderscoreAsAnIdentifier", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX));
expectedProblemAttributes.put("UsingDeprecatedConstructor", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedField", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedMethod", new ProblemAttributes(CategorizedProblem.CAT_DEPRECATION));
@@ -962,7 +1042,11 @@
expectedProblemAttributes.put("WildcardConstructorInvocation", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("WildcardFieldAssignment", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("WildcardMethodInvocation", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("illFormedParameterizationOfFunctionalInterface", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("lambdaParameterTypeMismatched", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("lambdaSignatureMismatched", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("IllegalArrayOfUnionType", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
+ expectedProblemAttributes.put("IllegalArrayTypeInIntersectionCast", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
//{ObjectTeams: new problems (incomplete list):
//expectedProblemAttributes.put("", new ProblemAttributes(CategorizedProblem.CAT_UNSPECIFIED));
expectedProblemAttributes.put("OTJ_RELATED", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
@@ -1175,6 +1259,7 @@
expectedProblemAttributes.put("ArgumentTypeNotFound", SKIP);
expectedProblemAttributes.put("ArgumentTypeNotVisible", SKIP);
expectedProblemAttributes.put("ArrayConstantsOnlyInArrayInitializers", SKIP);
+ expectedProblemAttributes.put("ArrayReferencePotentialNullReference", new ProblemAttributes(JavaCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE));
expectedProblemAttributes.put("ArrayReferenceRequired", SKIP);
expectedProblemAttributes.put("AssignmentHasNoEffect", new ProblemAttributes(JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT));
expectedProblemAttributes.put("AssignmentToMultiCatchParameter", SKIP);
@@ -1218,11 +1303,18 @@
expectedProblemAttributes.put("ComparingIdentical", new ProblemAttributes(JavaCore.COMPILER_PB_COMPARING_IDENTICAL));
expectedProblemAttributes.put("ConflictingImport", SKIP);
expectedProblemAttributes.put("ConflictingNullAnnotations", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
+ expectedProblemAttributes.put("ConstructedArrayIncompatible", SKIP);
+ expectedProblemAttributes.put("ConstructionTypeMismatch", SKIP);
expectedProblemAttributes.put("ConflictingInheritedNullAnnotations", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
+ expectedProblemAttributes.put("ConstructorReferenceNotBelow18", SKIP);
expectedProblemAttributes.put("ContradictoryNullAnnotations", SKIP);
expectedProblemAttributes.put("ConstructorVarargsArgumentNeedCast", new ProblemAttributes(JavaCore.COMPILER_PB_VARARGS_ARGUMENT_NEED_CAST));
expectedProblemAttributes.put("CorruptedSignature", SKIP);
+ expectedProblemAttributes.put("DanglingReference", SKIP);
expectedProblemAttributes.put("DeadCode", new ProblemAttributes(JavaCore.COMPILER_PB_DEAD_CODE));
+ expectedProblemAttributes.put("DefaultMethodNotBelow18", SKIP);
+ expectedProblemAttributes.put("DefaultMethodOverridesObjectMethod", SKIP);
+ expectedProblemAttributes.put("DereferencingNullableExpression", new ProblemAttributes(JavaCore.COMPILER_PB_POTENTIAL_NULL_REFERENCE));
expectedProblemAttributes.put("DiamondNotBelow17", SKIP);
expectedProblemAttributes.put("DirectInvocationOfAbstractMethod", SKIP);
expectedProblemAttributes.put("DisallowedTargetForAnnotation", SKIP);
@@ -1231,12 +1323,14 @@
expectedProblemAttributes.put("DuplicateAnnotationMember", SKIP);
expectedProblemAttributes.put("DuplicateBlankFinalFieldInitialization", SKIP);
expectedProblemAttributes.put("DuplicateBounds", SKIP);
+ expectedProblemAttributes.put("DuplicateBoundInIntersectionCast", SKIP);
expectedProblemAttributes.put("DuplicateCase", SKIP);
expectedProblemAttributes.put("DuplicateDefaultCase", SKIP);
expectedProblemAttributes.put("DuplicateField", SKIP);
expectedProblemAttributes.put("DuplicateFinalLocalInitialization", SKIP);
expectedProblemAttributes.put("DuplicateImport", SKIP);
expectedProblemAttributes.put("DuplicateInheritedMethods", SKIP);
+ expectedProblemAttributes.put("DuplicateInheritedDefaultMethods", SKIP);
expectedProblemAttributes.put("DuplicateLabel", SKIP);
expectedProblemAttributes.put("DuplicateMethod", SKIP);
expectedProblemAttributes.put("DuplicateMethodErasure", SKIP);
@@ -1265,11 +1359,15 @@
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("FieldComparisonYieldsFalse", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
expectedProblemAttributes.put("FieldHidingField", new ProblemAttributes(JavaCore.COMPILER_PB_FIELD_HIDING));
expectedProblemAttributes.put("FieldHidingLocalVariable", new ProblemAttributes(JavaCore.COMPILER_PB_FIELD_HIDING));
expectedProblemAttributes.put("FieldMissingDeprecatedAnnotation", new ProblemAttributes(JavaCore.COMPILER_PB_MISSING_DEPRECATED_ANNOTATION));
@@ -1292,10 +1390,12 @@
expectedProblemAttributes.put("HierarchyCircularitySelfReference", SKIP);
expectedProblemAttributes.put("HierarchyHasProblems", SKIP);
expectedProblemAttributes.put("IllegalAbstractModifierCombinationForMethod", SKIP);
+ expectedProblemAttributes.put("IllegalStrictfpForAbstractInterfaceMethod", SKIP);
expectedProblemAttributes.put("IllegalAccessFromTypeVariable", SKIP);
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);
@@ -1305,8 +1405,10 @@
expectedProblemAttributes.put("IllegalHexaLiteral", SKIP);
expectedProblemAttributes.put("IllegalInstanceofParameterizedType", SKIP);
expectedProblemAttributes.put("IllegalInstanceofTypeParameter", SKIP);
+ expectedProblemAttributes.put("IllegalBasetypeInIntersectionCast", SKIP);
expectedProblemAttributes.put("IllegalModifierCombinationFinalAbstractForClass", SKIP);
expectedProblemAttributes.put("IllegalModifierCombinationFinalVolatileForField", SKIP);
+ expectedProblemAttributes.put("IllegalModifierCombinationForInterfaceMethod", SKIP);
expectedProblemAttributes.put("IllegalModifierForAnnotationField", SKIP);
expectedProblemAttributes.put("IllegalModifierForAnnotationMemberType", SKIP);
expectedProblemAttributes.put("IllegalModifierForAnnotationMethod", SKIP);
@@ -1321,6 +1423,7 @@
expectedProblemAttributes.put("IllegalModifierForInterface", SKIP);
expectedProblemAttributes.put("IllegalModifierForInterfaceField", SKIP);
expectedProblemAttributes.put("IllegalModifierForInterfaceMethod", SKIP);
+ expectedProblemAttributes.put("IllegalModifierForInterfaceMethod18", SKIP);
expectedProblemAttributes.put("IllegalModifierForLocalClass", SKIP);
expectedProblemAttributes.put("IllegalModifierForLocalEnum", SKIP);
expectedProblemAttributes.put("IllegalModifierForMemberClass", SKIP);
@@ -1328,16 +1431,24 @@
expectedProblemAttributes.put("IllegalModifierForMemberInterface", SKIP);
expectedProblemAttributes.put("IllegalModifierForMethod", SKIP);
expectedProblemAttributes.put("IllegalModifierForVariable", SKIP);
+ expectedProblemAttributes.put("IllegalModifiersForElidedType", SKIP);
+ expectedProblemAttributes.put("IllegalModifiers", SKIP);
expectedProblemAttributes.put("IllegalPrimitiveOrArrayTypeForEnclosingInstance", SKIP);
expectedProblemAttributes.put("IllegalQualifiedEnumConstantLabel", SKIP);
expectedProblemAttributes.put("IllegalQualifiedParameterizedTypeAllocation", SKIP);
+ expectedProblemAttributes.put("IllegalQualifierForExplicitThis", SKIP);
+ expectedProblemAttributes.put("IllegalQualifierForExplicitThis2", SKIP);
expectedProblemAttributes.put("IllegalRedefinitionToNonNullParameter", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
expectedProblemAttributes.put("IllegalReturnNullityRedefinition", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
expectedProblemAttributes.put("IllegalStaticModifierForMemberType", SKIP);
+ expectedProblemAttributes.put("IllegalTypeAnnotationsInStaticMemberAccess", SKIP);
+ expectedProblemAttributes.put("IllegalTypeForExplicitThis", SKIP);
expectedProblemAttributes.put("IllegalTypeVariableSuperReference", SKIP);
expectedProblemAttributes.put("IllegalUnderscorePosition", SKIP);
expectedProblemAttributes.put("IllegalUsageOfQualifiedTypeReference", SKIP);
+ expectedProblemAttributes.put("IllegalUsageOfTypeAnnotations", SKIP);
expectedProblemAttributes.put("IllegalVararg", SKIP);
+ expectedProblemAttributes.put("IllegalVarargInLambda", SKIP);
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForField", SKIP);
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForMemberType", SKIP);
expectedProblemAttributes.put("IllegalVisibilityModifierCombinationForMethod", SKIP);
@@ -1355,6 +1466,8 @@
expectedProblemAttributes.put("IncompatibleTypesInConditionalOperator", SKIP);
expectedProblemAttributes.put("IncompatibleTypesInEqualityOperator", SKIP);
expectedProblemAttributes.put("IncompatibleTypesInForeach", SKIP);
+ expectedProblemAttributes.put("IncompatibleLambdaParameterType", SKIP);
+ expectedProblemAttributes.put("IncompatibleMethodReference", SKIP);
expectedProblemAttributes.put("IncorrectArityForParameterizedConstructor", SKIP);
expectedProblemAttributes.put("IncorrectArityForParameterizedMethod", SKIP);
expectedProblemAttributes.put("IncorrectArityForParameterizedType", SKIP);
@@ -1364,6 +1477,7 @@
expectedProblemAttributes.put("IndirectAccessToStaticField", new ProblemAttributes(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS));
expectedProblemAttributes.put("IndirectAccessToStaticMethod", new ProblemAttributes(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS));
expectedProblemAttributes.put("IndirectAccessToStaticType", new ProblemAttributes(JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS));
+ expectedProblemAttributes.put("InheritedDefaultMethodConflictsWithOtherInherited", SKIP);
expectedProblemAttributes.put("InheritedFieldHidesEnclosingName", SKIP);
expectedProblemAttributes.put("InheritedIncompatibleReturnType", SKIP);
expectedProblemAttributes.put("InheritedMethodHidesEnclosingName", SKIP);
@@ -1378,9 +1492,12 @@
expectedProblemAttributes.put("InterfaceInheritedNameHidesEnclosingName", SKIP);
expectedProblemAttributes.put("InterfaceInternalNameProvided", SKIP);
expectedProblemAttributes.put("InterfaceNotFound", SKIP);
+ expectedProblemAttributes.put("InterfaceNotFunctionalInterface", SKIP);
expectedProblemAttributes.put("InterfaceNotVisible", SKIP);
expectedProblemAttributes.put("InternalTypeNameProvided", SKIP);
+ expectedProblemAttributes.put("IntersectionCastNotBelow18", SKIP);
expectedProblemAttributes.put("InvalidAnnotationMemberType", SKIP);
+ expectedProblemAttributes.put("InvalidArrayConstructorReference", SKIP);
expectedProblemAttributes.put("InvalidBinary", SKIP);
expectedProblemAttributes.put("InvalidBreak", SKIP);
expectedProblemAttributes.put("InvalidCatchBlockSequence", SKIP);
@@ -1398,6 +1515,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);
@@ -1416,7 +1534,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);
@@ -1493,6 +1613,10 @@
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("LambdaDescriptorMentionsUnmentionable", SKIP);
+ expectedProblemAttributes.put("LambdaExpressionNotBelow18", SKIP);
+ expectedProblemAttributes.put("LambdaRedeclaresArgument", SKIP);
+ expectedProblemAttributes.put("LambdaRedeclaresLocal", SKIP);
expectedProblemAttributes.put("LocalVariableCanOnlyBeNull", SKIP);
expectedProblemAttributes.put("LocalVariableCannotBeNull", SKIP);
expectedProblemAttributes.put("LocalVariableHidingField", new ProblemAttributes(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING));
@@ -1509,9 +1633,12 @@
expectedProblemAttributes.put("MethodNameClash", SKIP);
expectedProblemAttributes.put("MethodNameClashHidden", SKIP);
expectedProblemAttributes.put("MethodReducesVisibility", SKIP);
+ expectedProblemAttributes.put("MethodReferenceNotBelow18", SKIP);
+ expectedProblemAttributes.put("MethodReferenceSwingsBothWays", 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);
@@ -1531,6 +1658,8 @@
expectedProblemAttributes.put("MissingTypeInMethod", SKIP);
expectedProblemAttributes.put("MissingValueForAnnotationMember", SKIP);
expectedProblemAttributes.put("MultiCatchNotBelow17", SKIP);
+ expectedProblemAttributes.put("MultipleFunctionalInterfaces", SKIP);
+ expectedProblemAttributes.put("StaticInterfaceMethodNotBelow18", SKIP);
expectedProblemAttributes.put("MustDefineEitherDimensionExpressionsOrInitializer", SKIP);
expectedProblemAttributes.put("MustSpecifyPackage", SKIP);
expectedProblemAttributes.put("NativeMethodsCannotBeStrictfp", SKIP);
@@ -1540,6 +1669,7 @@
expectedProblemAttributes.put("NeedToEmulateMethodAccess", new ProblemAttributes(JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION));
expectedProblemAttributes.put("NoAdditionalBoundAfterTypeVariable", SKIP);
expectedProblemAttributes.put("NoFieldOnBaseType", SKIP);
+ expectedProblemAttributes.put("NoGenericLambda", SKIP);
expectedProblemAttributes.put("NoImplicitStringConversionForCharArrayExpression", new ProblemAttributes(JavaCore.COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION));
expectedProblemAttributes.put("NoMessageSendOnArrayType", SKIP);
expectedProblemAttributes.put("NoMessageSendOnBaseType", SKIP);
@@ -1557,6 +1687,7 @@
expectedProblemAttributes.put("NonStaticAccessToStaticMethod", new ProblemAttributes(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER));
expectedProblemAttributes.put("NonStaticContextForEnumMemberType", SKIP);
expectedProblemAttributes.put("NonStaticFieldFromStaticInvocation", SKIP);
+ expectedProblemAttributes.put("NonStaticOrAlienTypeReceiver", SKIP);
expectedProblemAttributes.put("NonStaticTypeFromStaticInvocation", SKIP);
expectedProblemAttributes.put("NotVisibleConstructor", SKIP);
expectedProblemAttributes.put("NotVisibleConstructorInDefaultConstructor", SKIP);
@@ -1565,6 +1696,10 @@
expectedProblemAttributes.put("NotVisibleMethod", SKIP);
expectedProblemAttributes.put("NotVisibleType", SKIP);
expectedProblemAttributes.put("NullableFieldReference", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_REFERENCE));
+ expectedProblemAttributes.put("NullAnnotationUnsupportedLocation", SKIP);
+ expectedProblemAttributes.put("NullityMismatchingTypeAnnotation", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
+ expectedProblemAttributes.put("NullityMismatchTypeArgument", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
+ expectedProblemAttributes.put("NullityUncheckedTypeAnnotationDetail", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION));
expectedProblemAttributes.put("NullExpressionReference", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_REFERENCE));
expectedProblemAttributes.put("NullLocalVariableComparisonYieldsFalse", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
expectedProblemAttributes.put("NullLocalVariableInstanceofYieldsFalse", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
@@ -1576,6 +1711,7 @@
expectedProblemAttributes.put("ObjectCannotHaveSuperTypes", SKIP);
expectedProblemAttributes.put("ObjectHasNoSuperclass", SKIP);
expectedProblemAttributes.put("ObjectMustBeClass", SKIP);
+ expectedProblemAttributes.put("OuterLocalMustBeEffectivelyFinal", SKIP);
expectedProblemAttributes.put("OuterLocalMustBeFinal", SKIP);
expectedProblemAttributes.put("OverridingDeprecatedMethod", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("OverridingMethodWithoutSuperInvocation", new ProblemAttributes(JavaCore.COMPILER_PB_OVERRIDING_METHOD_WITHOUT_SUPER_INVOCATION));
@@ -1623,6 +1759,8 @@
expectedProblemAttributes.put("RedundantSpecificationOfTypeArguments", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_TYPE_ARGUMENTS));
expectedProblemAttributes.put("RedundantLocalVariableNullAssignment", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
expectedProblemAttributes.put("RedundantNullAnnotation", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_ANNOTATION));
+ expectedProblemAttributes.put("RedundantNullCheckAgainstNonNullType", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
+ expectedProblemAttributes.put("RedundantNullCheckOnField", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
expectedProblemAttributes.put("RedundantNullCheckOnNonNullExpression", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
expectedProblemAttributes.put("RedundantNullCheckOnNonNullSpecdField", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
expectedProblemAttributes.put("RedundantNullCheckOnNonNullLocalVariable", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK));
@@ -1634,6 +1772,10 @@
expectedProblemAttributes.put("RedundantNullDefaultAnnotationType", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_ANNOTATION));
expectedProblemAttributes.put("RedundantNullDefaultAnnotationMethod", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_NULL_ANNOTATION));
expectedProblemAttributes.put("RedundantSuperinterface", new ProblemAttributes(JavaCore.COMPILER_PB_REDUNDANT_SUPERINTERFACE));
+ expectedProblemAttributes.put("ReferenceExpressionParameterMismatchPromisedNullable", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
+ expectedProblemAttributes.put("ReferenceExpressionParameterRequiredNonnullUnchecked", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION));
+ expectedProblemAttributes.put("ReferenceExpressionReturnNullRedef", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
+ expectedProblemAttributes.put("ReferenceExpressionReturnNullRedefUnchecked", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION));
expectedProblemAttributes.put("ReferenceToForwardField", SKIP);
expectedProblemAttributes.put("ReferenceToForwardTypeVariable", SKIP);
expectedProblemAttributes.put("RequiredNonNullButProvidedNull", new ProblemAttributes(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION));
@@ -1656,7 +1798,10 @@
expectedProblemAttributes.put("StaticInheritedMethodConflicts", SKIP);
expectedProblemAttributes.put("StaticMemberOfParameterizedType", SKIP);
expectedProblemAttributes.put("StaticMethodRequested", SKIP);
+ expectedProblemAttributes.put("StaticMethodShouldBeAccessedStatically", SKIP);
expectedProblemAttributes.put("StringConstantIsExceedingUtf8Limit", SKIP);
+ expectedProblemAttributes.put("SuperAccessCannotBypassDirectSuper", SKIP);
+ expectedProblemAttributes.put("SuperCallCannotBypassOverride", SKIP);
expectedProblemAttributes.put("SuperInterfaceMustBeAnInterface", SKIP);
expectedProblemAttributes.put("SuperInterfacesCollide", SKIP);
expectedProblemAttributes.put("SuperTypeUsingWildcard", SKIP);
@@ -1669,6 +1814,7 @@
expectedProblemAttributes.put("SuperfluousSemicolon", new ProblemAttributes(JavaCore.COMPILER_PB_EMPTY_STATEMENT));
expectedProblemAttributes.put("SwitchOnEnumNotBelow15", SKIP);
expectedProblemAttributes.put("SwitchOnStringsNotBelow17", SKIP);
+ expectedProblemAttributes.put("TargetTypeNotAFunctionalInterface", SKIP);
expectedProblemAttributes.put("Task", SKIP);
expectedProblemAttributes.put("ThisInStaticContext", SKIP);
expectedProblemAttributes.put("ThisSuperDuringConstructorInvocation", SKIP);
@@ -1755,6 +1901,7 @@
expectedProblemAttributes.put("UnusedWarningToken", new ProblemAttributes(JavaCore.COMPILER_PB_UNUSED_WARNING_TOKEN));
expectedProblemAttributes.put("UseAssertAsAnIdentifier", new ProblemAttributes(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER));
expectedProblemAttributes.put("UseEnumAsAnIdentifier", new ProblemAttributes(JavaCore.COMPILER_PB_ENUM_IDENTIFIER));
+ expectedProblemAttributes.put("IllegalUseOfUnderscoreAsAnIdentifier", SKIP);
expectedProblemAttributes.put("UsingDeprecatedConstructor", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedField", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
expectedProblemAttributes.put("UsingDeprecatedMethod", new ProblemAttributes(JavaCore.COMPILER_PB_DEPRECATION));
@@ -1768,7 +1915,12 @@
expectedProblemAttributes.put("WildcardConstructorInvocation", SKIP);
expectedProblemAttributes.put("WildcardFieldAssignment", SKIP);
expectedProblemAttributes.put("WildcardMethodInvocation", SKIP);
+ expectedProblemAttributes.put("illFormedParameterizationOfFunctionalInterface", SKIP);
+ expectedProblemAttributes.put("lambdaParameterTypeMismatched", SKIP);
+ expectedProblemAttributes.put("lambdaSignatureMismatched", SKIP);
+ expectedProblemAttributes.put("DisallowedExplicitThisParameter", SKIP);
expectedProblemAttributes.put("IllegalArrayOfUnionType", SKIP);
+ expectedProblemAttributes.put("IllegalArrayTypeInIntersectionCast", SKIP);
//{ObjectTeams: new constants:
expectedProblemAttributes.put("OTJ_RELATED", SKIP);
expectedProblemAttributes.put("OTCHAP", SKIP);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java
index 4a2bab6..38436e0 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java
@@ -2966,7 +2966,7 @@
"The argument of type null should explicitly be cast to Class[] for the invocation of the varargs method getMethod(String, Class...) from type Class. It could alternatively be cast to Class for a varargs invocation\n" +
"----------\n";
String javaVersion = System.getProperty("java.version");
- if (isJRELevel(AbstractCompilerTest.F_1_6|AbstractCompilerTest.F_1_7)
+ if (isJRELevel(AbstractCompilerTest.F_1_6|AbstractCompilerTest.F_1_7|AbstractCompilerTest.F_1_8)
|| (AbstractCompilerTest.getPossibleComplianceLevels() == AbstractCompilerTest.F_1_5
&& javaVersion.indexOf("1.5") == -1)) {
errorMessage =
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated18Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated18Test.java
new file mode 100644
index 0000000..40d4cc7
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated18Test.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+public class Deprecated18Test extends AbstractRegressionTest {
+public Deprecated18Test(String name) {
+ super(name);
+}
+public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+}
+public void test412555() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " Runnable r = () -> {\n" +
+ " Y.callMe();\n" +
+ " };\n" +
+ " }\n" +
+ "}\n",
+ "Y.java",
+ "public class Y {\n" +
+ " @Deprecated\n" +
+ " public static void callMe() {}\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " Y.callMe();\n" +
+ " ^^^^^^^^\n" +
+ "The method callMe() from the type Y is deprecated\n" +
+ "----------\n",
+ null,
+ true,
+ options);
+}
+public static Class testClass() {
+ return Deprecated18Test.class;
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
index 3b3a5ab..ed6a69d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
@@ -5,12 +5,17 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contributions for
* Bug 365519 - editorial cleanup after bug 186342 and bug 365387
* Bug 265744 - Enum switch should warn about missing default
* Bug 374605 - Unreasonable warning for enum-based switch statements
+ * bug 388739 - [1.8][compiler] consider default methods when detecting whether a class needs to be declared abstract
* Bug 395681 - [compiler] Improve simulation of javac6 behavior from bug 317719 after fixing bug 388795
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExpressionContextTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExpressionContextTests.java
new file mode 100644
index 0000000..fc8d1bb
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExpressionContextTests.java
@@ -0,0 +1,663 @@
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jesper S Moller - realigned with bug 399695
+ *******************************************************************************/
+
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.util.Map;
+
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import junit.framework.Test;
+
+public class ExpressionContextTests extends AbstractRegressionTest {
+
+static {
+ // TESTS_NAMES = new String[] { "test380112e"};
+ // TESTS_NUMBERS = new int[] { 50 };
+ // TESTS_RANGE = new int[] { 11, -1 };
+}
+
+public ExpressionContextTests(String name) {
+ super(name);
+}
+
+public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+}
+
+protected Map getCompilerOptions() {
+ Map defaultOptions = super.getCompilerOptions();
+ defaultOptions.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.WARNING);
+ defaultOptions.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
+ defaultOptions.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.WARNING);
+ return defaultOptions;
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test001() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " Object o = () -> {};\n" +
+ " Object p = (I) () -> {};\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " Object o = () -> {};\n" +
+ " ^^^^^^^^\n" +
+ "The target type of this expression must be a functional interface\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test002() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "interface J {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " Object p = (I & J) () -> {};\n" +
+ "}\n" ,
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " Object p = (I & J) () -> {};\n" +
+ " ^^^^^^^^\n" +
+ "The target type of this expression is not a functional interface: more than one of the intersecting interfaces are functional\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test003() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "interface J {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " Object p = (int & I & J) () -> {};\n" +
+ "}\n" ,
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " Object p = (int & I & J) () -> {};\n" +
+ " ^^^\n" +
+ "Base types are not allowed in intersection cast operator\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " Object p = (int & I & J) () -> {};\n" +
+ " ^^^^^^^^\n" +
+ "The target type of this expression must be a functional interface\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test004() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "interface J {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " Object p = (X[] & Serializable & Cloneable) new X[0];\n" +
+ "}\n" ,
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " Object p = (X[] & Serializable & Cloneable) new X[0];\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Arrays are not allowed in intersection cast operator\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " Object p = (X[] & Serializable & Cloneable) new X[0];\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Serializable cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test005() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "interface J {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " Object p = (I & X) () -> {};\n" +
+ "}\n" ,
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " Object p = (I & X) () -> {};\n" +
+ " ^\n" +
+ "The type X is not an interface; it cannot be specified as a bounded parameter\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " Object p = (I & X) () -> {};\n" +
+ " ^^^^^^^^\n" +
+ "The target type of this expression must be a functional interface\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test006() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "interface J {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " Object p = (I & J & I) () -> {};\n" +
+ "}\n" ,
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " Object p = (I & J & I) () -> {};\n" +
+ " ^\n" +
+ "Duplicate type in intersection cast operator\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " Object p = (I & J & I) () -> {};\n" +
+ " ^^^^^^^^\n" +
+ "The target type of this expression must be a functional interface\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test007() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.List;\n" +
+ "interface I<T> {\n" +
+ " void doit(List<T> x);\n" +
+ " default void doitalso () {}\n" +
+ " boolean equals(Object o);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I<String> i = (List<String> p) -> {};\n" +
+ " I<X> i2 = (List<String> p) -> {};\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " I<X> i2 = (List<String> p) -> {};\n" +
+ " ^^^^\n" +
+ "Lambda expression\'s parameter p is expected to be of type List<X>\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test008() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "interface J {\n" +
+ " void doit();\n" +
+ " default void doitalso () {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " Object p = (@Marker java.lang. @Readonly String & I & J) () -> {};\n" +
+ "}\n" ,
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " Object p = (@Marker java.lang. @Readonly String & I & J) () -> {};\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " Object p = (@Marker java.lang. @Readonly String & I & J) () -> {};\n" +
+ " ^^^^^^^^\n" +
+ "Readonly cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 10)\n" +
+ " Object p = (@Marker java.lang. @Readonly String & I & J) () -> {};\n" +
+ " ^^^^^^^^\n" +
+ "The target type of this expression is not a functional interface: more than one of the intersecting interfaces are functional\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test009() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.List;\n" +
+ "import java.util.Map;\n" +
+ "interface I<T> {\n" +
+ " void doit(List<T> x);\n" +
+ " boolean equals(Object o);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I<String> i = (List<String> p) -> {};\n" +
+ " I<X> i2 = (Map<String, String> & I<X>) null;\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 9)\n" +
+ " I<X> i2 = (Map<String, String> & I<X>) null;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Unnecessary cast from null to Map<String,String> & I<X>\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test010() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.List;\n" +
+ "import java.util.Map;\n" +
+ "interface I<T> {\n" +
+ " void doit(List<T> x);\n" +
+ " boolean equals(Object o);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I<String> i = (List<String> p) -> {};\n" +
+ " I<X> i2 = (Map<String, String>.Entry & I<X> & Serializable) null;\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " I<X> i2 = (Map<String, String>.Entry & I<X> & Serializable) null;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The member type Map<String,String>.Entry cannot be qualified with a parameterized type, since it is static. Remove arguments from qualifying type Map<String,String>\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " I<X> i2 = (Map<String, String>.Entry & I<X> & Serializable) null;\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Serializable cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test011() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ "}\n" +
+ "interface J {\n" +
+ "}\n" +
+ "interface K {\n" +
+ "}\n" +
+ "public class X {\n" +
+ " X X = (X & J & K) new Y();\n" +
+ "}\n" +
+ "class Y {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " X X = (X & J & K) new Y();\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "Cannot cast from Y to X & J & K\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test012() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ "}\n" +
+ "interface J {\n" +
+ "}\n" +
+ "interface K {\n" +
+ "}\n" +
+ "public class X {\n" +
+ " X X = (X & J & K) new Y();\n" +
+ "}\n" +
+ "class Y extends X implements Zork {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 8)\n" +
+ " X X = (X & J & K) new Y();\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "Unnecessary cast from Y to X & J & K\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " class Y extends X implements Zork {\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test013() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ "}\n" +
+ "interface J {\n" +
+ "}\n" +
+ "interface K {\n" +
+ "}\n" +
+ "public class X {\n" +
+ " X X = (X & J & K) new Y();\n" +
+ "}\n" +
+ "final class Y extends X {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " X X = (X & J & K) new Y();\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "Cannot cast from Y to X & J & K\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 8)\n" +
+ " X X = (X & J & K) new Y();\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "Unnecessary cast from Y to X & J & K\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test014() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ "}\n" +
+ "interface J {\n" +
+ "}\n" +
+ "interface K {\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I i = null;\n" +
+ " X X = (X & J & K) i;\n" +
+ "}\n" +
+ "final class Y extends P {\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 11)\n" +
+ " final class Y extends P {\n" +
+ " ^\n" +
+ "P cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test015() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ "}\n" +
+ "interface J {\n" +
+ "}\n" +
+ "interface K {\n" +
+ "}\n" +
+ "final public class X {\n" +
+ " I i = null;\n" +
+ " X X = (X & J & K) i;\n" +
+ " Zork z;\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " X X = (X & J & K) i;\n" +
+ " ^^^^^^^^^^^^^\n" +
+ "Cannot cast from I to X & J & K\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test016() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ "}\n" +
+ "interface J {\n" +
+ "}\n" +
+ "interface K {\n" +
+ "}\n" +
+ "final public class X implements I {\n" +
+ " I i = null;\n" +
+ " X X = (X & J & K) i;\n" +
+ " Zork z;\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399773, [1.8][compiler] Cast expression should allow for additional bounds to form intersection types
+public void test017() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ "}\n" +
+ "interface J {\n" +
+ "}\n" +
+ "interface K {\n" +
+ "}\n" +
+ "public class X {\n" +
+ " I i = null;\n" +
+ " X X = (X & J & K) (X & K & J) i;\n" +
+ " Zork z;\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 9)\n" +
+ " X X = (X & J & K) (X & K & J) i;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Unnecessary cast from X & K & J to X & J & K\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 10)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399778, [1.8][compiler] Conditional operator expressions should propagate target types
+public void test018() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ "}\n" +
+ "class X {\n" +
+ " Object o = (I) () -> {};\n" +
+ " I k = (()->{});\n" +
+ " I i = 1 == 2 ? () -> {} : () -> {};\n" +
+ " I j = () -> {};\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 7)\n" +
+ " I i = 1 == 2 ? () -> {} : () -> {};\n" +
+ " ^^^^^^^^\n" +
+ "Dead code\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399778, [1.8][compiler] Conditional operator expressions should propagate target types
+public void test019() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ "}\n" +
+ "class X {\n" +
+ " I [] k = {(()->{}), ()->{}, 1 == 2 ? () -> {} : ()->{}};\n" +
+ " I [][] i = {{()->{}}};\n" +
+ " void foo() {\n" +
+ " I i = () -> {};\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 5)\n" +
+ " I [] k = {(()->{}), ()->{}, 1 == 2 ? () -> {} : ()->{}};\n" +
+ " ^^^^^^^^\n" +
+ "Dead code\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 8)\n" +
+ " I i = () -> {};\n" +
+ " ^\n" +
+ "The local variable i is hiding a field from type X\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399778, [1.8][compiler] Conditional operator expressions should propagate target types
+public void test020() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " J doit(int x);\n" +
+ "}\n" +
+ "interface J {\n" +
+ " K doit();\n" +
+ "}\n" +
+ "interface K {\n" +
+ " I doit();\n" +
+ "}" +
+ "class X {\n" +
+ " I foo() {\n" +
+ " return x -> { return () -> () -> \"Hello\"; };\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 11)\n" +
+ " return x -> { return () -> () -> \"Hello\"; };\n" +
+ " ^^^^^^^\n" +
+ "Type mismatch: cannot convert from String to I\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=399778, [1.8][compiler] Conditional operator expressions should propagate target types
+public void test021() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void doit();\n" +
+ "}\n" +
+ "class X {\n" +
+ " I foo() {\n" +
+ " return \"Hello\" + () -> {};\n" +
+ " }\n" +
+ " I goo() {\n" +
+ " return \"Hello\" + (I)(() -> {});\n" +
+ " }\n" +
+ " I zoo() {\n" +
+ " return 10 + (() -> {});\n" +
+ " }\n" +
+ " I boo() {\n" +
+ " return 10 + (I) (() -> {});\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " return \"Hello\" + () -> {};\n" +
+ " ^^^^^^^^\n" +
+ "The target type of this expression must be a functional interface\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " return \"Hello\" + (I)(() -> {});\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from String to I\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 9)\n" +
+ " return \"Hello\" + (I)(() -> {});\n" +
+ " ^^^^^^^^^^^^^\n" +
+ "Unnecessary cast from I to I\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 12)\n" +
+ " return 10 + (() -> {});\n" +
+ " ^^^^^^^^^^\n" +
+ "The target type of this expression must be a functional interface\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 15)\n" +
+ " return 10 + (I) (() -> {});\n" +
+ " ^^^^^^^^^^^^^^^^^^^\n" +
+ "The operator + is undefined for the argument type(s) int, I\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=401222, [1.8][compiler] Conditional operator expressions results differ from 8b76
+public void test022() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.Arrays;\n" +
+ "import java.util.List;\n" +
+ "class X {\n" +
+ " int foo(int x) {\n" +
+ " List<String> l = x == 2 ? (List<String>)(null) : 1;\n" +
+ " List<String> m = x == 2 ? 1 : (List<String>)(null);\n" +
+ " return 1;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " List<String> l = x == 2 ? (List<String>)(null) : 1;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from Object to List<String>\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " List<String> m = x == 2 ? 1 : (List<String>)(null);\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from Object to List<String>\n" +
+ "----------\n");
+}
+public static Class testClass() {
+ return ExpressionContextTests.class;
+}
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest8.java
new file mode 100644
index 0000000..f50670f
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest8.java
@@ -0,0 +1,410 @@
+/*******************************************************************************
+ * Copyright (c) 2013 GK Software AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * Stephan Herrmann - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.core.JavaCore;
+
+public class FlowAnalysisTest8 extends AbstractNullAnnotationTest {
+
+//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[] { "testReferenceExpression" };
+// TESTS_NUMBERS = new int[] { 561 };
+// TESTS_RANGE = new int[] { 1, 2049 };
+}
+
+public FlowAnalysisTest8(String name) {
+ super(name);
+}
+
+public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+}
+
+public static Class testClass() {
+ return FlowAnalysisTest8.class;
+}
+
+// Lambda with elided args inherits null contract from the super method
+public void testLambda_01() {
+ Map customOptions = getCompilerOptions();
+ runNegativeTestWithLibs(
+ new String[] {
+ "ISAM.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public interface ISAM {\n" +
+ " @NonNull String toString(@NonNull String prefix, @Nullable Object o);\n" +
+ "}\n",
+ "X.java",
+ "public class X {\n" +
+ " void test() {\n" +
+ " ISAM printer = (p,o) -> p.concat(o.toString());\n" +
+ " }\n" +
+ "}\n"
+ },
+ customOptions,
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " ISAM printer = (p,o) -> p.concat(o.toString());\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Null type safety (type annotations): The expression of type 'String' needs unchecked conversion to conform to \'@NonNull String\'\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " ISAM printer = (p,o) -> p.concat(o.toString());\n" +
+ " ^\n" +
+ "Potential null pointer access: this expression has a '@Nullable' type\n" +
+ "----------\n");
+}
+
+// Lambda with declared args violates null contract of super
+public void testLambda_02() {
+ Map customOptions = getCompilerOptions();
+ runNegativeTestWithLibs(
+ new String[] {
+ "ISAM.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public interface ISAM {\n" +
+ " void process(@NonNull Object nn, @Nullable Object n, Object u);\n" +
+ "}\n",
+ "X.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public class X {\n" +
+ " void test() {\n" +
+ // try to override, illegal except for unchanged o1:
+ " ISAM printer = (@NonNull Object o1, @NonNull Object o2, @NonNull Object o3) -> System.out.println(2);\n" +
+ " }\n" +
+ "}\n"
+ },
+ customOptions,
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " ISAM printer = (@NonNull Object o1, @NonNull Object o2, @NonNull Object o3) -> System.out.println(2);\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Illegal redefinition of parameter o2, inherited method from ISAM declares this parameter as @Nullable\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " ISAM printer = (@NonNull Object o1, @NonNull Object o2, @NonNull Object o3) -> System.out.println(2);\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Illegal redefinition of parameter o3, inherited method from ISAM does not constrain this parameter\n" +
+ "----------\n");
+}
+
+// Lambda with declared args inherits / modifies contract of super
+public void testLambda_03() {
+ Map customOptions = getCompilerOptions();
+ runNegativeTestWithLibs(
+ new String[] {
+ "ISAM.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public interface ISAM {\n" +
+ " void process(@NonNull Object nn, @Nullable Object n, Object u);\n" +
+ "}\n",
+ "X.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public class X {\n" +
+ " void test() {\n" +
+ // fill-in all from super:
+ " ISAM printer1 = (Object o1, Object o2, Object o3) \n" +
+ " -> System.out.println(o1.toString()+o2.toString()+o3.toString());\n" +
+ // legal overrides: (however, @NonNull -> @Nullable is probably nonsense)
+ " ISAM printer3 = (@Nullable Object o1, @Nullable Object o2, @Nullable Object o3) \n" +
+ " -> System.out.println(o1.toString()+o2.toString()+o3.toString());\n" +
+ " }\n" +
+ "}\n"
+ },
+ customOptions,
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " -> System.out.println(o1.toString()+o2.toString()+o3.toString());\n" +
+ " ^^\n" +
+ "Potential null pointer access: The variable o2 may be null at this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 7)\n" +
+ " -> System.out.println(o1.toString()+o2.toString()+o3.toString());\n" +
+ " ^^\n" +
+ "Potential null pointer access: this expression has a '@Nullable' type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 7)\n" +
+ " -> System.out.println(o1.toString()+o2.toString()+o3.toString());\n" +
+ " ^^\n" +
+ "Potential null pointer access: this expression has a '@Nullable' type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 7)\n" +
+ " -> System.out.println(o1.toString()+o2.toString()+o3.toString());\n" +
+ " ^^\n" +
+ "Potential null pointer access: this expression has a '@Nullable' type\n" +
+ "----------\n");
+}
+
+// Lambda with declared args has illegal @NonNull an primitive argument
+public void testLambda_04() {
+ Map customOptions = getCompilerOptions();
+ runNegativeTestWithLibs(
+ new String[] {
+ "ISAM.java",
+ "public interface ISAM {\n" +
+ " void process(int i);\n" +
+ "}\n",
+ "X.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public class X {\n" +
+ " void test() {\n" +
+ " ISAM printer1 = (@NonNull int i) \n" +
+ " -> System.out.println(i);\n" +
+ " }\n" +
+ "}\n"
+ },
+ customOptions,
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " ISAM printer1 = (@NonNull int i) \n" +
+ " ^^^^^^^^\n" +
+ "The nullness annotation @NonNull is not applicable for the primitive type int\n" +
+ "----------\n");
+}
+
+// Lambda inherits null contract and has block with return statement
+public void testLambda_05() {
+ Map customOptions = getCompilerOptions();
+ runNegativeTestWithLibs(
+ new String[] {
+ "ISAM.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public interface ISAM {\n" +
+ " @NonNull String toString(Object o);\n" +
+ "}\n",
+ "X.java",
+ "public class X {\n" +
+ " void test() {\n" +
+ " ISAM printer = (o) -> {\n" +
+ " System.out.print(13);\n" +
+ " return null; // error\n" +
+ " };\n" +
+ " }\n" +
+ "}\n"
+ },
+ customOptions,
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " return null; // error\n" +
+ " ^^^^\n" +
+ "Null type mismatch: required \'@NonNull String\' but the provided value is null\n" +
+ "----------\n");
+}
+// Lambda has no descriptor (overriding method from Object), don't bail out with NPE during analysis
+public void testLambda_05a() {
+ Map customOptions = getCompilerOptions();
+ runNegativeTestWithLibs(
+ new String[] {
+ "ISAM.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public interface ISAM {\n" +
+ " @NonNull String toString();\n" +
+ "}\n",
+ "X.java",
+ "public class X {\n" +
+ " void test() {\n" +
+ " ISAM printer = () -> {\n" +
+ " System.out.print(13);\n" +
+ " return null;\n" +
+ " };\n" +
+ " }\n" +
+ "}\n"
+ },
+ customOptions,
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " ISAM printer = () -> {\n" +
+ " System.out.print(13);\n" +
+ " return null;\n" +
+ " };\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The target type of this expression must be a functional interface\n" +
+ "----------\n");
+}
+// Test flows with ReferenceExpression regarding:
+// - definite assignment
+// - unused local
+public void testReferenceExpression1() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR);
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "public interface I {\n" +
+ " public void bar();\n" +
+ "}\n",
+ "X.java",
+ "public class X {\n" +
+ " public void moo() {}\n" +
+ " public static void soo() {}\n" +
+ " void testAssignment() {\n" +
+ " X x;\n" +
+ " I i = x::moo; // x is unassigned\n" +
+ " i.bar();\n" +
+ " I i2 = X::soo;\n" + // OK
+ " }\n" +
+ " void testStatic() {\n" +
+ " X xs;\n" +
+ " I is = xs::soo;\n" +
+ " }\n" +
+ " void testUse() {\n" +
+ " X x1 = this, x2 = this; // x2 is not used, only x is\n" +
+ " I i = x1::moo;\n" +
+ " i.bar();\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " I i = x::moo; // x is unassigned\n" +
+ " ^\n" +
+ "The local variable x may not have been initialized\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 12)\n" +
+ " I is = xs::soo;\n" +
+ " ^^^^^^^\n" +
+ "The method soo() from the type X should be accessed in a static way \n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 15)\n" +
+ " X x1 = this, x2 = this; // x2 is not used, only x is\n" +
+ " ^^\n" +
+ "The value of the local variable x2 is not used\n" +
+ "----------\n",
+ null/*libs*/, true/*flush*/, options);
+}
+public void testReferenceExpression_null_1() {
+ Map options = getCompilerOptions();
+ options.put(JavaCore.COMPILER_PB_NULL_REFERENCE, JavaCore.ERROR);
+ runNegativeTest(
+ new String[] {
+ "I.java",
+ "public interface I {\n" +
+ " public void foo();\n" +
+ "}\n",
+ "X.java",
+ "public class X {\n" +
+ " public void bar() {}\n" +
+ " void test() {\n" +
+ " X x = null;\n" +
+ " I i = x::bar;\n" +
+ " i.foo();\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " I i = x::bar;\n" +
+ " ^\n" +
+ "Null pointer access: The variable x can only be null at this location\n" +
+ "----------\n",
+ null/*libs*/, true/*flush*/, options);
+}
+public void testReferenceExpression_nullAnnotation_1() {
+ runNegativeTestWithLibs(
+ new String[] {
+ "I.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public interface I {\n" +
+ " public @NonNull String foo(@Nullable Object s);\n" +
+ "}\n",
+ "X.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public class X {\n" +
+ " public @Nullable String bar(@NonNull Object s) { return s.toString(); }\n" +
+ " void test() {\n" +
+ " I i = this::bar;\n" +
+ " System.out.print(i.foo(null));\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " I i = this::bar;\n" +
+ " ^^^^^^^^^\n" +
+ "Null type mismatch at parameter 1: required '@NonNull Object' but provided '@Nullable Object' via method descriptor I.foo(Object)\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 5)\n" +
+ " I i = this::bar;\n" +
+ " ^^^^^^^^^\n" +
+ "Null type mismatch at method return type: Method descriptor I.foo(Object) promises '@NonNull String' but referenced method provides '@Nullable String'\n" +
+ "----------\n");
+}
+public void testReferenceExpression_nullAnnotation_2() {
+ runNegativeTestWithLibs(
+ new String[] {
+ "I.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public interface I {\n" +
+ " public @NonNull String foo(@Nullable Object s);\n" +
+ "}\n",
+ "X.java",
+ "public class X {\n" +
+ " public String bar(Object s) { return s.toString(); }\n" +
+ " void test() {\n" +
+ " I i = this::bar;\n" +
+ " System.out.print(i.foo(null));\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " I i = this::bar;\n" +
+ " ^^^^^^^^^\n" +
+ "Null type mismatch at parameter 1: required \'Object\' but provided \'@Nullable Object\' via method descriptor I.foo(Object)\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 4)\n" +
+ " I i = this::bar;\n" +
+ " ^^^^^^^^^\n" +
+ "Null type safety at method return type: Method descriptor I.foo(Object) promises \'@NonNull String\' but referenced method provides \'String\'\n" +
+ "----------\n");
+}
+public void testReferenceExpression_nullAnnotation_3() {
+ runNegativeTestWithLibs(
+ new String[] {
+ "I.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public interface I {\n" +
+ " public @NonNull String foo(Object s);\n" +
+ "}\n",
+ "X.java",
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public class X {\n" +
+ " public @NonNull String bar(@NonNull Object s) { return \"\"; }\n" +
+ " void test() {\n" +
+ " I i = this::bar;\n" +
+ " System.out.print(i.foo(null));\n" +
+ " }\n" +
+ " Zork zork;\n" + // make warning visible by forcing an error
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 5)\n" +
+ " I i = this::bar;\n" +
+ " ^^^^^^^^^\n" +
+ "Null type safety: parameter 1 provided via method descriptor I.foo(Object) needs unchecked conversion to conform to '@NonNull Object'\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " Zork zork;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
index 78c5e7e..f78b826 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
@@ -4,11 +4,16 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
* Stephan Herrmann - Contribution for
* bug 393719 - [compiler] inconsistent warnings on iteration variables
+ * Bug 388800 - [1.8] adjust tests to 1.8 JRE
* Jesper S Moller - Contribution for
* bug 401853 - Eclipse Java compiler creates invalid bytecode (java.lang.VerifyError)
*******************************************************************************/
@@ -1105,6 +1110,7 @@
" public Iterator<String> iterator() {\n" +
" return null;\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}\n",
},
"----------\n" +
@@ -1627,11 +1633,13 @@
" }\n" +
" public void remove() {\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "T") +
"}\n" +
"class Bar implements Iterable<String> {\n" +
" public Iterator<String> iterator() {\n" +
" return new ArrayIterator<String>(new String[]{\"a\",\"b\"});\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}\n",
},
"ab");
@@ -1720,6 +1728,7 @@
" }\n" +
" public void remove() {\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "T") +
"}\n" +
"interface IFoo extends Iterable<String> {\n" +
"}\n" +
@@ -1727,6 +1736,7 @@
" public Iterator<String> iterator() {\n" +
" return new ArrayIterator<String>(new String[]{\"a\",\"b\"});\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}\n",
},
"ab");
@@ -1802,6 +1812,7 @@
" X x = new X();\n" +
" x.foo(x);\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
"}",
},
"ab");
@@ -2015,6 +2026,7 @@
" System.out.println(\"remove\");\n" +
" this.iterator.remove();\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "T") +
" }\n" +
" \n" +
" static Set<Object> initForEach() {\n" +
@@ -2111,6 +2123,7 @@
" System.out.println(\"remove\");\n" +
" this.iterator.remove();\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "T") +
" }\n" +
" \n" +
" static Set<Object> initForEach() {\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
index 0e046cc..333daf1 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,12 +5,19 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Technical University Berlin - adapted for Object Teams
* Stephan Herrmann - Contributions for
* bug 383690 - [compiler] location of error re uninitialized final field should be aligned
+ * bug 388800 - [1.8] adjust tests to 1.8 JRE
* bug 388795 - [compiler] detection of name clash depends on order of super interfaces
+ * bug 388739 - [1.8][compiler] consider default methods when detecting whether a class needs to be declared abstract
* bug 395681 - [compiler] Improve simulation of javac6 behavior from bug 317719 after fixing bug 388795
* bug 406928 - computation of inherited methods seems damaged (affecting @Overrides)
*******************************************************************************/
@@ -1626,42 +1633,41 @@
"}\n"
},
"----------\n" +
- "1. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^\n" +
- "Syntax error on token \"int\", Dimensions expected after this token\n" +
- "----------\n" +
- "2. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^^\n" +
- "Syntax error on token \"short\", Dimensions expected after this token\n" +
- "----------\n" +
- "3. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^\n" +
- "Syntax error on token \"long\", Dimensions expected after this token\n" +
- "----------\n" +
- "4. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^^\n" +
- "Syntax error on token \"float\", Dimensions expected after this token\n" +
- "----------\n" +
- "5. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^^^\n" +
- "Syntax error on token \"double\", Dimensions expected after this token\n" +
- "----------\n" +
- "6. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^^^^\n" +
- "Syntax error on token \"boolean\", Dimensions expected after this token\n" +
- "----------\n" +
- "7. ERROR in test\\X.java (at line 7)\n" +
- " X<int, short, long, float, double, boolean, char> x;\n" +
- " ^^^^\n" +
- "Syntax error on token \"char\", Dimensions expected after this token\n" +
- "----------\n"
- );
+ "1. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "2. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "3. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "4. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "5. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "6. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete TypeArgument\n" +
+ "----------\n" +
+ "7. ERROR in test\\X.java (at line 7)\n" +
+ " X<int, short, long, float, double, boolean, char> x;\n" +
+ " ^^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete ReferenceType\n" +
+ "----------\n");
}
// JSR14-v10[2.1,2.2]: Valid multiple parameter types: primitive type arrays
public void test0062() {
@@ -1873,7 +1879,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",
@@ -1945,8 +1951,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"
);
}
@@ -2318,7 +2330,7 @@
);
}
// TODO (david) remove errors: insert dimension to complete array type
- public void test0080() {
+ public void _test0080() {
this.runNegativeTest(
new String[] {
"test/X.java",
@@ -2405,7 +2417,7 @@
);
}
// TODO (david) remove error: insert dimension to complete array type
- public void test0083() {
+ public void _test0083() {
this.runNegativeTest(
new String[] {
"test/X.java",
@@ -2947,12 +2959,13 @@
"class AX<P> {\n" +
"}\n",
},
- "----------\n" +
- "1. ERROR in X.java (at line 1)\n" +
- " public class X <T extends AX<? super int>> {\n" +
- " ^^^\n" +
- "Syntax error on token \"int\", Dimensions expected after this token\n" +
- "----------\n");
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X <T extends AX<? super int>> {\n" +
+ " ^^^\n" +
+ "Syntax error, insert \"Dimensions\" to complete ArrayType\n" +
+ "----------\n"
+);
}
// type parameterized with wildcard cannot appear in allocation
@@ -4432,6 +4445,8 @@
" }\n" +
" public int size() { return 0; }\n" +
" public Object get(int index) { return null; }\n" +
+ ITERABLE_RAW_IMPL_JRE8 +
+ COLLECTION_AND_LIST_RAW_IMPL_JRE8 +
"}\n"
},
"SUCCESS");
@@ -6141,6 +6156,7 @@
" public int compare(X x1, X x2) {\n" +
" return comparator.compare(function.eval(x1),function.eval(x2));\n" +
" }\n" +
+ COMPARATOR_RAW_IMPL_JRE8 +
"}\n",
},
"");
@@ -6717,7 +6733,7 @@
"2. WARNING in X.java (at line 13)\n" +
" } catch (T t) {\n" +
" ^\n" +
- "The parameter t is hiding another local variable defined in an enclosing type scope\n" +
+ "The parameter t is hiding another local variable defined in an enclosing scope\n" +
"----------\n" +
"3. WARNING in X.java (at line 19)\n" +
" class EX extends Exception {\n" +
@@ -8841,6 +8857,7 @@
" public Set<Map.Entry<String, V>> entrySet() {\n" +
" return this.backingMap.entrySet();\n" +
" }\n" +
+ MAP_IMPL_JRE8.replaceAll("\\*", "String").replaceAll("\\%", "V")+
"}\n",
},
"----------\n" +
@@ -10800,9 +10817,12 @@
" public boolean hasNext() {return false;}\n" +
" public Entry<String, Integer> next() {return null;}\n" +
" public void remove() {} \n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "Entry<String,Integer>") +
" };\n" +
" }\n" +
" public int size() {return 0;}\n" +
+ COLLECTION_RAW_IMPL_JRE8 +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "Entry<String,Integer>") +
"}"
}
);
@@ -11374,6 +11394,8 @@
" }\n" +
" public Iterator<Runnable> iterator() {return null;}\n" +
" public int size() {return 0;}\n" +
+ COLLECTION_RAW_IMPL_JRE8 +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "Runnable") +
"}"
}
);
@@ -13553,6 +13575,7 @@
" public boolean hasNext() { return false; }\n" +
" public String next() { return null; }\n" +
" public void remove() {}\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "String") +
"}\n",
},
"");
@@ -19890,6 +19913,7 @@
" }\n" +
" public void remove() {\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "U") +
" }\n" +
" }\n" +
"}\n",
@@ -24900,6 +24924,8 @@
" List<String> list = new AbstractList<String>() {\n" +
" @Override public int size() { return 0; }\n" +
" @Override public String get(int i) { return args.get(i); }\n" +
+ COLLECTION_AND_LIST_IMPL_JRE8.replaceAll("\\*", "String") +
+ ITERABLE_IMPL_JRE8.replaceAll("\\*", "String") +
" };\n" +
" }\n" +
" }\n" +
@@ -24911,13 +24937,14 @@
},
"SUCCESS");
+ String constantPoolIdx = IS_JRE_8 ? "73" : "36"; // depends on whether or not stubs for JRE8 default methods are included
String expectedOutput =
" // Method descriptor #31 (I)Ljava/lang/Object;\n" +
" // Stack: 2, Locals: 2\n" +
" public bridge synthetic java.lang.Object get(int arg0);\n" +
" 0 aload_0 [this]\n" +
" 1 iload_1 [arg0]\n" +
- " 2 invokevirtual X$Entry$1.get(int) : java.lang.String [36]\n" +
+ " 2 invokevirtual X$Entry$1.get(int) : java.lang.String ["+constantPoolIdx+"]\n" +
" 5 areturn\n" +
" Line numbers:\n" +
" [pc: 0, line: 1]\n";
@@ -25864,6 +25891,7 @@
" }\n" +
" public void remove() {\n" +
" }\n" +
+ ITERATOR_IMPL_JRE8.replaceAll("\\*", "N") +
"}\n" +
"interface Set3<N extends Node> extends Iterable<N> {\n" +
" SetIterator<N> iterator();\n" +
@@ -25895,27 +25923,27 @@
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 21)\n" +
+ "1. WARNING in X.java (at line 23)\n" +
" void f1(Set1 s) {\n" +
" ^^^^\n" +
"Set1 is a raw type. References to generic type Set1<N> should be parameterized\n" +
"----------\n" +
- "2. ERROR in X.java (at line 22)\n" +
+ "2. ERROR in X.java (at line 24)\n" +
" Node n_ = s.iterator().next();\n" +
" ^^^^^^^^^^^^^^^^^^^\n" +
"Type mismatch: cannot convert from Object to Node\n" +
"----------\n" +
- "3. ERROR in X.java (at line 25)\n" +
+ "3. ERROR in X.java (at line 27)\n" +
" for (Node n : s) {\n" +
" ^\n" +
"Type mismatch: cannot convert from element type Object to Node\n" +
"----------\n" +
- "4. WARNING in X.java (at line 35)\n" +
+ "4. WARNING in X.java (at line 37)\n" +
" void f3(Set3 s) {\n" +
" ^^^^\n" +
"Set3 is a raw type. References to generic type Set3<N> should be parameterized\n" +
"----------\n" +
- "5. ERROR in X.java (at line 38)\n" +
+ "5. ERROR in X.java (at line 40)\n" +
" for (Node n : s) {\n" +
" ^\n" +
"Type mismatch: cannot convert from element type Object to Node\n" +
@@ -28019,6 +28047,8 @@
" // TODO Auto-generated method stub\n" +
" \n" +
" }" +
+ COLLECTION_RAW_IMPL_JRE8 +
+ ITERABLE_RAW_IMPL_JRE8 +
"}",
},
"",
@@ -30421,7 +30451,7 @@
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=119238 - variation
-public void test0932() {
+public void _test0932() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -32459,28 +32489,18 @@
public void test0987() {
String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6
? "----------\n" +
- "1. ERROR in X.java (at line 7)\n" +
- " abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" +
- " ^^^^^^^^^^^^^^^^\n" +
- "The return types are incompatible for the inherited methods EditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 11)\n" +
+ "1. ERROR in X.java (at line 11)\n" +
" public ISheetViewer getViewer() { return null; } \n" +
" ^^^^^^^^^^^^\n" +
"The return type is incompatible with EditPart.getViewer()\n" +
"----------\n" +
- "3. ERROR in X.java (at line 11)\n" +
+ "2. ERROR in X.java (at line 11)\n" +
" public ISheetViewer getViewer() { return null; } \n" +
" ^^^^^^^^^^^\n" +
"The method getViewer() of type AbstractLinkView<M> must override a superclass method\n" +
"----------\n"
: "----------\n" +
- "1. ERROR in X.java (at line 7)\n" +
- " abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" +
- " ^^^^^^^^^^^^^^^^\n" +
- "The return types are incompatible for the inherited methods EditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 11)\n" +
+ "1. ERROR in X.java (at line 11)\n" +
" public ISheetViewer getViewer() { return null; } \n" +
" ^^^^^^^^^^^^\n" +
"The return type is incompatible with EditPart.getViewer()\n" +
@@ -32568,13 +32588,8 @@
" public ISheetViewer getViewer();\n" +
"}", // =================
},
- "----------\n" +
- "1. ERROR in X.java (at line 7)\n" +
- " abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" +
- " ^^^^^^^^^^^^^^^^\n" +
- "The return types are incompatible for the inherited methods ILinkViewElement.getViewer(), EditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 11)\n" +
+ "----------\n" +
+ "1. ERROR in X.java (at line 11)\n" +
" public SheetViewer getViewer() { return null; } \n" +
" ^^^^^^^^^^^\n" +
"The return type is incompatible with AbstractEditPart.getViewer()\n" +
@@ -34171,6 +34186,7 @@
" public Iterator<W> iterator() {\n" +
" return theList.iterator();\n" +
" }\n" +
+ ITERABLE_IMPL_JRE8.replace('*', 'W') +
" }\n" +
"\n" +
" private PointList<Waypoint> waypoints = new PointList<Waypoint>();\n" +
@@ -34415,6 +34431,7 @@
"public int compare(T obj1, T obj2) {\n" +
" return obj1.compareTo(obj2);\n" +
"}\n" +
+ COMPARATOR_IMPL_JRE8.replace('*', 'T').replace('%', 'U').replace('$', 'S') +
"}\n" +
"\n" +
"@SuppressWarnings({\"unchecked\", \"rawtypes\"})\n" +
@@ -34465,6 +34482,7 @@
"public int compare(V obj1, V obj2) {\n" +
" return 0;\n" +
"}\n" +
+ COMPARATOR_IMPL_JRE8.replace('*', 'V').replace('%', 'U').replace('$', 'S') +
"}", // =================
},
@@ -37135,7 +37153,7 @@
"2. WARNING in X.java (at line 5)\n" +
" T t = t;\n" +
" ^\n" +
- "The field T.t is hiding another local variable defined in an enclosing type scope\n" +
+ "The field T.t is hiding another local variable defined in an enclosing scope\n" +
"----------\n" +
"3. ERROR in X.java (at line 5)\n" +
" T t = t;\n" +
@@ -37459,7 +37477,7 @@
null/* do not perform statements recovery */);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=168232
-public void test1097() {
+public void _test1097() {
runNegativeTest(
// test directory preparation
new String[] { /* test files */
@@ -37845,12 +37863,19 @@
" }\n" +
"}\n",
},
+ this.complianceLevel < ClassFileConstants.JDK1_8 ?
"----------\n" +
"1. ERROR in X.java (at line 4)\n" +
" return true ? Z.bar() : null;\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
"Type mismatch: cannot convert from Y<Object> to Y<String>\n" +
- "----------\n");
+ "----------\n" :
+ "----------\n" +
+ "1. WARNING in X.java (at line 4)\n" +
+ " return true ? Z.bar() : null;\n" +
+ " ^^^^\n" +
+ "Dead code\n" +
+ "----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=176591
//variant
@@ -48351,12 +48376,6 @@
"2. ERROR in A.java (at line 3)\n" +
" Class<?> c = A<?>.class; \n" +
" ^^^\n" +
- "Syntax error on token(s), misplaced construct(s)\n" +
- "----------\n" +
- "3. ERROR in A.java (at line 3)\n" +
- " Class<?> c = A<?>.class; \n" +
- " ^^^^^\n" +
- "Syntax error, insert \")\" to complete Expression\n" +
:giro */
" ^\n" +
"Syntax error on token \"?\", invalid typeAnchor\n" +
@@ -49727,6 +49746,7 @@
" public boolean hasNext() {\n" +
" return false;\n" +
" }\n" +
+ ITERATOR_RAW_IMPL_JRE8 +
" };\n" +
" }\n" +
" Zork z;\n" +
@@ -49758,7 +49778,7 @@
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Unnecessary cast from Iterator to Iterator<String>\n" +
"----------\n" +
- "6. ERROR in X.java (at line 36)\n" +
+ "6. ERROR in X.java (at line 38)\n" +
" Zork z;\n" +
" ^^^^\n" +
"Zork cannot be resolved to a type\n" +
@@ -51043,4 +51063,4 @@
"The constructor X.Base<X<T>.Arr>(Class<X.Arr>) is undefined\n" +
"----------\n");
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GrammarCoverageTests308.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GrammarCoverageTests308.java
new file mode 100644
index 0000000..e2369c8
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GrammarCoverageTests308.java
@@ -0,0 +1,1639 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Stephan Herrmann - Contribution for
+ * bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import junit.framework.Test;
+
+public class GrammarCoverageTests308 extends AbstractRegressionTest {
+
+ static {
+// TESTS_NUMBERS = new int [] { 35 };
+// TESTS_NAMES = new String [] { "testnew" };
+ }
+ public static Class testClass() {
+ return GrammarCoverageTests308.class;
+ }
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_8);
+ }
+ public GrammarCoverageTests308(String testName){
+ super(testName);
+ }
+ // Lone test to verify that multiple annotations of all three kinds are accepted. All other tests will use only marker annotations
+ public void test000() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X extends @Marker @SingleMember(0) @Normal(Value = 0) Object {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends @Marker @SingleMember(0) @Normal(Value = 0) Object {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X extends @Marker @SingleMember(0) @Normal(Value = 0) Object {\n" +
+ " ^^^^^^^^^^^^\n" +
+ "SingleMember cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public class X extends @Marker @SingleMember(0) @Normal(Value = 0) Object {\n" +
+ " ^^^^^^\n" +
+ "Normal cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
+ public void test001() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @Marker int x;\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " @Marker int x;\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // TYPE: MethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
+ public void test002() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @Marker <T> @Marker int x() { return 10; };\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " @Marker <T> @Marker int x() { return 10; };\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " @Marker <T> @Marker int x() { return 10; };\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // TYPE: MethodHeaderName ::= Modifiersopt Type 'Identifier' '('
+ public void test003() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " @Marker int x() { return 10; };\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " @Marker int x() { return 10; };\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // FormalParameter ::= Modifiersopt Type VariableDeclaratorIdOrThis
+ public void test004() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x(@Marker int p) { return 10; };\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int x(@Marker int p) { return 10; };\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // FormalParameter ::= Modifiersopt Type PushZeroTypeAnnotations '...' VariableDeclaratorIdOrThis
+ public void test005() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x(@Marker int ... p) { return 10; };\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int x(@Marker int ... p) { return 10; };\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // FormalParameter ::= Modifiersopt Type @308... TypeAnnotations '...' VariableDeclaratorIdOrThis
+ public void test006() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x(@Marker int [] @Marker ... p) { return 10; };\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " int x(@Marker int [] @Marker ... p) { return 10; };\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " int x(@Marker int [] @Marker ... p) { return 10; };\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // UnionType ::= Type
+ // UnionType ::= UnionType '|' Type
+ public void test007() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x() {\n" +
+ " try {\n" +
+ " } catch (@Marker NullPointerException | @Marker ArrayIndexOutOfBoundsException e) {\n" +
+ " }\n" +
+ " return 10;\n" +
+ " }\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " } catch (@Marker NullPointerException | @Marker ArrayIndexOutOfBoundsException e) {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " } catch (@Marker NullPointerException | @Marker ArrayIndexOutOfBoundsException e) {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 8)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators
+ // LocalVariableDeclaration ::= Modifiers Type PushRealModifiers VariableDeclarators
+ public void test008() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x() {\n" +
+ " @Marker int p;\n" +
+ " final @Marker int q;\n" +
+ " @Marker final int r;\n" +
+ " return 10;\n" +
+ " }\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " @Marker int p;\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " final @Marker int q;\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " @Marker final int r;\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 8)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // Resource ::= Type PushModifiers VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
+ // Resource ::= Modifiers Type PushRealModifiers VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
+ public void test009() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x() {\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " }\n" +
+ " return 10;\n" +
+ " }\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The resource type Integer does not implement java.lang.AutoCloseable\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The resource type Integer does not implement java.lang.AutoCloseable\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 3)\n" +
+ " try (@Marker Integer p = null; final @Marker Integer q = null; @Marker final Integer r = null) {\n" +
+ " ^^^^^^^\n" +
+ "The resource type Integer does not implement java.lang.AutoCloseable\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 7)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // EnhancedForStatementHeaderInit ::= 'for' '(' Type PushModifiers Identifier Dimsopt
+ // EnhancedForStatementHeaderInit ::= 'for' '(' Modifiers Type PushRealModifiers Identifier Dimsopt
+ public void test010() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " int x() {\n" +
+ " for (@Marker int i: new int[3]) {}\n" +
+ " for (final @Marker int i: new int[3]) {}\n" +
+ " for (@Marker final int i: new int[3]) {}\n" +
+ " return 10;\n" +
+ " }\n" +
+ " Zork z;\n" +
+ "}\n" +
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " for (@Marker int i: new int[3]) {}\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " for (final @Marker int i: new int[3]) {}\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " for (@Marker final int i: new int[3]) {}\n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 8)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // AnnotationMethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
+ // AnnotationMethodHeaderName ::= Modifiersopt Type 'Identifier' '('
+ public void test011() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public @interface X { \n" +
+ " public @Marker String value(); \n" +
+ " @Marker String value2(); \n" +
+ " @Marker public String value3(); \n" +
+ " public @Marker <T> @Marker String value4(); \n" +
+ " @Marker <T> @Marker String value5(); \n" +
+ " @Marker public <T> @Marker String value6(); \n" +
+ "}\n" +
+
+ "@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+ "@interface Marker {}\n",
+
+ "java/lang/annotation/ElementType.java",
+ "package java.lang.annotation;\n"+
+ "public enum ElementType {\n" +
+ " TYPE,\n" +
+ " FIELD,\n" +
+ " METHOD,\n" +
+ " PARAMETER,\n" +
+ " CONSTRUCTOR,\n" +
+ " LOCAL_VARIABLE,\n" +
+ " ANNOTATION_TYPE,\n" +
+ " PACKAGE,\n" +
+ " TYPE_PARAMETER,\n" +
+ " TYPE_USE\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public @Marker String value(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " @Marker String value2(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " @Marker public String value3(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 5)\n" +
+ " public @Marker <T> @Marker String value4(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 5)\n" +
+ " public @Marker <T> @Marker String value4(); \n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 5)\n" +
+ " public @Marker <T> @Marker String value4(); \n" +
+ " ^^^^^^^^\n" +
+ "Annotation attributes cannot be generic\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 6)\n" +
+ " @Marker <T> @Marker String value5(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 6)\n" +
+ " @Marker <T> @Marker String value5(); \n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "9. ERROR in X.java (at line 6)\n" +
+ " @Marker <T> @Marker String value5(); \n" +
+ " ^^^^^^^^\n" +
+ "Annotation attributes cannot be generic\n" +
+ "----------\n" +
+ "10. ERROR in X.java (at line 7)\n" +
+ " @Marker public <T> @Marker String value6(); \n" +
+ " ^^^^^^^\n" +
+ "The annotation @Marker is disallowed for this location\n" +
+ "----------\n" +
+ "11. ERROR in X.java (at line 7)\n" +
+ " @Marker public <T> @Marker String value6(); \n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "12. ERROR in X.java (at line 7)\n" +
+ " @Marker public <T> @Marker String value6(); \n" +
+ " ^^^^^^^^\n" +
+ "Annotation attributes cannot be generic\n" +
+ "----------\n");
+ }
+ // PrimaryNoNewArray ::= PrimitiveType Dims '.' 'class'
+ // PrimaryNoNewArray ::= PrimitiveType '.' 'class'
+ public void test012() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X { \n" +
+ " public void value() {\n" +
+ " Object o = @Marker int.class;\n" +
+ " Object o2 = @Marker int @Marker[] [] @Marker[].class;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " Object o = @Marker int.class;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " Object o2 = @Marker int @Marker[] [] @Marker[].class;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " Object o2 = @Marker int @Marker[] [] @Marker[].class;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 4)\n" +
+ " Object o2 = @Marker int @Marker[] [] @Marker[].class;\n" +
+ " ^^^^^^^\n" +
+ "Syntax error, type annotations are illegal here\n" +
+ "----------\n");
+ }
+ // ReferenceExpression ::= PrimitiveType Dims '::' NonWildTypeArgumentsopt IdentifierOrNew
+ public void test013() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " Object copy(int [] ia);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = @Marker int @Marker []::<String>clone;\n" +
+ " Zork z;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " I i = @Marker int @Marker []::<String>clone;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " I i = @Marker int @Marker []::<String>clone;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 6)\n" +
+ " I i = @Marker int @Marker []::<String>clone;\n" +
+ " ^^^^^^\n" +
+ "Unused type arguments for the non generic method clone() of type Object; it should not be parameterized with arguments <String>\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 7)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
+ // ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
+ public void test014() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " int i [] = new @Marker int @Marker [4];\n" +
+ " int j [] = new @Marker int @Marker [] { 10 };\n" +
+ " Zork z;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " int i [] = new @Marker int @Marker [4];\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " int i [] = new @Marker int @Marker [4];\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " int j [] = new @Marker int @Marker [] { 10 };\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 4)\n" +
+ " int j [] = new @Marker int @Marker [] { 10 };\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 5)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN InsideCastExpression UnaryExpression
+ public void test015() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " int i = (@Marker int) 0;\n" +
+ " int j [] = (@Marker int @Marker []) null;\n" +
+ " Zork z;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " int i = (@Marker int) 0;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 4)\n" +
+ " int j [] = (@Marker int @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 4)\n" +
+ " int j [] = (@Marker int @Marker []) null;\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 5)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // InstanceofExpression ::= InstanceofExpression 'instanceof' ReferenceType
+ public void test016() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " if (args instanceof @Readonly String) {\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " if (args instanceof @Readonly String) {\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible conditional operand types String[] and String\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " if (args instanceof @Readonly String) {\n" +
+ " ^^^^^^^^\n" +
+ "Readonly cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // TypeArgument ::= ReferenceType
+ public void test017() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X extends Y<@Marker Integer, String> {}\n" +
+ "class Y<T, V> {\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends Y<@Marker Integer, String> {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ReferenceType1 ::= ReferenceType '>'
+ public void test018() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X extends Y<@Marker Integer> {}\n" +
+ "class Y<T> {\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X extends Y<@Marker Integer> {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+
+ // ReferenceType2 ::= ReferenceType '>>'
+ public void test019() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T extends Object & Comparable<? super @Marker String>> {}\n" +
+ "class Y<T> {\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<T extends Object & Comparable<? super @Marker String>> {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ReferenceType3 ::= ReferenceType '>>>'
+ public void test020() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<A extends X<X<X<@Marker String>>>> {}\n" +
+ "class Y<T> {\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X<A extends X<X<X<@Marker String>>>> {}\n" +
+ " ^\n" +
+ "Bound mismatch: The type X<X<String>> is not a valid substitute for the bounded parameter <A extends X<X<X<String>>>> of the type X<A>\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X<A extends X<X<X<@Marker String>>>> {}\n" +
+ " ^\n" +
+ "Bound mismatch: The type X<String> is not a valid substitute for the bounded parameter <A extends X<X<X<String>>>> of the type X<A>\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public class X<A extends X<X<X<@Marker String>>>> {}\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "Bound mismatch: The type String is not a valid substitute for the bounded parameter <A extends X<X<X<String>>>> of the type X<A>\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 1)\n" +
+ " public class X<A extends X<X<X<@Marker String>>>> {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 3)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // WildcardBounds ::= 'extends' ReferenceType
+ // WildcardBounds ::= 'super' ReferenceType
+ public void test021() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " ^^^\n" +
+ "Map cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 2)\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 2)\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 2)\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 2)\n" +
+ " void foo(Map<@Marker ? super @Marker Object, @Marker ? extends @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 3)\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ " ^^^\n" +
+ "Map cannot be resolved to a type\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 3)\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 3)\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "9. ERROR in X.java (at line 3)\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "10. ERROR in X.java (at line 3)\n" +
+ " void goo(Map<@Marker ? extends @Marker Object, @Marker ? super @Marker String> m){}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // TypeParameter ::= TypeParameterHeader 'extends' ReferenceType
+ public void test022() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ "}\n" +
+ "class Y<T> {}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. WARNING in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^^^^^^^^^^\n" +
+ "The type parameter Q should not be bounded by the final type Integer. Final types cannot be further extended\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 1)\n" +
+ " public class X <@Marker T extends @Marker Y<@Marker ?>, @Marker Q extends @Marker Integer> {\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // TypeParameter ::= TypeParameterHeader 'extends' ReferenceType AdditionalBoundList
+ // AdditionalBound ::= '&' ReferenceType
+ // TypeParameter1 ::= TypeParameterHeader 'extends' ReferenceType AdditionalBoundList1
+ public void test023() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "I.java",
+ "public interface I<U extends J<? extends I<U>>> {\n" +
+ "}\n" +
+ "interface J<T extends I<? extends J<T>>> {\n" +
+ "}\n" +
+ "class CI<U extends CJ<T, U> & @Marker J<@Marker T>,\n" +
+ " T extends CI<U, T> & @Marker I<U>>\n" +
+ " implements I<U> {\n" +
+ "}\n" +
+ "class CJ<T extends CI<U, T> & @Marker I<@Marker U>,\n" +
+ " U extends CJ<T, U> & J<T>>\n" +
+ " implements J<T> {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in I.java (at line 5)\n" +
+ " class CI<U extends CJ<T, U> & @Marker J<@Marker T>,\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in I.java (at line 5)\n" +
+ " class CI<U extends CJ<T, U> & @Marker J<@Marker T>,\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "3. ERROR in I.java (at line 6)\n" +
+ " T extends CI<U, T> & @Marker I<U>>\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "4. ERROR in I.java (at line 9)\n" +
+ " class CJ<T extends CI<U, T> & @Marker I<@Marker U>,\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n" +
+ "5. ERROR in I.java (at line 9)\n" +
+ " class CJ<T extends CI<U, T> & @Marker I<@Marker U>,\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // InstanceofExpression_NotName ::= Name 'instanceof' ReferenceType
+ public void test024() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<E> {\n" +
+ " class Y {\n" +
+ " E e;\n" +
+ " E getOtherElement(Object other) {\n" +
+ " if (!(other instanceof @Marker X<?>.Y)) {};\n" +
+ " return null;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " if (!(other instanceof @Marker X<?>.Y)) {};\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // InstanceofExpression_NotName ::= InstanceofExpression_NotName 'instanceof' ReferenceType
+ public void test025() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<P, C> {\n" +
+ " public X() {\n" +
+ " if (!(this instanceof @Marker X)) {}\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " if (!(this instanceof @Marker X)) {}\n" +
+ " ^^^^^^\n" +
+ "Marker cannot be resolved to a type\n" +
+ "----------\n");
+ }
+ // ReferenceExpressionTypeArgumentsAndTrunk ::= OnlyTypeArguments '.' ClassOrInterfaceType Dimsopt
+ public void test026() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {\n" +
+ " void foo(Y<String>.Z z, int x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static void main(String [] args) {\n" +
+ " I i = Y<String>.@Marker Z::foo;\n" +
+ " i.foo(new Y<String>().new Z(), 10); \n" +
+ " Zork z;\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T> {\n" +
+ " class Z {\n" +
+ " void foo(int x) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " I i = Y<String>.@Marker Z::foo;\n" +
+ &qu