diff options
author | ptff | 2004-07-01 09:32:04 +0000 |
---|---|---|
committer | ptff | 2004-07-01 09:32:04 +0000 |
commit | b4de16a0dc7d3ad9d6dd3c598e29125b9c3084c3 (patch) | |
tree | a983cca1d57d11d5975efe863d069eadbe497551 /org.eclipse.jdt.core.tests.compiler | |
parent | 39e0b3c44033d41fbb2f81071d1364bb178092c7 (diff) | |
download | eclipse.jdt.core-b4de16a0dc7d3ad9d6dd3c598e29125b9c3084c3.tar.gz eclipse.jdt.core-b4de16a0dc7d3ad9d6dd3c598e29125b9c3084c3.tar.xz eclipse.jdt.core-b4de16a0dc7d3ad9d6dd3c598e29125b9c3084c3.zip |
HEAD - Merge back 1.5 stream content after R3_0_maintenance branch was created...v_449b_head_after_JDK15_merge
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler')
35 files changed, 21497 insertions, 161 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java index 8382d9c522..970f9539e1 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java @@ -10,10 +10,21 @@ *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.parser; +import junit.framework.Test; +import junit.framework.TestSuite; + public class CompletionRecoveryTest extends AbstractCompletionTest { public CompletionRecoveryTest(String testName){ super(testName); } +public static Test suite() { + if (true) { + return new TestSuite(CompletionRecoveryTest.class); + } + TestSuite suite = new TestSuite(CompletionRecoveryTest.class.getName()); + suite.addTest(new CompletionRecoveryTest("test22")); //$NON-NLS-1$ + return suite; +} /* * Complete on variable behind ill-formed declaration */ 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 new file mode 100644 index 0000000000..0381d8b41f --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java @@ -0,0 +1,1883 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.parser; + +import junit.framework.Test; + +import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest; +import org.eclipse.jdt.core.tests.compiler.regression.RegressionTestSetup; + +public class ComplianceDiagnoseTest extends AbstractRegressionTest { + public ComplianceDiagnoseTest(String name) { + super(name); + } + // Use this static initializer to specify subset for tests + // All specified tests which does not belong to the class are skipped... + static { + // Names of tests to run: can be "testBugXXXX" or "BugXXXX") +// testsNames = new String[] { "Bug51529a", "Bug51529b" }; + // Numbers of tests to run: "test<number>" will be run for each number of this array +// testsNumbers = new int[] { 3, 7, 10, 21 }; + // Range numbers of tests to run: all tests between "test<first>" and "test<last>" will be run for { first, last } +// testsRange = new int[] { 21, 50 }; +// testsRange = new int[] { -1, 50 }; // run all tests with a number less or equals to 50 +// testsRange = new int[] { 10, -1 }; // run all tests with a number greater or equals to 10 + } + public static Test suite() { + if (testsNames != null || testsNumbers!=null || testsRange!=null) { + return new RegressionTestSetup(buildTestSuite(testClass()), highestComplianceLevels()); + } else { + // To run a specific test, just uncomment line with testNumbers in static initializer above + // and put numbers of tests you want to perform + return setupSuite(testClass()); + } + } +public static Class testClass() { + return ComplianceDiagnoseTest.class; +} +public void runComplianceParserTest( + String[] testFiles, + String expected13ProblemLog, + String expected14ProblemLog, + String expected15ProblemLog){ + if(COMPLIANCE_1_3.equals(this.complianceLevel)) { + this.runNegativeTest(testFiles, expected13ProblemLog); + } else if(COMPLIANCE_1_4.equals(this.complianceLevel)) { + this.runNegativeTest(testFiles, expected14ProblemLog); + } else if(COMPLIANCE_1_5.equals(this.complianceLevel)) { + this.runNegativeTest(testFiles, expected15ProblemLog); + } +} +public void test0001() { + String[] testFiles = new String[] { + "X.java", + "import static aaa.BBB.*;\n" + + "public class X {\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static aaa.BBB.*;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, static imports are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " import static aaa.BBB.*;\n" + + " ^^^\n" + + "The import aaa cannot be resolved\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static aaa.BBB.*;\n" + + " ^^^\n" + + "The import aaa cannot be resolved\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0002() { + String[] testFiles = new String[] { + "X.java", + "import static aaa.BBB.CCC;\n" + + "public class X {\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static aaa.BBB.CCC;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, static imports are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " import static aaa.BBB.CCC;\n" + + " ^^^\n" + + "The import aaa cannot be resolved\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static aaa.BBB.CCC;\n" + + " ^^^\n" + + "The import aaa cannot be resolved\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0003() { + String[] testFiles = new String[] { + "X.java", + "public enum X {\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public enum X {\n" + + " ^^^^\n" + + "Syntax error on token \"enum\", interface expected\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + ""; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0004() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo(){\n" + + " for(String o: c) {\n" + + " }\n" + + " }\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " for(String o: c) {\n" + + " ^^^^^^^^^^^\n" + + "Syntax error, \'for each\' statements are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " for(String o: c) {\n" + + " ^\n" + + "c cannot be resolved\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " for(String o: c) {\n" + + " ^\n" + + "c cannot be resolved\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0005() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo(Z ... arg){\n" + + " }\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(Z ... arg){\n" + + " ^^^^^^^^^\n" + + "Syntax error, varargs are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo(Z ... arg){\n" + + " ^\n" + + "Z cannot be resolved to a type\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(Z ... arg){\n" + + " ^\n" + + "Z cannot be resolved to a type\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0006() { + String[] testFiles = new String[] { + "X.java", + "public class X <T1 extends String, T2> extends Y {\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T1 extends String, T2> extends Y {\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, type parameters are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " public class X <T1 extends String, T2> extends Y {\n" + + " ^\n" + + "Y cannot be resolved to a type\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T1 extends String, T2> extends Y {\n" + + " ^\n" + + "Y cannot be resolved to a type\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0007() { + String[] testFiles = new String[] { + "X.java", + "public interface X <T1 extends String, T2> extends Y {\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public interface X <T1 extends String, T2> extends Y {\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, type parameters are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " public interface X <T1 extends String, T2> extends Y {\n" + + " ^\n" + + "Y cannot be resolved to a type\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public interface X <T1 extends String, T2> extends Y {\n" + + " ^\n" + + "Y cannot be resolved to a type\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0008() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " public <T1 extends String, T2> int foo(){\n" + + " }\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public <T1 extends String, T2> int foo(){\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, type parameters are only available if source level is 1.5\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public <T1 extends String, T2> int foo(){\n" + + " ^^^^^\n" + + "This method must return a result of type int\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0009() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " public <T1 extends String, T2> X(){\n" + + " }\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public <T1 extends String, T2> X(){\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, type parameters are only available if source level is 1.5\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + ""; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0010() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " Z<Y1, Y2> var;\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Z<Y1, Y2> var;\n" + + " ^\n" + + "Z cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " Z<Y1, Y2> var;\n" + + " ^^^^^^\n" + + "Syntax error, parameterized types are only available if source level is 1.5\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Z<Y1, Y2> var;\n" + + " ^\n" + + "Z cannot be resolved to a type\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0011() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " public X(){\n" + + " <Y1, Y2>this(null);\n" + + " }\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " <Y1, Y2>this(null);\n" + + " ^^^^^^\n" + + "Syntax error, parameterized types are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " <Y1, Y2>this(null);\n" + + " ^^\n" + + "Y1 cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " <Y1, Y2>this(null);\n" + + " ^^\n" + + "Y2 cannot be resolved to a type\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " <Y1, Y2>this(null);\n" + + " ^^\n" + + "Y1 cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " <Y1, Y2>this(null);\n" + + " ^^\n" + + "Y2 cannot be resolved to a type\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0012() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo() {\n" + + " assert true;\n" + + " }\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " assert true;\n" + + " ^^^^^^\n" + + "\'assert\' should not be used as an identifier, since it is a reserved keyword from source level 1.4 on\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " assert true;\n" + + " ^^^^^^\n" + + "Syntax error on token \"assert\", AssignmentOperator expected after this token\n" + + "----------\n"; + String expected14ProblemLog = + ""; + + String expected15ProblemLog = + expected14ProblemLog; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0013() { + String[] testFiles = new String[] { + "X.java", + "import static aaa.*\n" + + "public class X {\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static aaa.*\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Syntax error, static imports are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " import static aaa.*\n" + + " ^^^\n" + + "The import aaa cannot be resolved\n" + + "----------\n" + + "3. ERROR in X.java (at line 1)\n" + + " import static aaa.*\n" + + " ^\n" + + "Syntax error on token \"*\", ; expected after this token\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static aaa.*\n" + + " ^^^\n" + + "The import aaa cannot be resolved\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " import static aaa.*\n" + + " ^\n" + + "Syntax error on token \"*\", ; expected after this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0014() { + String[] testFiles = new String[] { + "X.java", + "public enum X \n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public enum X \n" + + "}\n" + + " ^^^^^^^^^\n" + + "Syntax error on tokens, delete these tokens\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public enum X \n" + + " ^\n" + + "Syntax error on token \"X\", { expected after this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0015() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo(){\n" + + " for(String o: c) {\n" + + " #\n" + + " }\n" + + " }\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " for(String o: c) {\n" + + " ^^^^^^^^^^^\n" + + "Syntax error, \'for each\' statements are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0016() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo(Z ... arg){\n" + + " }\n" + + " #\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(Z ... arg){\n" + + " ^^^^^^^^^\n" + + "Syntax error, varargs are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo(Z ... arg){\n" + + " ^\n" + + "Z cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(Z ... arg){\n" + + " ^\n" + + "Z cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0017() { + String[] testFiles = new String[] { + "X.java", + "public class X <T1 extends String, T2> extends Y {\n" + + " #\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T1 extends String, T2> extends Y {\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, type parameters are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " public class X <T1 extends String, T2> extends Y {\n" + + " ^\n" + + "Y cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 2)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T1 extends String, T2> extends Y {\n" + + " ^\n" + + "Y cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0018() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " public <T1 extends String, T2> int foo(){\n" + + " }\n" + + " #\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public <T1 extends String, T2> int foo(){\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, type parameters are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 4)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0019() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " Z<Y1, Y2> var;\n" + + " #\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Z<Y1, Y2> var;\n" + + " ^\n" + + "Z cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " Z<Y1, Y2> var;\n" + + " ^^^^^^\n" + + "Syntax error, parameterized types are only available if source level is 1.5\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Z<Y1, Y2> var;\n" + + " ^\n" + + "Z cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0020() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo() {\n" + + " assert true;\n" + + " #\n" + + " }\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " assert true;\n" + + " ^^^^^^\n" + + "\'assert\' should not be used as an identifier, since it is a reserved keyword from source level 1.4 on\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " assert true;\n" + + " ^^^^^^\n" + + "Syntax error on token \"assert\", AssignmentOperator expected after this token\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + String expected14ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " #\n" + + " ^\n" + + "Syntax error on token \"Invalid Character\", delete this token\n" + + "----------\n"; + + String expected15ProblemLog = + expected14ProblemLog; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +//TODO (david) suspicious behavior +public void test0021() { + String[] testFiles = new String[] { + "X.java", + "import staic aaa.*;\n" + + "public class X {\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import staic aaa.*;\n" + + " ^^^^^\n" + + "The import staic cannot be resolved\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " import staic aaa.*;\n" + + " ^^^\n" + + "Syntax error on token \"aaa\", delete this token\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import staic aaa.*;\n" + + " ^^^^^\n" + + "Syntax error on token \"staic\", static expected\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " import staic aaa.*;\n" + + " ^^^^^\n" + + "The import staic cannot be resolved\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +//TODO (david) suspicious behavior +public void test0022() { + String[] testFiles = new String[] { + "X.java", + "import static aaa.*.*;\n" + + "public class X {\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static aaa.*.*;\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Syntax error, static imports are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " import static aaa.*.*;\n" + + " ^^^\n" + + "The import aaa cannot be resolved\n" + + "----------\n" + + "3. ERROR in X.java (at line 1)\n" + + " import static aaa.*.*;\n" + + " ^^\n" + + "Syntax error on tokens, delete these tokens\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static aaa.*.*;\n" + + " ^^^\n" + + "The import aaa cannot be resolved\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " import static aaa.*.*;\n" + + " ^\n" + + "Syntax error on token \"*\", Identifier expected\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0023() { + String[] testFiles = new String[] { + "X.java", + "import static for;\n" + + "public class X {\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static for;\n" + + " ^^^^^^^^^^\n" + + "Syntax error on tokens, Name expected instead\n" + + "----------\n"; + String expected14ProblemLog = + 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"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} + +//TODO (david) reenable once bug is fixed +public void _test0024() { + String[] testFiles = new String[] { + "X.java", + "import static {aaa};\n" + + "public class X {\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static {aaa};\n" + + " ^^^^^^^^^^^^\n" + + "Syntax error on tokens, Name expected instead\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " import static {aaa};\n" + + " ^^^^^\n" + + "Syntax error on tokens, Name expected instead\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0025() { + String[] testFiles = new String[] { + "X.java", + "static aaa.*;\n" + + "public class X {\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " static aaa.*;\n" + + " ^^^^^^\n" + + "Syntax error on token \"static\", import expected\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " static aaa.*;\n" + + " ^^^^^^\n" + + "Syntax error on token \"static\", import expected before this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0026() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo(){\n" + + " for(Object o ? c){\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " for(Object o ? c){\n" + + " ^^^^^^\n" + + "Syntax error on token \"Object\", ( expected\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " for(Object o ? c){\n" + + " ^^^\n" + + "Syntax error on token(s), misplaced construct(s)\n" + + "----------\n" + + "3. ERROR in X.java (at line 3)\n" + + " for(Object o ? c){\n" + + " ^\n" + + "Syntax error, insert \"AssignmentOperator ArrayInitializer\" to complete ArrayInitializerAssignement\n" + + "----------\n" + + "4. ERROR in X.java (at line 3)\n" + + " for(Object o ? c){\n" + + " ^\n" + + "Syntax error, insert \"; ; ) Statement\" to complete BlockStatements\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " for(Object o ? c){\n" + + " ^\n" + + "Syntax error on token \"?\", : expected\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0027() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo(){\n" + + " for(Object o : switch){\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " for(Object o : switch){\n" + + " ^\n" + + "Syntax error, insert \"; ; ) Statement\" to complete BlockStatements\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " for(Object o : switch){\n" + + " ^^^^^^\n" + + "Syntax error on token \"switch\", invalid Expression\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0028() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo(int ... ){\n" + + " }\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X {\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo(int ... ){\n" + + " ^^^\n" + + "Syntax error on token \"ELLIPSIS\", invalid VariableDeclaratorId\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " }\n" + + " ^\n" + + "Syntax error on token \"}\", delete this token\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X {\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo(int ... ){\n" + + " ^^^\n" + + "Syntax error on token \"ELLIPSIS\", VariableDeclaratorId expected after this token\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " }\n" + + " ^\n" + + "Syntax error on token \"}\", delete this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0029() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo(int ... for){\n" + + " }\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X {\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo(int ... for){\n" + + " ^^^^^^^\n" + + "Syntax error on tokens, VariableDeclaratorId expected instead\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " }\n" + + " ^\n" + + "Syntax error on token \"}\", delete this token\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X {\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo(int ... for){\n" + + " ^^^\n" + + "Syntax error on token \"for\", invalid VariableDeclaratorId\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " }\n" + + " ^\n" + + "Syntax error on token \"}\", delete this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0030() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo(int .. aaa){\n" + + " }\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X {\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo(int .. aaa){\n" + + " ^^\n" + + "Syntax error on tokens, delete these tokens\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " }\n" + + " ^\n" + + "Syntax error on token \"}\", delete this token\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X {\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo(int .. aaa){\n" + + " ^^\n" + + "Syntax error on tokens, delete these tokens\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " }\n" + + " ^\n" + + "Syntax error on token \"}\", delete this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0031() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " void foo(int ... aaa bbb){\n" + + " }\n" + + "}\n" + + "\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X {\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo(int ... aaa bbb){\n" + + " ^^^^^^^^^^^\n" + + "Syntax error, varargs are only available if source level is 1.5\n" + + "----------\n" + + "3. ERROR in X.java (at line 2)\n" + + " void foo(int ... aaa bbb){\n" + + " ^^^^^^^\n" + + "Syntax error on token(s), misplaced construct(s)\n" + + "----------\n" + + "4. ERROR in X.java (at line 4)\n" + + " }\n" + + " ^\n" + + "Syntax error on token \"}\", delete this token\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X {\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo(int ... aaa bbb){\n" + + " ^^^\n" + + "Syntax error on token \"bbb\", delete this token\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " }\n" + + " ^\n" + + "Syntax error on token \"}\", delete this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0032() { + String[] testFiles = new String[] { + "X.java", + "public class X <T1 extends String, T2 extends Y {\n" + + " \n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T1 extends String, T2 extends Y {\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error on token(s), misplaced construct(s)\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T1 extends String, T2 extends Y {\n" + + " ^\n" + + "Syntax error, insert \">\" to complete ReferenceType1\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " public class X <T1 extends String, T2 extends Y {\n" + + " ^\n" + + "Y cannot be resolved to a type\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0033() { + String[] testFiles = new String[] { + "X.java", + "public class X T1 extends String, T2> extends Y {\n" + + " \n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X T1 extends String, T2> extends Y {\n" + + " ^^\n" + + "Syntax error on token \"T1\", delete this token\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " public class X T1 extends String, T2> extends Y {\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error on tokens, delete these tokens\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X T1 extends String, T2> extends Y {\n" + + " ^\n" + + "Syntax error on token \"X\", < expected after this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0034() { + String[] testFiles = new String[] { + "X.java", + "public class X <T1 extnds String, T2> extends Y {\n" + + " \n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T1 extnds String, T2> extends Y {\n" + + " ^\n" + + "Syntax error on token \"<\", { expected\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " public class X <T1 extnds String, T2> extends Y {\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error on tokens, InterfaceHeaderName expected instead\n" + + "----------\n" + + "3. ERROR in X.java (at line 1)\n" + + " public class X <T1 extnds String, T2> extends Y {\n" + + " ^^^^^^\n" + + "extnds cannot be resolved to a type\n" + + "----------\n" + + "4. ERROR in X.java (at line 1)\n" + + " public class X <T1 extnds String, T2> extends Y {\n" + + " ^^^^^^\n" + + "Syntax error on token \"String\", delete this token\n" + + "----------\n" + + "5. ERROR in X.java (at line 3)\n" + + " }\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T1 extnds String, T2> extends Y {\n" + + " ^^^^^^\n" + + "Syntax error on token \"extnds\", extends expected\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " public class X <T1 extnds String, T2> extends Y {\n" + + " ^^^^^^\n" + + "extnds cannot be resolved to a type\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0035() { + String[] testFiles = new String[] { + "X.java", + "public class X <T1 extends for, T2> extends Y {\n" + + " \n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T1 extends for, T2> extends Y {\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error on tokens, delete these tokens\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T1 extends for, T2> extends Y {\n" + + " ^^^\n" + + "Syntax error on token \"for\", invalid ReferenceType\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0036() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " public <T1 extends String, T2> foo(){\n" + + " }\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public <T1 extends String, T2> foo(){\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error, type parameters are only available if source level is 1.5\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " public <T1 extends String, T2> foo(){\n" + + " ^^^^^\n" + + "Return type for the method is missing\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public <T1 extends String, T2> foo(){\n" + + " ^^^^^\n" + + "Return type for the method is missing\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0037() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " public <T1 extnds String, T2> int foo(){\n" + + " }\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public <T1 extnds String, T2> int foo(){\n" + + " ^^^\n" + + "Syntax error on token(s), misplaced construct(s)\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " public <T1 extnds String, T2> int foo(){\n" + + " ^^\n" + + "T1 cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 2)\n" + + " public <T1 extnds String, T2> int foo(){\n" + + " ^\n" + + "Syntax error on token \">\", ; expected\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public <T1 extnds String, T2> int foo(){\n" + + " ^^\n" + + "T1 cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " public <T1 extnds String, T2> int foo(){\n" + + " ^^^^^^\n" + + "Syntax error on token \"extnds\", extends expected\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0038() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " public <T1 extends String T2> int foo(){\n" + + " }\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public <T1 extends String T2> int foo(){\n" + + " ^^^^^^^^^^^\n" + + "Syntax error on token(s), misplaced construct(s)\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " public <T1 extends String T2> int foo(){\n" + + " ^\n" + + "Syntax error on token \">\", ; expected\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public <T1 extends String T2> int foo(){\n" + + " ^^\n" + + "Syntax error on token \"T2\", delete this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0039() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " Z Y1, Y2> var;\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Z Y1, Y2> var;\n" + + " ^\n" + + "Z cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " Z Y1, Y2> var;\n" + + " ^\n" + + "Syntax error on token \">\", , expected\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Z Y1, Y2> var;\n" + + " ^\n" + + "Z cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " Z Y1, Y2> var;\n" + + " ^\n" + + "Syntax error on token \">\", , expected\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0040() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " Z <Y1, Y2 var;\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Z <Y1, Y2 var;\n" + + " ^^\n" + + "Syntax error, insert \">\" to complete ReferenceType1\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " Z <Y1, Y2 var;\n" + + " ^^\n" + + "Syntax error, insert \"Dimensions\" to complete ArrayType\n" + + "----------\n" + + "3. ERROR in X.java (at line 2)\n" + + " Z <Y1, Y2 var;\n" + + " ^^\n" + + "Y2 cannot be resolved to a type\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Z <Y1, Y2 var;\n" + + " ^^\n" + + "Syntax error, insert \">\" to complete ReferenceType1\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " Z <Y1, Y2 var;\n" + + " ^^\n" + + "Y2 cannot be resolved to a type\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0041() { + String[] testFiles = new String[] { + "X.java", + "public class X {\n" + + " Z <Y1, for Y2> var;\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Z <Y1, for Y2> var;\n" + + " ^^^^^^^^^^^^\n" + + "Syntax error on tokens, delete these tokens\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " Z <Y1, for Y2> var;\n" + + " ^^^\n" + + "Syntax error on token \"for\", delete this token\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +public void test0042() { + String[] testFiles = new String[] { + "X.java", + "void ___eval() {\n" + + " new Runnable() {\n" + + " int ___run() throws Throwable {\n" + + " return blah;\n" + + " }\n" + + " private String blarg;\n" + + " public void run() {\n" + + " }\n" + + " };\n" + + "}\n" + + "public class X {\n" + + " private static int x;\n" + + " private String blah;\n" + + " public static void main(String[] args) {\n" + + " }\n" + + " public void hello() {\n" + + " }\n" + + " public boolean blah() {\n" + + " return false;\n" + + " }\n" + + " public void foo() {\n" + + " }\n" + + "}\n" + }; + + String expected13ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " public void run() {\n" + + " }\n" + + " };\n" + + "}\n" + + " ^^^^^^^^^^^^^^^^^^^^^^\n" + + "Syntax error on tokens, delete these tokens\n" + + "----------\n"; + String expected14ProblemLog = + expected13ProblemLog; + + String expected15ProblemLog = + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " void ___eval() {\n" + + " ^^^^\n" + + "Syntax error on token \"void\", AT expected\n" + + "----------\n" + + "2. ERROR in X.java (at line 1)\n" + + " void ___eval() {\n" + + " ^\n" + + "Syntax error on token \")\", delete this token\n" + + "----------\n" + + "3. ERROR in X.java (at line 9)\n" + + " };\n" + + " ^\n" + + "Syntax error on token \"}\", { expected\n" + + "----------\n" + + "4. ERROR in X.java (at line 23)\n" + + " }\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "5. ERROR in X.java (at line 23)\n" + + " }\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete MemberValueArrayInitializer\n" + + "----------\n" + + "6. ERROR in X.java (at line 23)\n" + + " }\n" + + " ^\n" + + "Syntax error, insert \")\" to complete Modifiers\n" + + "----------\n" + + "7. ERROR in X.java (at line 23)\n" + + " }\n" + + " ^\n" + + "Syntax error, insert \"enum Identifier\" to complete EnumHeader\n" + + "----------\n" + + "8. ERROR in X.java (at line 23)\n" + + " }\n" + + " ^\n" + + "Syntax error, insert \"EnumBody\" to complete CompilationUnit\n" + + "----------\n"; + + runComplianceParserTest( + testFiles, + expected13ProblemLog, + expected14ProblemLog, + expected15ProblemLog + ); +} +} 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 d75c5a9b75..e942ba5044 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 @@ -5650,7 +5650,7 @@ public void test100() { expectedCompletionDietUnitToString, testName); } -public void test101() { +public void _test101() { String s = "public class X { \n"+ " Object foo(Stack<X> s) { \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 new file mode 100644 index 0000000000..8931f6ef61 --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericDietRecoveryTest.java @@ -0,0 +1,917 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.parser; + +import java.util.Locale; +import java.util.Map; + +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.compiler.CompilationResult; +import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies; +import org.eclipse.jdt.internal.compiler.SourceElementParser; +import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; +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.parser.Parser; +import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; +import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; + +public class GenericDietRecoveryTest extends AbstractCompilerTest { + public static boolean optimizeStringLiterals = false; + public static long sourceLevel = ClassFileConstants.JDK1_3; //$NON-NLS-1$ + +public GenericDietRecoveryTest(String testName){ + super(testName); +} + +/* + * Toggle compiler in mode -1.5 + */ +protected Map getCompilerOptions() { + Map options = super.getCompilerOptions(); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + return options; +} + +public void checkParse( + char[] source, + String expectedDietUnitToString, + String expectedDietPlusBodyUnitToString, + String expectedFullUnitToString, + String expectedCompletionDietUnitToString, + String testName) { + + /* using regular parser in DIET mode */ + { + Parser parser = + new Parser( + new ProblemReporter( + DefaultErrorHandlingPolicies.proceedWithAllProblems(), + new CompilerOptions(getCompilerOptions()), + new DefaultProblemFactory(Locale.getDefault())), + optimizeStringLiterals); + + ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null); + CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); + + CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult); + String computedUnitToString = computedUnit.toString(); + if (!expectedDietUnitToString.equals(computedUnitToString)){ + System.out.println(Util.displayString(computedUnitToString)); + } + assertEquals( + "Invalid unit diet structure" + testName, + expectedDietUnitToString, + computedUnitToString); + } + /* using regular parser in DIET mode + getMethodBodies */ + { + Parser parser = + new Parser( + new ProblemReporter( + DefaultErrorHandlingPolicies.proceedWithAllProblems(), + new CompilerOptions(getCompilerOptions()), + new DefaultProblemFactory(Locale.getDefault())), + optimizeStringLiterals); + + ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null); + CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); + + CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult); + String computedUnitToString = computedUnit.toString(); + if (!expectedDietUnitToString.equals(computedUnitToString)){ + System.out.println(Util.displayString(computedUnitToString)); + } + assertEquals( + "Invalid unit diet structure" + testName, + expectedDietUnitToString, + computedUnitToString); + if (computedUnit.types != null) { + for (int i = computedUnit.types.length; --i >= 0;){ + computedUnit.types[i].parseMethod(parser, computedUnit); + } + } + computedUnitToString = computedUnit.toString(); + if (!expectedDietPlusBodyUnitToString.equals(computedUnitToString)){ + System.out.println(Util.displayString(computedUnitToString)); + } + + assertEquals( + "Invalid unit diet+body structure" + testName, + expectedDietPlusBodyUnitToString, + computedUnitToString); + } + /* using regular parser in FULL mode */ + { + Parser parser = + new Parser( + new ProblemReporter( + DefaultErrorHandlingPolicies.proceedWithAllProblems(), + new CompilerOptions(getCompilerOptions()), + new DefaultProblemFactory(Locale.getDefault())), + optimizeStringLiterals); + + ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null); + CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); + + CompilationUnitDeclaration computedUnit = parser.parse(sourceUnit, compilationResult); + String computedUnitToString = computedUnit.toString(); + if (!expectedFullUnitToString.equals(computedUnitToString)){ + System.out.println(Util.displayString(computedUnitToString)); + } + assertEquals( + "Invalid unit full structure" + testName, + expectedFullUnitToString, + computedUnitToString); + + } + /* using source element parser in DIET mode */ + { + SourceElementParser parser = + new SourceElementParser( + new TestSourceElementRequestor(), + new DefaultProblemFactory(Locale.getDefault()), + new CompilerOptions(getCompilerOptions())); + + ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null); + CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); + + CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult); + String computedUnitToString = computedUnit.toString(); + if (!expectedDietUnitToString.equals(computedUnitToString)){ + System.out.println(Util.displayString(computedUnitToString)); + } + assertEquals( + "Invalid source element diet structure" + testName, + expectedDietUnitToString, + computedUnitToString); + } + /* using source element parser in FULL mode */ + { + SourceElementParser parser = + new SourceElementParser( + new TestSourceElementRequestor(), + new DefaultProblemFactory(Locale.getDefault()), + new CompilerOptions(getCompilerOptions())); + + ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null); + CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); + + CompilationUnitDeclaration computedUnit = parser.parse(sourceUnit, compilationResult); + String computedUnitToString = computedUnit.toString(); + if (!expectedFullUnitToString.equals(computedUnitToString)){ + System.out.println(Util.displayString(computedUnitToString)); + } + assertEquals( + "Invalid source element full structure" + testName, + expectedFullUnitToString, + computedUnitToString); + } + /* using completion parser in DIET mode */ + { + CompilerOptions options = new CompilerOptions(getCompilerOptions()); + CompletionParser parser = + new CompletionParser( + new ProblemReporter( + DefaultErrorHandlingPolicies.proceedWithAllProblems(), + options, + new DefaultProblemFactory(Locale.getDefault()))); + + ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null); + CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); + + CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult, Integer.MAX_VALUE); + String computedUnitToString = computedUnit.toString(); + if (!expectedCompletionDietUnitToString.equals(computedUnitToString)){ + System.out.println(Util.displayString(computedUnitToString)); + } + assertEquals( + "Invalid completion diet structure" + testName, + expectedCompletionDietUnitToString, + computedUnitToString); + } +} + +public void test0001() { + + String s = + "package a; \n" + + "public class X <A { \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0002() { + + String s = + "package a; \n" + + "public interface X <A { \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public interface X<A> {\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + expectedDietUnitToString; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0003() { + + String s = + "package a; \n" + + "public class X <A> \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0004() { + + String s = + "package a; \n" + + "public class X <A, B \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A, B> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A, B> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0005() { + + String s = + "package a; \n" + + "public class X <A, B \n" + + " A a; \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A, B> {\n" + + " A a;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A, B> {\n" + + " A a;\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0006() { + + String s = + "package a; \n" + + "public class X <A extends String, B \n" + + " A a; \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A extends String, B> {\n" + + " A a;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A extends String, B> {\n" + + " A a;\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0007() { + + String s = + "package a; \n" + + "public class X <A extends \n" + + " A a; \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A extends A> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A extends A> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} + +public void test0008() { + + String s = + "package a; \n" + + "public class X <A exteds B> \n" + + " A a; \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " exteds B;\n" + + " A a;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " exteds B;\n" + + " A a;\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0009() { + + String s = + "package a; \n" + + "public class X <A extends> \n" + + " A a; \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " A a;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " A a;\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} + +public void test0010() { + + String s = + "package a; \n" + + "public class X <A extends \n" + + " void foo(){} \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} + +public void test0011() { + + String s = + "package a; \n" + + "public class X <A, B extends \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A, B> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A, B> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0012() { + + String s = + "package a; \n" + + "public class X <A, B extends Z \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A, B extends Z> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A, B extends Z> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0013() { + + String s = + "package a; \n" + + "public class X <A, B extends Z< \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A, B> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A, B> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0014() { + + String s = + "package a; \n" + + "public class X <A, B extends Z<Y \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A, B> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A, B> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0015() { + + String s = + "package a; \n" + + "public class X <A, B extends Z<Y> \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A, B extends Z<Y>> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A, B extends Z<Y>> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0016() { + + String s = + "package a; \n" + + "public class X <A super int> { \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0017() { + + String s = + "package a; \n" + + "public class X <A<B super int>> { \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0018() { + + String s = + "package a; \n" + + "public class X <A<B<C super int>>> { \n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X<A> {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +public void test0019() { + + String s = + "package a; \n" + + "public class X { \n" + + " void foo()[\n" + + " Object o = (Y<Z>.W<U>)e\n" + + " \n" + + " }\n" + + "} \n"; + + String expectedDietUnitToString = + "package a;\n" + + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + String expectedDietPlusBodyUnitToString = + "package a;\n" + + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + String expectedFullUnitToString = expectedDietUnitToString; + + String expectedCompletionDietUnitToString = + expectedDietUnitToString; + + String testName = "<generic type recovery>"; + checkParse( + s.toCharArray(), + expectedDietUnitToString, + expectedDietPlusBodyUnitToString, + expectedFullUnitToString, + expectedCompletionDietUnitToString, + testName); +} +} diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java new file mode 100644 index 0000000000..fe629b30b5 --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java @@ -0,0 +1,7141 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.parser; + +public class GenericsCompletionParserTest extends AbstractCompletionTest { +public GenericsCompletionParserTest(String testName) { + super(testName); +} + +public void test0001(){ + String str = + "public class X <T extends Z<Y>. {\n" + + "}"; + + + String completeBehind = "Z<Y>."; + int cursorLocation = str.indexOf("Z<Y>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z<Y>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Z<Y>."; + String expectedUnitDisplayString = + "public class X<T extends <CompleteOnType:Z<Y>.>> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0002(){ + String str = + "public class X <T extends Z<Y>.W {\n" + + "}"; + + + String completeBehind = "Z<Y>.W"; + int cursorLocation = str.indexOf("Z<Y>.W") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z<Y>.W>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "W"; + String expectedReplacedSource = "Z<Y>.W"; + String expectedUnitDisplayString = + "public class X<T extends <CompleteOnType:Z<Y>.W>> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0003(){ + String str = + "public class Test<T extends test0001.X<Y>.Z> {\n" + + "}"; + + + String completeBehind = "X<Y>.Z"; + int cursorLocation = str.indexOf("X<Y>.Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:test0001.X<Y>.Z>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "test0001.X<Y>.Z"; + String expectedUnitDisplayString = + "public class Test<T extends <CompleteOnType:test0001.X<Y>.Z>> {\n" + + " public Test() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0004(){ + String str = + "public class X {\n" + + " public Y<Z>.\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0005(){ + String str = + "public class X {\n" + + " public Y<Z>. foo\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>;"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0006(){ + String str = + "public class X {\n" + + " public Y<Z>. foo;\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>;"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0007(){ + String str = + "public class X {\n" + + " public Y<Z>. foo()\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " public <CompleteOnType:Y<Z>.> foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0008(){ + String str = + "public class X {\n" + + " public Y<Z>. foo(){}\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " public <CompleteOnType:Y<Z>.> foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0009(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W>.\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W>."; + int cursorLocation = str.indexOf("Y<Z>.V<W>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.V<W>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>.V<W>."; + String expectedUnitDisplayString = + "public class X {\n" + + " <CompleteOnType:Y<Z>.V<W>.>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0010(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W>. foo\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W>."; + int cursorLocation = str.indexOf("Y<Z>.V<W>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.V<W>.>;"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>.V<W>."; + String expectedUnitDisplayString = + "public class X {\n" + + " <CompleteOnType:Y<Z>.V<W>.>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0011(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W>. foo;\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W>."; + int cursorLocation = str.indexOf("Y<Z>.V<W>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.V<W>.>;"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>.V<W>."; + String expectedUnitDisplayString = + "public class X {\n" + + " <CompleteOnType:Y<Z>.V<W>.>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0012(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W>. foo()\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W>."; + int cursorLocation = str.indexOf("Y<Z>.V<W>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.V<W>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>.V<W>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " public <CompleteOnType:Y<Z>.V<W>.> foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0013(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W>. foo(){}\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.V<W>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>.V<W>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " public <CompleteOnType:Y<Z>.V<W>.> foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0014(){ + String str = + "public class X extends Y<Z>. {\n" + + " \n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnClass:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X extends <CompleteOnClass:Y<Z>.> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0015(){ + String str = + "public class X implements I1, Y<Z>. {\n" + + " \n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnInterface:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X implements I1, <CompleteOnInterface:Y<Z>.> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0016(){ + String str = + "public class X {\n" + + " void foo(Y<Z>.){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " {\n" + + " }\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0017(){ + String str = + "public class X {\n" + + " void foo(Y<Z>. bar){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo(<CompleteOnType:Y<Z>.> bar) {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0018(){ + String str = + "public class X {\n" + + " Y<Z>. foo(){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <CompleteOnType:Y<Z>.> foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0019(){ + String str = + "public class X {\n" + + " void foo() throws Y<Z>. {\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnException:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() throws <CompleteOnException:Y<Z>.> {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0020(){ + String str = + "public class X {\n" + + " <T extends Y<Z>.> void foo(){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends <CompleteOnType:Y<Z>.>>void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0021(){ + String str = + "public class X {\n" + + " <T extends Y<Z>.> void foo(\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends <CompleteOnType:Y<Z>.>>void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0022(){ + String str = + "public class X {\n" + + " <T extends Y<Z>.> int foo\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends <CompleteOnType:Y<Z>.>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0023(){ + String str = + "public class X {\n" + + " <T extends Y<Z>.> X\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends <CompleteOnType:Y<Z>.>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0024(){ + String str = + "public class X {\n" + + " <T extends Y<Z>.>\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends <CompleteOnType:Y<Z>.>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0025(){ + String str = + "public class X {\n" + + " <T extends Y<Z>. void foo(){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends <CompleteOnType:Y<Z>.>>\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0026(){ + String str = + "public class X {\n" + + " <T extends Y<Z>. void foo(\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends <CompleteOnType:Y<Z>.>>\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0027(){ + String str = + "public class X {\n" + + " <T extends Y<Z>. int foo\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " int foo;\n" + + " public X() {\n" + + " }\n" + + " <T extends <CompleteOnType:Y<Z>.>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0028(){ + String str = + "public class X {\n" + + " <T extends Y<Z>. X\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends <CompleteOnType:Y<Z>.>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0029(){ + String str = + "public class X {\n" + + " <T extends Y<Z>.\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = ""; + String expectedReplacedSource = "Y<Z>."; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends <CompleteOnType:Y<Z>.>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0030(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Y<Z>.\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0031(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Y<Z>. var\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0032(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Y<Z>.W\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>.W"; + int cursorLocation = str.indexOf("Y<Z>.W") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.W>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = "W"; + expectedReplacedSource = "Y<Z>.W"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.W>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0033(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Y<Z>.W var\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>.W"; + int cursorLocation = str.indexOf("Y<Z>.W") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.W>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = "W"; + expectedReplacedSource = "Y<Z>.W"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.W>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0034(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z>.>bar();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0035(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z>.>bar(\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0036(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z>.>bar\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0037(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z>.>\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0038(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z>.\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0039(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " new <Y, Y<Z>.>X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0040(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " aaa.new <Y, Y<Z>.>X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0041(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " new V().new <Y, Y<Z>.>X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0042(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " for(Y<Z>. var;;){}\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0043(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " for(Y<Z>.\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0044(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " try {\n" + + " } catch(Y<Z>. e) {\n" + + " }\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnException:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnException:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0045(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " try {\n" + + " } catch(Y<Z>. e\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnException:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnException:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0046(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " catch(Y<Z>. e\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnException:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnException:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0047(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object a = (Y<Z>.) e;\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Object a = <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0048(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object a = (Y<Z>.) e;\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Object a = <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0049(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " (Y<Z>.) e;\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0050(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object[] o = new Y<Z>.[0];\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<NONE>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "<NONE>"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0051(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object[] o = new Y<Z>.\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<NONE>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "<NONE>"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0052(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " new Y<Z>.\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<NONE>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "<NONE>"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0053(){ + String str = + "public class X {\n" + + " public X() {\n" + + " <Y<Z>.>super();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0054(){ + String str = + "public class X {\n" + + " public X() {\n" + + " aaa.<Y<Z>.>super();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0055(){ + String str = + "public class X {\n" + + " public X() {\n" + + " A.this.<Y<Z>.>super();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z>."; + int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Y<Z>.>"; + expectedParentNodeToString = "<NONE>"; + completionIdentifier = ""; + expectedReplacedSource = "Y<Z>."; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " <CompleteOnType:Y<Z>.>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} + +public void test0056(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Y<Z\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0057(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Y<V,Z\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<V,Z"; + int cursorLocation = str.indexOf("Y<V,Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<V, <CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<V, <CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0058(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " W<U>.Y<V,Z\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<V,Z"; + int cursorLocation = str.indexOf("Y<V,Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "W<U>.Y<V, <CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " W<U>.Y<V, <CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0059(){ + String str = + "public class X <T extends Z<Y {\n" + + "}"; + + + String completeBehind = "Z<Y"; + int cursorLocation = str.indexOf("Z<Y") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Y>"; + String expectedParentNodeToString = "Z<<CompleteOnType:Y>>"; + String completionIdentifier = "Y"; + String expectedReplacedSource = "Y"; + String expectedUnitDisplayString = + "public class X<T> {\n" + + " Z<<CompleteOnType:Y>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0060(){ + String str = + "public class X {\n" + + " public Y<Z\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0061(){ + String str = + "public class X {\n" + + " public Y<Z>\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0062(){ + String str = + "public class X {\n" + + " public Y<Z> var\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public Y<<CompleteOnType:Z>> var;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0063(){ + String str = + "public class X {\n" + + " public Y<Z> var;\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public Y<<CompleteOnType:Z>> var;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0064(){ + String str = + "public class X {\n" + + " public Y<Z foo()\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + " foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0065(){ + String str = + "public class X {\n" + + " public Y<Z> foo()\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " public Y<<CompleteOnType:Z>> foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0066(){ + String str = + "public class X {\n" + + " public Y<Z foo(){}\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + " foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0067(){ + String str = + "public class X {\n" + + " public Y<Z> foo(){}\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " public Y<<CompleteOnType:Z>> foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0068(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W"; + int cursorLocation = str.indexOf("Y<Z>.V<W") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:W>"; + String expectedParentNodeToString = "Y<Z>.V<<CompleteOnType:W>>"; + String completionIdentifier = "W"; + String expectedReplacedSource = "W"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<Z>.V<<CompleteOnType:W>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0069(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W>\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W"; + int cursorLocation = str.indexOf("Y<Z>.V<W") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:W>"; + String expectedParentNodeToString = "Y<Z>.V<<CompleteOnType:W>>"; + String completionIdentifier = "W"; + String expectedReplacedSource = "W"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<Z>.V<<CompleteOnType:W>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0070(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W> var\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W"; + int cursorLocation = str.indexOf("Y<Z>.V<W") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:W>"; + String expectedParentNodeToString = "Y<Z>.V<<CompleteOnType:W>>"; + String completionIdentifier = "W"; + String expectedReplacedSource = "W"; + String expectedUnitDisplayString = + "public class X {\n" + + " public Y<Z>.V<<CompleteOnType:W>> var;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0071(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W> var;\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W"; + int cursorLocation = str.indexOf("Y<Z>.V<W") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:W>"; + String expectedParentNodeToString = "Y<Z>.V<<CompleteOnType:W>>"; + String completionIdentifier = "W"; + String expectedReplacedSource = "W"; + String expectedUnitDisplayString = + "public class X {\n" + + " public Y<Z>.V<<CompleteOnType:W>> var;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0072(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W foo()\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W"; + int cursorLocation = str.indexOf("Y<Z>.V<W") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:W>"; + String expectedParentNodeToString = "Y<Z>.V<<CompleteOnType:W>>"; + String completionIdentifier = "W"; + String expectedReplacedSource = "W"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<Z>.V<<CompleteOnType:W>>;\n" + + " public X() {\n" + + " }\n" + + " foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0073(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W> foo()\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W"; + int cursorLocation = str.indexOf("Y<Z>.V<W") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:W>"; + String expectedParentNodeToString = "Y<Z>.V<<CompleteOnType:W>>"; + String completionIdentifier = "W"; + String expectedReplacedSource = "W"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " public Y<Z>.V<<CompleteOnType:W>> foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0074(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W foo(){}\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:W>"; + String expectedParentNodeToString = "Y<Z>.V<<CompleteOnType:W>>"; + String completionIdentifier = "W"; + String expectedReplacedSource = "W"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<Z>.V<<CompleteOnType:W>>;\n" + + " public X() {\n" + + " }\n" + + " foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0075(){ + String str = + "public class X {\n" + + " public Y<Z>.V<W> foo(){}\n" + + "}"; + + + String completeBehind = "Y<Z>.V<W"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:W>"; + String expectedParentNodeToString = "Y<Z>.V<<CompleteOnType:W>>"; + String completionIdentifier = "W"; + String expectedReplacedSource = "W"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " public Y<Z>.V<<CompleteOnType:W>> foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0076(){ + String str = + "public class X extends Y<Z {\n" + + " \n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0077(){ + String str = + "public class X extends Y<Z> {\n" + + " \n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X extends Y<<CompleteOnType:Z>> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0078(){ + String str = + "public class X implements I1, Y<Z {\n" + + " \n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X implements I1 {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0079(){ + String str = + "public class X implements I1, Y<Z> {\n" + + " \n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X implements I1, Y<<CompleteOnType:Z>> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0080(){ + String str = + "public class X {\n" + + " void foo(Y<Z){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0081(){ + String str = + "public class X {\n" + + " void foo(Y<Z>){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0082(){ + String str = + "public class X {\n" + + " void foo(Y<Z> var){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo(Y<<CompleteOnType:Z>> var) {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0083(){ + String str = + "public class X {\n" + + " Y<Z foo(){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + " foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0084(){ + String str = + "public class X {\n" + + " Y<Z> foo(){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " Y<<CompleteOnType:Z>> foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0085(){ + String str = + "public class X {\n" + + " void foo() throws Y<Z {\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0086(){ + String str = + "public class X {\n" + + " void foo() throws Y<Z> {\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() throws Y<<CompleteOnType:Z>> {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0087(){ + String str = + "public class X {\n" + + " <T extends Y<Z void foo(){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0088(){ + String str = + "public class X {\n" + + " <T extends Y<Z> void foo(){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends Y<<CompleteOnType:Z>>>\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0089(){ + String str = + "public class X {\n" + + " <T extends Y<Z>> void foo(){\n" + + " \n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends Y<<CompleteOnType:Z>>>void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0090(){ + String str = + "public class X {\n" + + " <T extends Y<Z int foo\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " int foo;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0091(){ + String str = + "public class X {\n" + + " <T extends Y<Z> int foo\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " int foo;\n" + + " public X() {\n" + + " }\n" + + " <T extends Y<<CompleteOnType:Z>>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0092(){ + String str = + "public class X {\n" + + " <T extends Y<Z>> int foo\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends Y<<CompleteOnType:Z>>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0093(){ + String str = + "public class X {\n" + + " <T extends Y<Z X\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0094(){ + String str = + "public class X {\n" + + " <T extends Y<Z> X\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends Y<<CompleteOnType:Z>>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0095(){ + String str = + "public class X {\n" + + " <T extends Y<Z>> X\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends Y<<CompleteOnType:Z>>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0096(){ + String str = + "public class X {\n" + + " <T extends Y<Z\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0097(){ + String str = + "public class X {\n" + + " <T extends Y<Z>\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends Y<<CompleteOnType:Z>>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0098(){ + String str = + "public class X {\n" + + " <T extends Y<Z>>\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends Y<<CompleteOnType:Z>>>\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0099(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z bar();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0100(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z> bar();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0101(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z>> bar();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0102(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z bar\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0103(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z> bar\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0104(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z>> bar\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0105(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0106(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z>\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0107(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " this.<Y, Y<Z>>\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0108(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " new <Y, Y<Z X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0109(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " new <Y, Y<Z> X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0110(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " new <Y, Y<Z>> X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0111(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " aaa.new <Y, Y<Z X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0112(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " aaa.new <Y, Y<Z> X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0113(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " aaa.new <Y, Y<Z>> X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0114(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " new V().new <Y, Y<Z X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0115(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " new V().new <Y, Y<Z> X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0116(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " new V().new <Y, Y<Z>> X();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0117(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " for(Y<Z var;;){}\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0118(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " for(Y<Z> var;;){}\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0119(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " for(Y<Z\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0120(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " for(Y<Z>\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0121(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " try {\n" + + " } catch(Y<Z e) {\n" + + " }\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0122(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " try {\n" + + " } catch(Y<Z> e) {\n" + + " }\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0123(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " try {\n" + + " } catch(Y<Z e\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0124(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " try {\n" + + " } catch(Y<Z> e\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0125(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " catch(Y<Z e\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0126(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " catch(Y<Z> e\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0127(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object a = (Y<Z ) e;\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnName:Z>"; + expectedParentNodeToString = "(Y < <CompleteOnName:Z>)"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Object a = (Y < <CompleteOnName:Z>);\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0128(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object a = (Y<Z> ) e;\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnName:Z>"; + expectedParentNodeToString = "(Y < <CompleteOnName:Z>)"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Object a = (Y < <CompleteOnName:Z>);\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0129(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " (Y<Z) e;\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnName:Z>"; + expectedParentNodeToString = "(Y < <CompleteOnName:Z>)"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " (Y < <CompleteOnName:Z>);\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0130(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " (Y<Z>) e;\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnName:Z>"; + expectedParentNodeToString = "(Y < <CompleteOnName:Z>)"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " (Y < <CompleteOnName:Z>);\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0131(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object[] o = new Y<Z[0];\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Object[] o = Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0132(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object[] o = new Y<Z>[0];\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Object[] o = Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0133(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object[] o = new Y<Z\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Object[] o = Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0134(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object[] o = new Y<Z>\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Object[] o = Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0135(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " new Y<Z\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0136(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " new Y<Z>\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0137(){ + String str = + "public class X {\n" + + " public X() {\n" + + " <Y<Z super(0);\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0138(){ + String str = + "public class X {\n" + + " public X() {\n" + + " <Y<Z> super(0);\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0139(){ + String str = + "public class X {\n" + + " public X() {\n" + + " <Y<Z>> super(0);\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0140(){ + String str = + "public class X {\n" + + " public X() {\n" + + " aaa.<Y<Z super(0);\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0141(){ + String str = + "public class X {\n" + + " public X() {\n" + + " aaa.<Y<Z> super(0);\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0142(){ + String str = + "public class X {\n" + + " public X() {\n" + + " aaa.<Y<Z>> super(0);\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0143(){ + String str = + "public class X {\n" + + " public X() {\n" + + " A.this.<Y<Z super(0);\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0144(){ + String str = + "public class X {\n" + + " public X() {\n" + + " A.this.<Y<Z> super(0);\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0145(){ + String str = + "public class X {\n" + + " public X() {\n" + + " A.this.<Y<Z>> super(0);\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " super();\n" + + " Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0146(){ + String str = + "public class X {\n" + + " W<Y<Z\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0147(){ + String str = + "public class X {\n" + + " W<Y<Z>\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0148(){ + String str = + "public class X {\n" + + " W<Y<Z>>\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0149(){ + String str = + "public class X {\n" + + " W<Y<Z>> var\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " W<Y<<CompleteOnType:Z>>> var;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0150(){ + String str = + "public class X {\n" + + " W<Y<Z>> var;\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " W<Y<<CompleteOnType:Z>>> var;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0151(){ + String str = + "public class X {\n" + + " W<A,B,C\n" + + "}"; + + + String completeBehind = "A,B"; + int cursorLocation = str.indexOf("A,B") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:B>"; + String expectedParentNodeToString = "W<A, <CompleteOnType:B>, C>"; + String completionIdentifier = "B"; + String expectedReplacedSource = "B"; + String expectedUnitDisplayString = + "public class X {\n" + + " W<A, <CompleteOnType:B>, C>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0152(){ + String str = + "public class X {\n" + + " W<A,B,C>\n" + + "}"; + + + String completeBehind = "A,B"; + int cursorLocation = str.indexOf("A,B") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:B>"; + String expectedParentNodeToString = "W<A, <CompleteOnType:B>, C>"; + String completionIdentifier = "B"; + String expectedReplacedSource = "B"; + String expectedUnitDisplayString = + "public class X {\n" + + " W<A, <CompleteOnType:B>, C>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0153(){ + String str = + "public class X {\n" + + " W<A,B,C> var\n" + + "}"; + + + String completeBehind = "A,B"; + int cursorLocation = str.indexOf("A,B") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:B>"; + String expectedParentNodeToString = "W<A, <CompleteOnType:B>, C>"; + String completionIdentifier = "B"; + String expectedReplacedSource = "B"; + String expectedUnitDisplayString = + "public class X {\n" + + " W<A, <CompleteOnType:B>, C> var;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0154(){ + String str = + "public class X {\n" + + " W<A,B,C> var;\n" + + "}"; + + + String completeBehind = "A,B"; + int cursorLocation = str.indexOf("A,B") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:B>"; + String expectedParentNodeToString = "W<A, <CompleteOnType:B>, C>"; + String completionIdentifier = "B"; + String expectedReplacedSource = "B"; + String expectedUnitDisplayString = + "public class X {\n" + + " W<A, <CompleteOnType:B>, C> var;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0155(){ + String str = + "public class X {\n" + + " Y<Z>.V<W> var;\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>.V<W>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>.V<W> var;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0156(){ + String str = + "public class X {\n" + + " Y<Z>.V<W> var\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>.V<W>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>.V<W> var;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0157(){ + String str = + "public class X {\n" + + " Y<Z>.V<W>\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>.V<W>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>.V<W>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0158(){ + String str = + "public class X {\n" + + " Y<Z>.V<W\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "Y<<CompleteOnType:Z>>.V<W>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " Y<<CompleteOnType:Z>>.V<W>;\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0159(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object a = (W<Y<Z> ) e;\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Object a = Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0160(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " ((Y<Z>) e).foo();\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnName:Z>"; + expectedParentNodeToString = "(Y < <CompleteOnName:Z>)"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " (Y < <CompleteOnName:Z>);\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0161(){ + String str = + "public class X <T extends Z<Y>> {\n" + + "}"; + + + String completeBehind = "Z"; + int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:Z>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X<T extends <CompleteOnType:Z>> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0162(){ + String str = + "public class X <T extends X.Z<Y>> {\n" + + "}"; + + + String completeBehind = "Z"; + int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:X.Z>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "X.Z"; + String expectedUnitDisplayString = + "public class X<T extends <CompleteOnType:X.Z>> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0163(){ + String str = + "public class X <T extends X<W>.Z<Y>> {\n" + + "}"; + + + String completeBehind = "Z"; + int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:X<W>.Z>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "X<W>.Z"; + String expectedUnitDisplayString = + "public class X<T extends <CompleteOnType:X<W>.Z>> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0164(){ + String str = + "public class X {\n" + + " <T extends X<W>.Z> foo() {}\n" + + "}"; + + + String completeBehind = "Z"; + int cursorLocation = str.indexOf("Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnType:X<W>.Z>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "X<W>.Z"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " <T extends <CompleteOnType:X<W>.Z>>foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +public void test0165(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object a = (W.Y<Z>) e;\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnName:Z>"; + expectedParentNodeToString = "(W.Y < <CompleteOnName:Z>)"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Object a = (W.Y < <CompleteOnName:Z>);\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void test0166(){ + String str = + "public class X {\n" + + " void foo() {\n" + + " Object a = (W<U>.Y<Z>) e;\n" + + " }\n" + + "}"; + + + String completeBehind = "Y<Z"; + int cursorLocation = str.indexOf("Y<Z") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<NONE>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "<NONE>"; + String expectedReplacedSource = "<NONE>"; + String expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "<CompleteOnType:Z>"; + expectedParentNodeToString = "Y<<CompleteOnType:Z>>"; + completionIdentifier = "Z"; + expectedReplacedSource = "Z"; + expectedUnitDisplayString = + "public class X {\n" + + " public X() {\n" + + " }\n" + + " void foo() {\n" + + " Object a = W<U>.Y<<CompleteOnType:Z>>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +public void _testXXX2(){ + String str = + "public class X extends Y. {\n" + + "}"; + + + String completeBehind = "Y"; + int cursorLocation = str.indexOf("Y") + completeBehind.length() - 1; + String expectedCompletionNodeToString = "<CompleteOnClass:Y>"; + String expectedParentNodeToString = "<NONE>"; + String completionIdentifier = "Z"; + String expectedReplacedSource = "Z"; + String expectedUnitDisplayString = + "public class X extends <CompleteOnClass:Y> {\n" + + " public X() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); +} +} 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 15c7e997d0..2b17661f53 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 @@ -333,7 +333,7 @@ public void test014() { /* * https://bugs.eclipse.org/bugs/show_bug.cgi?id=60848 */ -public void test015() { +public void _test015() { this.runNegativeTest( new String[] { "X.java", diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java index c615bc7e0a..a3161ac024 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java @@ -176,7 +176,9 @@ public void enterClass( int nameSourceStart, int nameSourceEnd, char[] superclass, - char[][] superinterfaces) { + char[][] superinterfaces, + char[][] typeParameterNames, + char[][][] typeParameterBounds) { if (currentType == null) { // top level type @@ -227,7 +229,9 @@ public void enterConstructor( int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, - char[][] exceptionTypes) { + char[][] exceptionTypes, + char[][] typeParameterNames, + char[][][] typeParameterBounds) { currentType.addMethod( currentMethod = @@ -241,6 +245,8 @@ public void enterConstructor( parameterTypes, parameterNames, exceptionTypes, + typeParameterNames, + typeParameterBounds, source)); } /** @@ -292,7 +298,9 @@ public void enterInterface( char[] name, int nameSourceStart, int nameSourceEnd, - char[][] superinterfaces) { + char[][] superinterfaces, + char[][] typeParameterNames, + char[][][] typeParameterBounds) { if (currentType == null) { // top level type @@ -340,7 +348,9 @@ public void enterMethod( int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, - char[][] exceptionTypes) { + char[][] exceptionTypes, + char[][] typeParameterNames, + char[][][] typeParameterBounds) { currentType.addMethod( currentMethod = @@ -354,6 +364,8 @@ public void enterMethod( parameterTypes, parameterNames, exceptionTypes, + typeParameterNames, + typeParameterBounds, source)); } /** diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java index 0da2938f27..2943475309 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java @@ -26,6 +26,9 @@ public class SourceMethod implements ISourceMethod, IConstants { private char[][] exceptionTypeNames; private char[] source; private String explicitConstructorCall; + private char[][] typeParameterNames; + private char[][][] typeParameterBounds; + public SourceMethod( int declarationStart, int modifiers, @@ -36,6 +39,8 @@ public SourceMethod( char[][] argumentTypeNames, char[][] argumentNames, char[][] exceptionTypeNames, + char[][] typeParameterNames, + char[][][] typeParameterBounds, char[] source) { this.declarationStart = declarationStart; @@ -47,6 +52,8 @@ public SourceMethod( this.argumentTypeNames = argumentTypeNames; this.argumentNames = argumentNames; this.exceptionTypeNames = exceptionTypeNames; + this.typeParameterNames = typeParameterNames; + this.typeParameterBounds = typeParameterBounds; this.source = source; } public String displayModifiers() { @@ -109,6 +116,12 @@ public char[] getReturnTypeName() { public char[] getSelector() { return selector; } +public char[][][] getTypeParameterBounds() { + return typeParameterBounds; +} +public char[][] getTypeParameterNames() { + return typeParameterNames; +} public boolean isConstructor() { return returnTypeName == null; } 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 878b57f58e..3e0f06c52a 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 @@ -45,6 +45,7 @@ public class TestAll extends TestCase { testClasses.add(ReferenceTypeCompletionTest.class); testClasses.add(CompletionParserTest2.class); testClasses.add(CompletionParserTestKeyword.class); + testClasses.add(GenericsCompletionParserTest.class); /* selection tests */ testClasses.add(ExplicitConstructorInvocationSelectionTest.class); @@ -53,6 +54,7 @@ public class TestAll extends TestCase { /* recovery tests */ testClasses.add(DietRecoveryTest.class); + testClasses.add(GenericDietRecoveryTest.class); /* source element parser tests */ testClasses.add(SourceElementParserTest.class); @@ -61,6 +63,7 @@ public class TestAll extends TestCase { testClasses.add(SyntaxErrorTest.class); testClasses.add(DualParseSyntaxErrorTest.class); testClasses.add(ParserTest.class); + testClasses.add(ComplianceDiagnoseTest.class); return AbstractCompilerTest.suite(TestAll.class.getName(), CompilerTestSetup.class, testClasses); } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java index cb5ef1ba9f..2c2ca5edf6 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java @@ -67,7 +67,7 @@ public void acceptUnknownReference(char[] name, int sourcePosition) {} /** * enterClass method comment. */ -public void enterClass(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[] superclass, char[][] superinterfaces) {} +public void enterClass(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[] superclass, char[][] superinterfaces, char[][] typeParameterNames, char[][][] typeParameterBounds) {} /** * enterCompilationUnit method comment. */ @@ -75,7 +75,7 @@ public void enterCompilationUnit() {} /** * enterConstructor method comment. */ -public void enterConstructor(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, char[][] exceptionTypes) {} +public void enterConstructor(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, char[][] exceptionTypes, char[][] typeParameterNames, char[][][] typeParameterBounds) {} /** * enterField method comment. */ @@ -83,11 +83,11 @@ public void enterField(int declarationStart, int modifiers, char[] type, char[] /** * enterInterface method comment. */ -public void enterInterface(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[][] superinterfaces) {} +public void enterInterface(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[][] superinterfaces, char[][] typeParameterNames, char[][][] typeParameterBounds) {} /** * enterMethod method comment. */ -public void enterMethod(int declarationStart, int modifiers, char[] returnType, char[] name, int nameSourceStart, int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, char[][] exceptionTypes) {} +public void enterMethod(int declarationStart, int modifiers, char[] returnType, char[] name, int nameSourceStart, int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, char[][] exceptionTypes, char[][] typeParameterNames, char[][][] typeParameterBounds) {} /** * exitClass method comment. */ 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 39e9725b31..87e77fa2c5 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 @@ -216,7 +216,19 @@ public abstract class AbstractRegressionTest extends AbstractCompilerTest implem options, requestor, problemFactory); - batchCompiler.compile(Util.compilationUnits(testFiles)); // compile all files together + try { + batchCompiler.compile(Util.compilationUnits(testFiles)); // compile all files together + } catch(RuntimeException e) { + System.out.println(getClass().getName() + '#' + getName()); + e.printStackTrace(); + for (int i = 0; i < testFiles.length; i += 2) { + System.out.print(testFiles[i]); + System.out.println(" ["); //$NON-NLS-1$ + System.out.println(testFiles[i + 1]); + System.out.println("]"); //$NON-NLS-1$ + } + throw e; + } if (!requestor.hasErrors) { String sourceFile = testFiles[0]; 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 f1b25bc3bd..1966a5f58a 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 @@ -122,6 +122,8 @@ public void test005() { } String expectedOutput = + " // Method descriptor #7 ()V\n" + + " // Stack: 1, Locals: 0\n" + " static {};\n" + " 0 iconst_2\n" + " 1 anewarray #4 java/lang/Object\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java index 87c0403e23..c05a6982c7 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CastTest.java @@ -83,7 +83,16 @@ public void test001() { " 6 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + " 9 ldc #23 <String \"SUCCESS\">\n" + " 11 invokevirtual #29 <Method java/io/PrintStream.print(Ljava/lang/String;)V>\n" + - " 14 return\n"; + " 14 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 3]\n" + + " [pc: 4, line: 4]\n" + + " [pc: 6, line: 5]\n" + + " [pc: 14, line: 6]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 15] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 4, pc: 15] local: c1 index: 1 type: Ljava/lang/Cloneable;\n" + + " [pc: 6, pc: 15] local: c2 index: 2 type: Ljava/lang/Cloneable;\n"; if (actualOutput.indexOf(expectedOutput) == -1){ System.out.println(Util.displayString(actualOutput, 2)); } @@ -527,7 +536,7 @@ public void test014() { "1. ERROR in X.java (at line 2)\n" + " boolean b = new Cloneable() {} instanceof Cloneable;\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "The expression of type <anonymous implementation of Cloneable> is already an instance of type Cloneable\n" + + "The expression of type new Cloneable(){} is already an instance of type Cloneable\n" + "----------\n", null, true, @@ -631,18 +640,13 @@ public void test018() { "}\n" + "public class X extends Y {\n" + " Y[] bar() {\n" + - " return (Y[]) Y.foo(new double[] {});\n" + + " return (Y[]) Y.foo(new double[] {});\n" + // no cast warning until method is applicable " }\n" + "}\n" }, "----------\n" + "1. ERROR in X.java (at line 8)\n" + " return (Y[]) Y.foo(new double[] {});\n" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + - "Unnecessary cast to type Y[] for expression of type Y[]\n" + - "----------\n" + - "2. ERROR in X.java (at line 8)\n" + - " return (Y[]) Y.foo(new double[] {});\n" + " ^^^\n" + "The method foo(int[]) in the type Y is not applicable for the arguments (double[])\n" + "----------\n", @@ -1270,6 +1274,7 @@ public void test034() { } assertTrue("unexpected bytecode sequence", actualOutput.indexOf(expectedOutput) != -1); } + public static Class testClass() { return CastTest.class; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest.java index 1406245d44..269e64c27d 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest.java @@ -1969,7 +1969,7 @@ public class ClassFileReaderTest extends AbstractRegressionTest { " 29 ireturn\n" + " Exception Table:\n" + " [pc: 0, pc: 7] -> 14 when : any\n" + - " [pc: 9, pc: 14] -> 14 when : any\n" + + " [pc: 9, pc: 18] -> 14 when : any\n" + " [pc: 25, pc: 28] -> 14 when : any\n" + " Line numbers:\n" + " [pc: 0, line: 6]\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CollisionCase.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CollisionCase.java index 7dc7758c57..47d5b511fa 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CollisionCase.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CollisionCase.java @@ -63,7 +63,7 @@ public void test002() { "1. ERROR in X.java (at line 3)\n" + " foo.bar abar; \n" + " ^^^^^^^\n" + - "foo.bar cannot be resolved (or is not a valid type) for the field X.abar\n" + + "foo.bar 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/Compliance_1_3.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java index c010d7bad6..9781991c0e 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java @@ -85,7 +85,7 @@ public void test001() { "1. ERROR in p1\\Test.java (at line 10)\n" + " M m; \n" + " ^\n" + - "The field type M is defined in an inherited type and an enclosing scope\n" + + "The type M is defined in an inherited type and an enclosing scope\n" + "----------\n" ); } @@ -1486,12 +1486,12 @@ public void test040() { "1. ERROR in X.java (at line 6)\n" + " class Y extends Homonym {}; \n" + " ^^^^^^^\n" + - "Superclass Homonym is defined in an inherited type and an enclosing scope\n" + + "The type Homonym is defined in an inherited type and an enclosing scope\n" + "----------\n" + "2. ERROR in X.java (at line 13)\n" + " class Y extends Homonym {}; \n" + " ^^^^^^^\n" + - "Superclass Homonym is defined in an inherited type and an enclosing scope\n" + + "The type Homonym is defined in an inherited type and an enclosing scope\n" + "----------\n"); } /* @@ -1641,7 +1641,7 @@ public void test044() { } String expectedOutput = - " 1 invokevirtual #19 <Method java/lang/Object.clone()Ljava/lang/Object;>\n"; + " 1 invokevirtual #19 <Method java/lang/Object.clone()Ljava/lang/Object;>\n"; if (actualOutput.indexOf(expectedOutput) == -1) { System.out.println(org.eclipse.jdt.core.tests.util.Util.displayString(actualOutput, 2)); @@ -2192,7 +2192,7 @@ public void test061() { "1. ERROR in p\\X.java (at line 6)\n" + " Z someField; \n" + " ^\n" + - "The field type Z is defined in an inherited type and an enclosing scope\n" + + "The type Z is defined in an inherited type and an enclosing scope\n" + "----------\n" + "----------\n" + "1. WARNING in q\\Y.java (at line 3)\n" + @@ -2790,6 +2790,33 @@ public void test079() { "----------\n" ); } +/* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67643 + * from 1.5 source level on most specific common super type is allowed + */ +public void test080() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "public class X {\n" + + " private static class C1 extends ArrayList {\n" + + " }\n" + + " private static class C2 extends ArrayList {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " ArrayList list = args == null ? new C1(): new C2();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " ArrayList list = args == null ? new C1(): new C2();\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Incompatible conditional operand types C1 and C2\n" + + "----------\n"); +} public static Class testClass() { return Compliance_1_3.class; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java index 0a3524dd4c..8abf38e299 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java @@ -2406,7 +2406,7 @@ public void test073() { "1. ERROR in X.java (at line 14)\n" + " System.out.println(new Local());\n" + " ^^^^^\n" + - "Local cannot be resolved or is not a type\n" + + "Local cannot be resolved to a type\n" + "----------\n"); } @@ -2446,12 +2446,12 @@ public void test074() { "1. ERROR in X.java (at line 15)\n" + " System.out.print(new Local()); \n" + " ^^^^^\n" + - "Local cannot be resolved or is not a type\n" + + "Local cannot be resolved to a type\n" + "----------\n" + "2. ERROR in X.java (at line 17)\n" + " System.out.println(new Local(){ \n" + " ^^^^^\n" + - "Local cannot be resolved or is not a type\n" + + "Local cannot be resolved to a type\n" + "----------\n"); } public void test075() { @@ -2613,6 +2613,34 @@ public void test079() { "----------\n" ); } +/* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67643 + * from 1.5 source level on most specific common super type is allowed + */ +public void test080() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "public class X {\n" + + " private static class C1 extends ArrayList {\n" + + " }\n" + + " private static class C2 extends ArrayList {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " ArrayList list = args == null ? new C1(): new C2();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " ArrayList list = args == null ? new C1(): new C2();\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Incompatible conditional operand types C1 and C2\n" + + "----------\n"); +} + public static Class testClass() { return Compliance_1_4.class; } 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 new file mode 100644 index 0000000000..0e8f87c2d5 --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java @@ -0,0 +1,2673 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.regression; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +import junit.framework.Test; + +import org.eclipse.jdt.core.ToolFactory; +import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; + +public class Compliance_1_5 extends AbstractRegressionTest { +boolean docSupport = false; + +public Compliance_1_5(String name) { + super(name); +} + +/* + * Toggle compiler in mode -1.5 + */ +protected Map getCompilerOptions() { + Map options = super.getCompilerOptions(); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + if (docSupport) { + options.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); + options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.ERROR); + } + return options; +} +public static Test suite() { + return buildTestSuite(testClass()); +} +// Use this static initializer to specify subset for tests +// All specified tests which does not belong to the class are skipped... +static { + // Names of tests to run: can be "testBugXXXX" or "BugXXXX") +// testsNames = new String[] { "Bug58069" }; + // Numbers of tests to run: "test<number>" will be run for each number of this array +// testsNumbers = new int[] { 78 }; + // Range numbers of tests to run: all tests between "test<first>" and "test<last>" will be run for { first, last } +// testsRange = new int[] { 76, -1 }; +} +/* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ +protected void setUp() throws Exception { + super.setUp(); + // Javadoc disabled by default + docSupport = false; +} +public void test001() { + this.runConformTest( + new String[] { + "p1/Test.java", + "package p1; \n"+ + "public class Test { \n"+ + " public static void main(String[] arguments) { \n"+ + " new Test().foo(); \n"+ + " } \n"+ + " class M { \n"+ + " } \n"+ + " void foo(){ \n"+ + " class Y extends Secondary { \n"+ + " M m; \n"+ + " }; \n"+ + " System.out.println(\"SUCCESS\"); \n" + + " } \n"+ + "} \n" + + "class Secondary { \n" + + " class M {} \n" + + "} \n" + }, + "SUCCESS"); +} +public void test002() { + this.runConformTest( + new String[] { + "p1/Test.java", + "package p1; \n"+ + "public class Test { \n"+ + " public static void main(String[] arguments) { \n"+ + " new Test().foo(); \n"+ + " } \n"+ + " String bar() { \n"+ + " return \"FAILED\"; \n" + + " } \n"+ + " void foo(){ \n"+ + " class Y extends Secondary { \n"+ + " String z = bar(); \n" + + " }; \n"+ + " System.out.println(new Y().z); \n" + + " } \n"+ + "} \n" + + "class Secondary { \n" + + " String bar(){ return \"SUCCESS\"; } \n" + + "} \n" + }, + "SUCCESS"); +} +public void test003() { + this.runConformTest( + new String[] { + "p1/Test.java", + "package p1; \n"+ + "public class Test { \n"+ + " public static void main(String[] arguments) { \n"+ + " new Test().foo(); \n"+ + " } \n"+ + " String bar = \"FAILED\";"+ + " void foo(){ \n"+ + " class Y extends Secondary { \n"+ + " String z = bar; \n"+ + " }; \n"+ + " System.out.println(new Y().z); \n" + + " } \n"+ + "} \n" + + "class Secondary { \n" + + " String bar = \"SUCCESS\"; \n" + + "} \n" + }, + "SUCCESS"); +} +public void test004() { + this.runConformTest( + new String[] { + "p1/Test.java", + "package p1; \n"+ + "public class Test { \n"+ + " public static void main(String[] arguments) { \n"+ + " new Test().foo(); \n"+ + " } \n"+ + " String bar() { \n"+ + " return \"SUCCESS\"; \n" + + " } \n"+ + " void foo(){ \n"+ + " class Y extends Secondary { \n"+ + " String z = bar(); \n" + + " }; \n"+ + " System.out.println(new Y().z); \n" + + " } \n"+ + "} \n" + + "class Secondary { \n" + + " private String bar(){ return \"FAILED\"; } \n" + + "} \n" + }, + "SUCCESS"); +} +public void test005() { + this.runConformTest( + new String[] { + "p1/Test.java", + "package p1; \n"+ + "public class Test { \n"+ + " public static void main(String[] arguments) { \n"+ + " new Test().foo(); \n"+ + " } \n"+ + " String bar = \"SUCCESS\";"+ + " void foo(){ \n"+ + " class Y extends Secondary { \n"+ + " String z = bar; \n"+ + " }; \n"+ + " System.out.println(new Y().z); \n" + + " } \n"+ + "} \n" + + "class Secondary { \n" + + " private String bar = \"FAILED\"; \n" + + "} \n" + }, + "SUCCESS"); +} +public void test006() { + this.runNegativeTest( + new String[] { + "p1/Test.java", + "package p1; \n"+ + "public class Test { \n"+ + " public static void main(String[] arguments) { \n"+ + " new Test().foo(); \n"+ + " } \n"+ + " String bar() { \n"+ + " return \"FAILED\"; \n" + + " } \n"+ + " void foo(){ \n"+ + " class Y extends Secondary { \n"+ + " String z = bar(); \n" + + " }; \n"+ + " System.out.println(new Y().z); \n" + + " } \n"+ + "} \n" + + "class Secondary { \n" + + " String bar(int i){ return \"SUCCESS\"; } \n" + + "} \n" + }, + "----------\n" + + "1. ERROR in p1\\Test.java (at line 11)\n" + + " String z = bar(); \n" + + " ^^^\n" + + "The method bar(int) in the type Secondary is not applicable for the arguments ()\n" + + "----------\n" + ); +} +public void test007() { + this.runConformTest( + new String[] { + "p1/Test.java", + "package p1; \n"+ + "public class Test { \n"+ + " public static void main(String[] arguments) { \n"+ + " try { \n" + + " throw null; \n"+ + " } catch(NullPointerException e){ \n" + + " System.out.println(\"SUCCESS\"); \n" + + " } \n" + + " } \n"+ + "} \n" + }, + "SUCCESS"); +} +public void test008() { + this.runNegativeTest( + new String[] { + "p1/Test.java", + "package p1; \n"+ + "import Test2; \n" + + "import Test2.Member; \n" + + "public class Test { \n"+ + " public static void main(String[] arguments) { \n"+ + " } \n"+ + "} \n", + "Test2.java", + "public class Test2 { \n"+ + " public class Member { \n" + + " } \n"+ + "} \n" + }, + "----------\n" + + "1. ERROR in p1\\Test.java (at line 2)\n" + + " import Test2; \n" + + " ^^^^^\n" + + "The import Test2 cannot be resolved\n" + + "----------\n" + + "2. ERROR in p1\\Test.java (at line 3)\n" + + " import Test2.Member; \n" + + " ^^^^^\n" + + "The import Test2 cannot be resolved\n" + + "----------\n" + ); +} +// binary compatibility +public void test009() { + this.runConformTest( + new String[] { + "p1/Z.java", + "package p1; \n"+ + "public class Z { \n" + + " public static void main(String[] arguments) { \n"+ + " Y y = new Y(); \n" + + " System.out.print(y.field); \n" + + " System.out.print(y.staticField); \n" + + " System.out.print(y.method()); \n" + + " System.out.println(y.staticMethod()); \n" + + " } \n"+ + "} \n", + "p1/X.java", + "package p1; \n"+ + "public class X { \n"+ + " public String field = \"X.field-\"; \n" + + " public static String staticField = \"X.staticField-\"; \n" + + " public String method(){ return \"X.method()-\"; } \n" + + " public static String staticMethod(){ return \"X.staticMethod()-\"; } \n" + + "} \n", + "p1/Y.java", + "package p1; \n"+ + "public class Y extends X { \n"+ + "} \n" + }, + "X.field-X.staticField-X.method()-X.staticMethod()-"); + + this.runConformTest( + new String[] { + "p1/Y.java", + "package p1; \n"+ + "public class Y extends X { \n"+ + " public static void main(String[] arguments) { \n"+ + " Z.main(arguments); \n" + + " } \n" + + " public String field = \"Y.field-\"; \n" + + " public static String staticField = \"Y.staticField-\"; \n" + + " public String method(){ return \"Y.method()-\"; } \n" + + " public static String staticMethod(){ return \"Y.staticMethod()-\"; } \n" + + "} \n" + }, + "Y.field-Y.staticField-Y.method()-Y.staticMethod()-", // expected output + null, // use default class-path + false, // do not flush previous output dir content + null); // no special vm args +} + +// check actualReceiverType when array type +public void test010() { + this.runConformTest( + new String[] { + "p1/Z.java", + "package p1; \n"+ + "public class Z { \n" + + " public static void main(String[] arguments) { \n"+ + " String[] s = new String[]{\"SUCCESS\" }; \n" + + " System.out.print(s.length); \n" + + " System.out.print(((String[])s.clone())[0]); \n" + + " } \n"+ + "} \n" + }, + "1SUCCESS"); +} +// test unreachable code complaints +public void test011() { + this.runNegativeTest( + new String[] { + "p1/X.java", + "package p1; \n"+ + "public class X { \n"+ + " void foo() { \n"+ + " while (false); \n" + + " while (false) System.out.println(\"unreachable\"); \n" + + " do ; while (false); \n" + + " do System.out.println(\"unreachable\"); while (false); \n" + + " for (;false;); \n" + + " for (;false;) System.out.println(\"unreachable\"); \n" + + " if (false); \n" + + " if (false)System.out.println(\"unreachable\"); \n" + + " } \n" + + "} \n" + }, + "----------\n" + + "1. ERROR in p1\\X.java (at line 4)\n" + + " while (false); \n" + + " ^\n" + + "Unreachable code\n" + + "----------\n" + + "2. ERROR in p1\\X.java (at line 5)\n" + + " while (false) System.out.println(\"unreachable\"); \n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Unreachable code\n" + + "----------\n" + + "3. ERROR in p1\\X.java (at line 8)\n" + + " for (;false;); \n" + + " ^\n" + + "Unreachable code\n" + + "----------\n" + + "4. ERROR in p1\\X.java (at line 9)\n" + + " for (;false;) System.out.println(\"unreachable\"); \n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Unreachable code\n" + + "----------\n" + ); +} +// binary compatibility +public void test012() { + this.runConformTest( + new String[] { + "p1/Y.java", + "package p1; \n" + + "class Store { \n" + + " String value; \n" + + " Store(String value){ \n" + + " this.value = value; \n" + + " } \n" + + "} \n" + + "class Top { \n" + + " static String bar = \"Top.bar\"; \n" + + " String foo = \"Top.foo\"; \n" + + " Store store = new Store(\"Top.store\"); \n" + + " static Store sstore = new Store(\"Top.sstore\"); \n" + + " static Top ss = new Top(); \n" + + "} \n" + + "public class Y extends Updated { \n" + + " public static void main(String[] arguments) { \n" + + " new Y().test(); \n" + + " } \n" + + " void test() { \n" + + " System.out.print(\"*** FIELD ACCESS ***\"); \n" + + " System.out.print(\"*1* new Updated().bar: \" + new Updated().bar); \n" + + " System.out.print(\"*2* new Updated().foo: \" + new Updated().foo); \n" + + " System.out.print(\"*3* new Y().foo: \" + new Y().foo); \n" + + " System.out.print(\"*4* new Y().bar: \" + new Y().bar); \n" + + " System.out.print(\"*5* bar: \" + bar); \n" + + " System.out.print(\"*6* foo: \" + foo); \n" + + " System.out.print(\"*7* Y.bar: \" + Y.bar); \n" + + " System.out.print(\"*8* this.bar: \" + this.bar); \n" + + " System.out.print(\"*9* this.foo: \" + this.foo); \n" + + " System.out.print(\"*10* store.value: \" + store.value); \n" + + " System.out.print(\"*11* sstore.value: \" + sstore.value); \n" + + " System.out.print(\"*12* ss.sstore.value: \" + ss.sstore.value); \n" + + " } \n" + + "} \n", + "p1/Updated.java", + "package p1; \n" + + "public class Updated extends Top { \n" + + "} \n" + }, + "*** FIELD ACCESS ***" + +"*1* new Updated().bar: Top.bar" + +"*2* new Updated().foo: Top.foo" + +"*3* new Y().foo: Top.foo" + +"*4* new Y().bar: Top.bar" + +"*5* bar: Top.bar" + +"*6* foo: Top.foo" + +"*7* Y.bar: Top.bar" + +"*8* this.bar: Top.bar" + +"*9* this.foo: Top.foo" + +"*10* store.value: Top.store" + +"*11* sstore.value: Top.sstore" + +"*12* ss.sstore.value: Top.sstore"); + + this.runConformTest( + new String[] { + "p1/Updated.java", + "package p1; \n"+ + "public class Updated extends Top { \n"+ + " public static void main(String[] arguments) { \n"+ + " Y.main(arguments); \n" + + " } \n" + + " static String bar = \"Updated.bar\"; \n" + + " String foo = \"Updated.foo\"; \n" + + " Store store = new Store(\"Updated.store\"); \n" + + " static Store sstore = new Store(\"Updated.sstore\"); \n" + + " static Updated ss = new Updated(); \n" + + "} \n" + }, + "*** FIELD ACCESS ***" + +"*1* new Updated().bar: Updated.bar" + +"*2* new Updated().foo: Updated.foo" + +"*3* new Y().foo: Updated.foo" + +"*4* new Y().bar: Updated.bar" + +"*5* bar: Top.bar" + +"*6* foo: Updated.foo" + +"*7* Y.bar: Updated.bar" + +"*8* this.bar: Updated.bar" + +"*9* this.foo: Updated.foo" + +"*10* store.value: Updated.store" + +"*11* sstore.value: Top.sstore" + +"*12* ss.sstore.value: Top.sstore", + null, // use default class-path + false, // do not flush previous output dir content + null); // no special vm args +} +// binary compatibility +public void test013() { + this.runConformTest( + new String[] { + "p1/Y.java", + "package p1; \n" + + "class Store { \n" + + " String value; \n" + + " Store(String value){ \n" + + " this.value = value; \n" + + " } \n" + + "} \n" + + "class Top { \n" + + " static String bar() { return \"Top.bar()\"; } \n" + + " String foo() { return \"Top.foo()\"; } \n" + + "} \n" + + "public class Y extends Updated { \n" + + " public static void main(String[] arguments) { \n" + + " new Y().test(); \n" + + " } \n" + + " void test() { \n" + + " System.out.print(\"*** METHOD ACCESS ***\"); \n" + + " System.out.print(\"*1* new Updated().bar(): \" + new Updated().bar()); \n" + + " System.out.print(\"*2* new Updated().foo(): \" + new Updated().foo()); \n" + + " System.out.print(\"*3* new Y().foo(): \" + new Y().foo()); \n" + + " System.out.print(\"*4* new Y().bar(): \" + new Y().bar()); \n" + + " System.out.print(\"*5* bar(): \" + bar()); \n" + + " System.out.print(\"*6* foo(): \" + foo()); \n" + + " System.out.print(\"*7* Y.bar(): \" + Y.bar()); \n" + + " System.out.print(\"*8* this.bar(): \" + this.bar()); \n" + + " System.out.print(\"*9* this.foo(): \" + this.foo()); \n" + + " } \n" + + "} \n", + "p1/Updated.java", + "package p1; \n" + + "public class Updated extends Top { \n" + + "} \n" + }, + "*** METHOD ACCESS ***" + +"*1* new Updated().bar(): Top.bar()" + +"*2* new Updated().foo(): Top.foo()" + +"*3* new Y().foo(): Top.foo()" + +"*4* new Y().bar(): Top.bar()" + +"*5* bar(): Top.bar()" + +"*6* foo(): Top.foo()" + +"*7* Y.bar(): Top.bar()" + +"*8* this.bar(): Top.bar()" + +"*9* this.foo(): Top.foo()"); + + this.runConformTest( + new String[] { + "p1/Updated.java", + "package p1; \n"+ + "public class Updated extends Top { \n"+ + " public static void main(String[] arguments) { \n"+ + " Y.main(arguments); \n" + + " } \n" + + " static String bar() { return \"Updated.bar()\"; } \n" + + " String foo() { return \"Updated.foo()\"; } \n" + + "} \n" + }, + "*** METHOD ACCESS ***" + +"*1* new Updated().bar(): Updated.bar()" + +"*2* new Updated().foo(): Updated.foo()" + +"*3* new Y().foo(): Updated.foo()" + +"*4* new Y().bar(): Updated.bar()" + +"*5* bar(): Top.bar()" + +"*6* foo(): Updated.foo()" + +"*7* Y.bar(): Updated.bar()" + +"*8* this.bar(): Updated.bar()" + +"*9* this.foo(): Updated.foo()", + null, // use default class-path + false, // do not flush previous output dir content + null); // no special vm args +} + +public void test014() { + this.runConformTest( + new String[] { + "p1/X.java", + "package p1; \n" + + "class T { \n" + + " void foo(boolean b) { \n" + + " System.out.print(\"T.foo(boolean)#\"); \n" + + " } \n" + + " boolean bar = false; \n" + + " class Member { \n" + + " void display(){ System.out.print(\"T.Member#\"); } \n" + + " } \n" + + "} \n" + + "public class X { \n" + + " void foo(int i) { \n" + + " System.out.println(\"X.foo(int)#\"); \n" + + " } \n" + + " int bar; \n" + + " class Member { \n" + + " void display(){ System.out.print(\"X.Member#\"); } \n" + + " } \n" + + " public static void main(String[] arguments) { \n" + + " new X().bar(); \n" + + " } \n" + + " void bar() { \n" + + " new T() { \n" + + " { \n" + + " foo(true); \n" + + " System.out.print((boolean)bar + \"#\"); \n" + + " Member m = new Member(); \n" + + " m.display(); \n" + + " } \n" + + " }; \n" + + " } \n" + + "} \n" + }, + "T.foo(boolean)#false#T.Member"); +} + +/* + * check handling of default abstract methods + */ +public void test015() { + this.runConformTest( + new String[] { + "p1/X.java", + "package p1; \n"+ + "public class X { \n"+ + " public static void main(String[] arguments) { \n"+ + " C c = new C() { \n"+ + " public void doSomething(){ \n"+ + " System.out.println(\"SUCCESS\"); \n"+ + " } \n"+ + " }; \n"+ + " c.doSomething(); \n"+ + " } \n"+ + "} \n"+ + "interface I { \n"+ + " void doSomething(); \n"+ + "} \n"+ + "abstract class C implements I { \n"+ + "} \n" + }, + "SUCCESS"); +} + +public void test016() { + this.runNegativeTest( + new String[] { + "X.java", + "class T { \n"+ + " void foo(boolean b) {} \n"+ + "} \n"+ + "public class X { \n"+ + " void foo(int i) {} \n"+ + " void bar() { \n"+ + " new T() { \n"+ + " { \n"+ + " foo(0); \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + "} \n" + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " foo(0); \n" + + " ^^^\n" + + "The method foo(boolean) in the type T is not applicable for the arguments (int)\n" + + "----------\n"); +} + +public void test017() { + this.runConformTest( + new String[] { + "X.java", + "class T { \n"+ + " void foo(boolean b) { System.out.println(\"SUCCESS\"); } \n"+ + "} \n"+ + "public class X { \n"+ + " void foo(int i) {} \n"+ + " void bar() { \n"+ + " new T() { \n"+ + " { \n"+ + " foo(false); \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + " public static void main(String[] arguments) { \n"+ + " new X().bar(); \n" + + " } \n"+ + "} \n" + }, + "SUCCESS"); +} + +public void test018() { + this.runConformTest( + new String[] { + "X.java", + "class T { \n"+ + " void foo(int j) { System.out.println(\"SUCCESS\"); } \n"+ + "} \n"+ + "public class X { \n"+ + " void foo(int i) {} \n"+ + " void bar() { \n"+ + " new T() { \n"+ + " { \n"+ + " foo(0); \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + " public static void main(String[] arguments) { \n"+ + " new X().bar(); \n" + + " } \n"+ + "} \n" + }, + "SUCCESS"); +} +public void test019() { + this.runConformTest( + new String[] { + "X.java", + "class T { \n"+ + " void foo(int j) { System.out.println(\"SUCCESS\"); } \n"+ + "} \n"+ + "class U { \n"+ + " void foo(int j) { System.out.println(\"FAILED\"); } \n"+ + "} \n"+ + "public class X extends U { \n"+ + " void bar() { \n"+ + " new T() { \n"+ + " { \n"+ + " foo(0); \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + " public static void main(String[] arguments) { \n"+ + " new X().bar(); \n" + + " } \n"+ + "} \n" + }, + "SUCCESS"); +} +public void test020() { + this.runConformTest( + new String[] { + "X.java", + "class T { \n"+ + " void foo(int j) { System.out.println(\"SUCCESS\"); } \n"+ + "} \n"+ + "class U { \n"+ + " void foo(boolean j) { System.out.println(\"FAILED\"); } \n"+ + "} \n"+ + "public class X extends U { \n"+ + " void bar() { \n"+ + " new T() { \n"+ + " { \n"+ + " foo(0); \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + " public static void main(String[] arguments) { \n"+ + " new X().bar(); \n" + + " } \n"+ + "} \n" + }, + "SUCCESS"); +} +// binary check for 11511 +public void test021() { + this.runConformTest( + new String[] { + "p1/Z.java", + "package p1; \n" + + "public class Z extends AbstractA { \n" + + " public static void main(String[] arguments) { \n" + + " new Z().init(); \n" + + " } \n" + + "} \n" + + "abstract class AbstractB implements K { \n" + + " public void init() { \n" + + " System.out.println(\"AbstractB.init()\"); \n" + + " } \n" + + "} \n" + + "interface K { \n" + + " void init(); \n" + + " void init(int i); \n" + + "} \n", + "p1/AbstractA.java", + "package p1; \n" + + "public abstract class AbstractA extends AbstractB implements K { \n" + + " public void init(int i) { \n" + + " } \n" + + "} \n" + }, + "AbstractB.init()"); // no special vm args + + // check that "new Z().init()" is bound to "Z.init()" + String computedReferences = findReferences(OUTPUT_DIR + "/p1/Z.class"); + boolean check = + computedReferences.indexOf("constructorRef/Z/0") >= 0 + && computedReferences.indexOf("methodRef/init/0") >= 0; + if (!check){ + System.out.println(computedReferences); + } + assertTrue("did not bind 'new Z().init()' to Z.init()'", check); +} + /* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=11511 + * variant - applicable error diagnosis + */ +public void test022() { + + this.runNegativeTest( + new String[] { + "p1/T.java", + "package p1; \n"+ + "interface II {} \n"+ + "class TT { \n"+ + " void foo(boolean b) {} \n"+ + " void foo(int i, boolean b) {} \n"+ + " void foo(String s) {} \n"+ + "} \n"+ + "public abstract class T implements II { \n"+ + " void foo(int i) {} \n"+ + " void bar() { \n"+ + " new TT() { \n"+ + " { \n"+ + " foo(0); // should say that foo(int, boolean) isn't applicable \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + " void boo() { \n"+ + " new TT() { \n"+ + " { \n"+ + " foo(true); // should not complain about ambiguity \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + "} \n" + }, + "----------\n" + + "1. ERROR in p1\\T.java (at line 13)\n" + + " foo(0); // should say that foo(int, boolean) isn\'t applicable \n" + + " ^^^\n" + + "The method foo(int, boolean) in the type TT is not applicable for the arguments (int)\n" + + "----------\n"); +} + + /* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=11511 + * variant - applicable error diagnosis + */ +public void test023() { + + this.runNegativeTest( + new String[] { + "p1/T.java", + "package p1; \n"+ + "interface II {} \n"+ + "abstract class TT { \n"+ // 259+ABSTRACT + " void foo(boolean b) {} \n"+ + " void foo(int i, boolean b) {} \n"+ + " void foo(String s) {} \n"+ + "} \n"+ + "public abstract class T implements II { \n"+ + " void foo(int i) {} \n"+ + " void bar() { \n"+ + " new TT() { \n"+ + " { \n"+ + " foo(0); // should say that foo(int, boolean) isn't applicable \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + " void boo() { \n"+ + " new TT() { \n"+ + " { \n"+ + " foo(true); // should complain ambiguity \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + "} \n" + }, + "----------\n" + + "1. ERROR in p1\\T.java (at line 13)\n" + + " foo(0); // should say that foo(int, boolean) isn\'t applicable \n" + + " ^^^\n" + + "The method foo(int, boolean) in the type TT is not applicable for the arguments (int)\n" + + "----------\n"); +} +/* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=11511 + * variant - applicable error diagnosis + */ +public void test024() { + + this.runNegativeTest( + new String[] { + "p1/X.java", + "package p1; \n"+ + "interface II {} \n"+ + "abstract class T implements II { \n"+ + " void foo(boolean b) {} \n"+ + " void foo(int i, boolean b) {} \n"+ + "} \n"+ + "abstract class TT implements II { \n"+ + " void foo(boolean b) {} \n"+ + "} \n"+ + "public class X { \n"+ + " void foo(int i) {} \n"+ + " void bar() { \n"+ + " new T() { \n"+ + " { \n"+ + " foo(0); // javac says foo cannot be resolved because of multiple matches \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + " void bar2() { \n"+ + " new TT() { \n"+ + " { \n"+ + " foo(0); // should say that foo(boolean) isn't applicable \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + " void boo() { \n"+ + " new T() { \n"+ + " { \n"+ + " foo(true); // should complain ambiguity \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + "} \n" + }, + "----------\n" + + "1. ERROR in p1\\X.java (at line 15)\n" + + " foo(0); // javac says foo cannot be resolved because of multiple matches \n" + + " ^^^\n" + + "The method foo(int, boolean) in the type T is not applicable for the arguments (int)\n" + + "----------\n" + + "2. ERROR in p1\\X.java (at line 22)\n" + + " foo(0); // should say that foo(boolean) isn\'t applicable \n" + + " ^^^\n" + + "The method foo(boolean) in the type TT is not applicable for the arguments (int)\n" + + "----------\n"); +} + +/* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=11511 + * variant - applicable error diagnosis (no matter if super is abstract or not) + */ +public void test025() { + + this.runNegativeTest( + new String[] { + "p1/X.java", + "package p1; \n"+ + "public class X extends AbstractY { \n"+ + " void bar(){ \n"+ + " init(\"hello\"); \n"+ + " } \n"+ + "} \n"+ + "abstract class AbstractY implements I { \n"+ + "} \n"+ + "interface I { \n"+ + " void init(String s, int i); \n"+ + "} \n" + }, + "----------\n" + + "1. ERROR in p1\\X.java (at line 2)\n" + + " public class X extends AbstractY { \n" + + " ^\n" + + "Class must implement the inherited abstract method I.init(String, int)\n" + + "----------\n" + + "2. ERROR in p1\\X.java (at line 4)\n" + + " init(\"hello\"); \n" + + " ^^^^\n" + + "The method init(String, int) in the type I is not applicable for the arguments (String)\n" + + "----------\n"); +} + +/* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=11511 + * variant - applicable error diagnosis (no matter if super is abstract or not) + */ +public void test026() { + + this.runNegativeTest( + new String[] { + "p1/X.java", + "package p1; \n"+ + "public class X extends AbstractY { \n"+ + " void bar(){ \n"+ + " init(\"hello\"); \n"+ + " } \n"+ + "} \n"+ + "class AbstractY implements I { \n"+ + "} \n"+ + "interface I { \n"+ + " void init(String s, int i); \n"+ + "} \n" + }, + "----------\n" + + "1. ERROR in p1\\X.java (at line 4)\n" + + " init(\"hello\"); \n" + + " ^^^^\n" + + "The method init(String, int) in the type I is not applicable for the arguments (String)\n" + + "----------\n" + + "2. ERROR in p1\\X.java (at line 7)\n" + + " class AbstractY implements I { \n" + + " ^^^^^^^^^\n" + + "Class must implement the inherited abstract method I.init(String, int)\n" + + "----------\n" +); +} +/* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=11922 + * should report unreachable empty statement + */ +public void test027() { + + this.runNegativeTest( + new String[] { + "p1/X.java", + "package p1; \n"+ + "public class X { \n"+ + " public static void main(String[] arguments) { \n"+ + " for (;false;p()); \n"+ + " System.out.println(\"SUCCESS\"); \n"+ + " } \n"+ + " static void p(){ \n"+ + " System.out.println(\"FAILED\"); \n"+ + " } \n"+ + "} \n" + }, + "----------\n" + + "1. ERROR in p1\\X.java (at line 4)\n" + + " for (;false;p()); \n" + + " ^\n" + + "Unreachable code\n" + + "----------\n"); +} +/* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=12445 + * should report unreachable empty statement + */ +public void test028() { + + this.runConformTest( + new String[] { + "p1/X.java", + "package p1; \n" + + "interface FooInterface { \n" + + " public boolean foo(int a); \n" + + " public boolean bar(int a); \n" + + "} \n" + + "public class X extends Z { \n" + + " public boolean foo(int a){ return true; } \n" + + " public boolean bar(int a){ return false; } \n" + + " public static void main(String[] arguments) { \n"+ + " System.out.println(new X().test(0)); \n"+ + " } \n" + + "}\n" + + "abstract class Z implements FooInterface { \n" + + " public boolean foo(int a, int b) { \n" + + " return true; \n" + + " } \n" + + " public String test(int a) { \n" + + " boolean result = foo(a); \n" + + " if (result) \n" + + " return \"SUCCESS\"; \n" + + " else \n" + + " return \"FAILED\"; \n" + + " } \n" + + "} \n" + }, + "SUCCESS"); +} + +/* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=21580 + * verify error on qualified name ref in 1.4 + */ +public void test029() { + + this.runConformTest( + new String[] { + "p/X.java", + "package p; \n" + + "public class X { \n" + + " public static void main(String[] args) { \n" + + " new X(); \n" + + " System.out.println(\"SUCCESS\"); \n" + + " } \n" + + " Woof woof_1; \n" + + " public class Honk { \n" + + " Integer honks; \n" + + " } \n" + + " public class Meow { \n" + + " Honk honk_1; \n" + + " } \n" + + " public class Woof { \n" + + " Meow meow_1; \n" + + " } \n" + + " public void setHonks(int num) { \n" + + " // This is the line that causes the VerifyError \n" + + " woof_1.meow_1.honk_1.honks = new Integer(num); \n" + + " // Here is equivalent code that does not cause the error. \n" + + " // Honk h = woof_1.moo_1.meow_1.honk_1; \n" + + " // h.honks = new Integer(num); \n" + + " } \n" + + "} \n" + }, + "SUCCESS"); +} + +/* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=21580 + * 1.4 signals invocations of non-visible abstract protected method implementations. + */ +public void test030() { + + this.runNegativeTest( + new String[] { + "p/X.java", + "package p; \n" + + "public class X { \n" + + " public static void main(String[] args){ \n" + + " new q.X2().foo(\"String\"); \n" + + " new q.X2().bar(\"String\"); \n" + + " new q.X2().barbar(\"String\"); \n" + + " new q.X2().baz(\"String\"); \n" + + " } \n" + + "} \n", + + "p/X1.java", + "package p; \n" + + "public abstract class X1 { \n" + + " protected void foo(Object o){ System.out.println(\"X1.foo(Object)\"); } \n" + + " protected void bar(Object o){ System.out.println(\"X1.bar(Object)\"); } \n" + + " void barbar(Object o){ System.out.println(\"X1.barbar(Object)\"); } \n" + + " protected void baz(Object o) { System.out.println(\"X1.baz(Object)\"); } \n" + + "} \n", + + "q/X2.java", + "package q; \n" + + "public class X2 extends p.X1 { \n" + + " protected void foo(int i) { System.out.println(\"X2.foo(int)\"); } \n" + + " protected void bar(Object o) { System.out.println(\"X2.bar(Object)\"); } \n" + + " void barbar(Object o){ System.out.println(\"X2.barbar(Object)\"); } \n" + + " protected void baz(String s) { System.out.println(\"X2.baz(String)\"); } \n" + + "} \n", + }, + "----------\n" + + "1. ERROR in p\\X.java (at line 5)\n" + + " new q.X2().bar(\"String\"); \n" + + " ^^^\n" + + "The method bar(Object) from the type X2 is not visible\n" + + "----------\n" + + "2. ERROR in p\\X.java (at line 6)\n" + + " new q.X2().barbar(\"String\"); \n" + + " ^^^^^^\n" + + "The method barbar(Object) from the type X2 is not visible\n" + + "----------\n" + + "----------\n" + + "1. WARNING in q\\X2.java (at line 5)\n" + + " void barbar(Object o){ System.out.println(\"X2.barbar(Object)\"); } \n" + + " ^^^^^^^^^^^^^^^^\n" + + "The method X2.barbar(Object) does not override the inherited method from X1 since it is private to a different package.\n" + + "----------\n"); +} + +/* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=21580 + * 1.4 signals invocations of non-visible abstract protected method implementations. + */ +public void test031() { + + this.runNegativeTest( + new String[] { + "p/X.java", + "package p; \n" + + "public class X extends q.X2 { \n" + + " public static void main(String[] args){ \n" + + " new X().doSomething(); \n" + + " } \n" + + " void doSomething(){ \n" + + " foo(\"String\"); \n" + + " bar(\"String\"); \n" + + " barbar(\"String\"); \n" + + " baz(\"String\"); \n" + + " } \n" + + "} \n", + + "p/X1.java", + "package p; \n" + + "public abstract class X1 { \n" + + " protected void foo(Object o){ System.out.println(\"X1.foo(Object)\"); } \n" + + " protected void bar(Object o){ System.out.println(\"X1.bar(Object)\"); } \n" + + " void barbar(Object o){ System.out.println(\"X1.barbar(Object)\"); } \n" + + " protected void baz(Object o) { System.out.println(\"X1.baz(Object)\"); } \n" + + "} \n", + + "q/X2.java", + "package q; \n" + + "public class X2 extends p.X1 { \n" + + " protected void foo(int i) { System.out.println(\"X2.foo(int)\"); } \n" + + " protected void bar(Object o) { System.out.println(\"X2.bar(Object)\"); } \n" + + " void barbar(Object o){ System.out.println(\"X2.barbar(Object)\"); } \n" + + " protected void baz(String s) { System.out.println(\"X2.baz(String)\"); } \n" + + "} \n", + }, + "----------\n" + + "1. ERROR in p\\X.java (at line 9)\n" + + " barbar(\"String\"); \n" + + " ^^^^^^\n" + + "The method barbar(Object) from the type X2 is not visible\n" + + "----------\n" + + "----------\n" + + "1. WARNING in q\\X2.java (at line 5)\n" + + " void barbar(Object o){ System.out.println(\"X2.barbar(Object)\"); } \n" + + " ^^^^^^^^^^^^^^^^\n" + + "The method X2.barbar(Object) does not override the inherited method from X1 since it is private to a different package.\n" + + "----------\n" +); +} + +/* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=21580 + * 1.4 signals invocations of non-visible abstract protected field implementations. + */ +public void test032() { + + this.runNegativeTest( + new String[] { + "p/X.java", + "package p; \n" + + "public class X { \n" + + " public static void main(String[] args){ \n" + + " System.out.println(new q.X2().foo); \n" + + " System.out.println(new q.X2().bar); \n" + + " } \n" + + "} \n", + + "p/X1.java", + "package p; \n" + + "public abstract class X1 { \n" + + " protected String foo = \"X1.foo\"; \n" + + " String bar = \"X1.bar\"; \n" + + "} \n", + + "q/X2.java", + "package q; \n" + + "public class X2 extends p.X1 { \n" + + " protected String foo = \"X2.foo\"; \n" + + " String bar = \"X2.bar\"; \n" + + "} \n", + }, + "----------\n" + + "1. ERROR in p\\X.java (at line 4)\n" + + " System.out.println(new q.X2().foo); \n" + + " ^^^\n" + + "The field foo is not visible\n" + + "----------\n" + + "2. ERROR in p\\X.java (at line 5)\n" + + " System.out.println(new q.X2().bar); \n" + + " ^^^\n" + + "The field bar is not visible\n" + + "----------\n"); +} + +/* + * Initialization of synthetic fields prior to super constructor call + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=23075 + */ +public void test033() { + + this.runConformTest( + new String[] { + "A.java", + "public class A { \n"+ + " public int m; \n"+ + " public void pp() { \n"+ + " C c = new C(4); \n"+ + " System.out.println(c.get()); \n"+ + " } \n"+ + " public static void main(String[] args) { \n"+ + " A a = new A(); \n"+ + " try { \n"+ + " a.pp(); \n"+ + " System.out.println(\"SyntheticInit BEFORE SuperConstructorCall\"); \n"+ + " } catch(NullPointerException e) { \n"+ + " System.out.println(\"SyntheticInit AFTER SuperConstructorCall\"); // should no longer occur with target 1.4 \n"+ + " } \n"+ + " } \n"+ + " class C extends B { \n"+ + " public C(int x1) { \n"+ + " super(x1); \n"+ + " } \n"+ + " protected void init(int x1) { \n"+ + " x = m * x1; // <- NULL POINTER EXCEPTION because of m \n"+ + " } \n"+ + " } \n"+ + "} \n"+ + "class B { \n"+ + " int x; \n"+ + " public B(int x1) { \n"+ + " init(x1); \n"+ + " } \n"+ + " protected void init(int x1) { \n"+ + " x = x1; \n"+ + " } \n"+ + " public int get() { \n"+ + " return x; \n"+ + " } \n"+ + "} \n" + }, + "SyntheticInit BEFORE SuperConstructorCall"); +} +/* + * Initialization of synthetic fields prior to super constructor call - NPE check + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=25174 + */ +public void test034() { + + this.runConformTest( + new String[] { + "X.java", + "public class X { \n"+ + " public static void main(String[] arguments) { \n"+ + " new X().new X2(); \n"+ + " } \n"+ + " class X1 { \n"+ + " X1(){ \n"+ + " this.baz(); \n"+ + " } \n"+ + " void baz() { \n"+ + " System.out.println(\"-X1.baz()\"); \n"+ + " } \n"+ + " } \n"+ + " class X2 extends X1 { \n"+ + " void baz() { \n"+ + " System.out.print(X.this==null ? \"X.this == null\" : \"X.this != null\"); \n"+ + " X1 x1 = X.this.new X1(){ \n"+ + " void baz(){ \n"+ + " System.out.println(\"-X$1.baz()\"); \n"+ + " } \n"+ + " }; \n"+ + " } \n"+ + " } \n"+ + "}\n", + }, + "X.this != null-X$1.baz()"); +} + +public void test035() { + this.runConformTest( + new String[] { + /* p1/X.java */ + "p1/X.java", + "package p1; \n"+ + "public class X { \n"+ + " class Y { Y(int i){} } \n"+ + " public static void main(String[] arguments) { \n"+ + " int i = 1; \n" + + " try { \n" + + " X x =null; \n" + + " x.new Y(++i); \n" + // i won't get incremented before NPE + " System.out.println(\"FAILED\"); \n" + + " } catch(NullPointerException e){ \n" + + " System.out.println(\"SUCCESS:\"+i); \n" + + " } \n" + + " } \n"+ + "} \n", + }, + "SUCCESS:1" + ); +} + +public void test036() { + this.runConformTest( + new String[] { + /* p1/X.java */ + "p1/X.java", + "package p1; \n"+ + "public class X { \n"+ + " class Y {} \n"+ + " static class Z extends Y { \n"+ + " Z (X x){ \n"+ + " x.super(); \n" + + " } \n"+ + " } \n"+ + " public static void main(String[] arguments) { \n"+ + " try { \n" + + " new Z(null); \n" + + " System.out.println(\"FAILED\"); \n" + + " } catch(NullPointerException e){ \n" + + " System.out.println(\"SUCCESS\"); \n" + + " } \n" + + " } \n"+ + "} \n", + }, + "SUCCESS" + ); +} + +/* + * http://dev.eclipse.org/bugs/show_bug.cgi?id=24744 + * http://dev.eclipse.org/bugs/show_bug.cgi?id=23096 + * + * NOTE: since JLS got revised to allow unterminated line comments (32476) + */ +public void test037() { + Map customOptions = getCompilerOptions(); + customOptions.put(CompilerOptions.OPTION_TaskTags, "TODO:"); + this.runNegativeTest( + new String[] { + "p/X.java", + "package p; \n"+ + "public class X {\n"+ + "}\n"+ + "// TODO: something" + }, + "----------\n" + + "1. WARNING in p\\X.java (at line 4)\n" + + " // TODO: something\n" + + " ^^^^^^^^^^^^^^^\n" + + "TODO: something\n" + + "----------\n", + null, + true, + customOptions); +} + +/* + * http://dev.eclipse.org/bugs/show_bug.cgi?id=24833 + * http://dev.eclipse.org/bugs/show_bug.cgi?id=23096 + * + * NOTE: since JLS got revised to allow unterminated line comments (32476) + */ +public void test038() { + Map customOptions = getCompilerOptions(); + customOptions.put(CompilerOptions.OPTION_TaskTags, "TODO:"); + this.runNegativeTest( + new String[] { + "X.java", + "// TODO: something" + }, + "----------\n" + + "1. WARNING in X.java (at line 1)\n" + + " // TODO: something\n" + + " ^^^^^^^^^^^^^^^\n" + + "TODO: something\n" + + "----------\n", + null, + true, + customOptions); +} + +/* + * unreachable empty statement/block are diagnosed in 1.3 + */ +public void test039() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X { \n" + + " public static void main(String[] args){ \n"+ + " for (;null != null;); \n"+ + " for (;null != null;){} \n"+ + " for (;false;); \n"+ + " for (;false;){} \n"+ + " while (false); \n"+ + " while (false){} \n"+ + " if (false) {} else {} \n"+ + " if (false) ; else ; \n"+ + " System.out.println(\"FAILED\"); \n" + + " } \n"+ + "} \n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " for (;false;); \n" + + " ^\n" + + "Unreachable code\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " for (;false;){} \n" + + " ^^\n" + + "Unreachable code\n" + + "----------\n" + + "3. ERROR in X.java (at line 7)\n" + + " while (false); \n" + + " ^\n" + + "Unreachable code\n" + + "----------\n" + + "4. ERROR in X.java (at line 8)\n" + + " while (false){} \n" + + " ^^\n" + + "Unreachable code\n" + + "----------\n"); +} +// jls6.5.5.1 - simple type names favor member type over toplevel one. +//http://bugs.eclipse.org/bugs/show_bug.cgi?id=30705 +public void test040() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X { \n"+ + " interface Homonym {} \n"+ // takes precedence over others. + " void foo() { \n"+ + " class Homonym extends X { \n"+ + " { \n"+ + " class Y extends Homonym {}; \n"+ // X$Homonym + " } \n"+ + " } \n"+ + " } \n"+ + "} \n"+ + "class Homonym extends X { \n"+ + " { \n"+ + " class Y extends Homonym {}; \n"+ // X$Homonym + " } \n"+ + "} \n" + }, + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " class Y extends Homonym {}; \n" + + " ^^^^^^^\n" + + "The interface X.Homonym cannot be the superclass of Y; a superclass must be a class\n" + + "----------\n" + + "2. ERROR in X.java (at line 13)\n" + + " class Y extends Homonym {}; \n" + + " ^^^^^^^\n" + + "The interface X.Homonym cannot be the superclass of Y; a superclass must be a class\n" + + "----------\n"); +} +/* + * 30856 - 1.4 compliant mode should consider abstract method matches + */ +public void test041() { + this.runConformTest( + new String[] { + "p/X.java", //================================ + "package p; \n" + + "public class X { \n" + + " void foo(int i, float f){} \n" + + " public static void main(String[] args) { \n" + + " q.Y y = new q.Y.Z(); \n" + + " y.bar(); \n" + + " } \n" + + "} \n", + "q/Y.java", //================================ + "package q; \n" + + "public abstract class Y extends p.X implements I { \n" + + " public void bar(){ foo(1, 2); } \n" + + " public static class Z extends Y { \n" + + " public void foo(float f, int i) { \n" + + " System.out.println(\"SUCCESS\"); \n" + + " } \n" + + " } \n" + + "} \n" + + "interface I { \n" + + " void foo(float f, int i); \n" + + "} \n", + }, + "SUCCESS"); +} +/* + * variation - 30856 - 1.4 compliant mode should consider abstract method matches + */ +public void test042() { + this.runConformTest( + new String[] { + "p/X.java", //================================ + "package p; \n" + + "public class X extends X0 { \n" + + " void foo(int i, float f){} \n" + + " public static void main(String[] args) { \n" + + " q.Y y = new q.Y.Z(); \n" + + " y.bar(); \n" + + " } \n" + + "} \n" + + "class X0 { \n" + + " void foo(int i, double d){} \n" + // extra match + "} \n", + "q/Y.java", //================================ + "package q; \n" + + "public abstract class Y extends p.X implements I { \n" + + " public void bar(){ foo(1, 2); } \n" + + " public static class Z extends Y { \n" + + " public void foo(float f, int i) { \n" + + " System.out.println(\"SUCCESS\"); \n" + + " } \n" + + " } \n" + + "} \n" + + "interface I { \n" + + " void foo(float f, int i); \n" + + "} \n", + }, + "SUCCESS"); +} + +// binary compatibility +public void _test043() { + this.runConformTest( + new String[] { + "p1/Y.java", + "package p1; \n" + + "public class Y extends A implements I { \n" + + " public static void main(String[] args) { \n" + + " Y.printValues(); \n" + + " } \n" + + " public static void printValues() { \n" + + " System.out.println(\"i=\"+i+\",j=\"+j+\",Y.i=\"+Y.i+\",Y.j=\"+Y.j); \n" + + " } \n" + + "} \n", + "p1/A.java", + "package p1; \n" + + "public class A { \n" + + " static int i = 1; \n" + + "} \n", + "p1/I.java", + "package p1; \n" + + "interface I { \n" + + " int j = \"aa\".length(); \n" + + "} \n", + }, + "i=1,j=2,Y.i=1,Y.j=2"); + + this.runConformTest( + new String[] { + "p1/A.java", + "package p1; \n" + + "public class A { \n" + + " static int j = 3; \n" + + " public static void main(String[] args) { \n" + + " Y.printValues(); \n" + + " } \n" + + "} \n", + "p1/I.java", + "package p1; \n" + + "interface I { \n" + + " int j = \"aaaa\".length(); \n" + + "} \n", + }, + "i=4,j=3,Y.i=4,Y.j=3", + null, // use default class-path + false, // do not flush previous output dir content + null); // no special vm args +} +/* + * array.clone() should use array type in methodRef + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=36307 + */ +public void test044() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " args.clone(); \n"+ + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String actualOutput = null; + try { + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator +"X.class")); + actualOutput = + disassembler.disassemble( + classFileBytes, + "\n", + ClassFileBytesDisassembler.DETAILED); + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue("ClassFormatException", false); + } catch (IOException e) { + assertTrue("IOException", false); + } + + String expectedOutput = + " 1 invokevirtual #21 <Method [Ljava/lang/String;.clone()Ljava/lang/Object;>\n"; + + if (actualOutput.indexOf(expectedOutput) == -1) { + System.out.println(org.eclipse.jdt.core.tests.util.Util.displayString(actualOutput, 2)); + } + assertTrue("unexpected bytecode sequence", actualOutput.indexOf(expectedOutput) != -1); +} +// 39172 +public void test045() { + this.runNegativeTest( + new String[] { + "p/X.java", + "package p; \n" + + "public class X { \n" + + " public static void main(String[] args) { \n" + + " System.out.println(\"FAILED\"); \n" + + " return;; \n" + // unreachable empty statement - must complain in 1.4 mode + " } \n" + + "} \n" + }, + "----------\n" + + "1. ERROR in p\\X.java (at line 5)\n" + + " return;; \n" + + " ^\n" + + "Unreachable code\n" + + "----------\n" + ); +} +/** + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=39467 + * should diagnose missing abstract method implementation + */ +public void test046() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X extends Y {\n" + + "}\n" + + "abstract class Y extends Z {\n" + + " public abstract void foo();\n" + + "}\n" + + "abstract class Z extends T {\n" + + "}\n" + + "class T implements I {\n" + + " public void foo(){}\n" + + "}\n" + + "interface I {\n" + + " public void foo ();\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X extends Y {\n" + + " ^\n" + + "Class must implement the inherited abstract method Y.foo()\n" + + "----------\n" + ); +} +/** + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=40442 + * Abstract class fails to invoke interface-defined method in 1.4 compliance mode. + */ +public void test047() { + this.runConformTest( + new String[] { + "X.java", + "public class X extends AbstractDoubleAlgorithm {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " ((ObjectAlgorithm)(new X())).operate(new Double(0));\n" + + " }\n" + + " public void operate(Double pDouble)\n" + + " {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "abstract class AbstractDoubleAlgorithm implements DoubleAlgorithm {\n" + + " public void operate(Object pObject)\n" + + " {\n" + + " operate((Double)pObject);\n" + + " }\n" + + "}\n" + + "interface DoubleAlgorithm extends ObjectAlgorithm {\n" + + " void operate(Double pDouble);\n" + + "}\n" + + "interface ObjectAlgorithm {\n" + + " void operate(Object pObject);\n" + + "}" + }, + "SUCCESS" + ); +} +/** + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=40442 + * Abstract class fails to invoke interface-defined method in 1.4 compliance mode. + * variation with 2 found methods + */ +public void test048() { + this.runConformTest( + new String[] { + "X.java", + "public class X extends AbstractDoubleAlgorithm {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " ((ObjectAlgorithm)(new X())).operate(new Double(0));\n" + + " }\n" + + " public void operate(Double pDouble)\n" + + " {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "abstract class AbstractDoubleAlgorithm implements DoubleAlgorithm {\n" + + " public void operate(Object pObject)\n" + + " {\n" + + " operate((Double)pObject);\n" + + " }\n" + + " public void operate(X x) {}\n" + + "}\n" + + "interface DoubleAlgorithm extends ObjectAlgorithm {\n" + + " void operate(Double pDouble);\n" + + "}\n" + + "interface ObjectAlgorithm {\n" + + " void operate(Object pObject);\n" + + "}" + }, + "SUCCESS" + ); +} +/** + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=41278 + */ +public void test049() { + this.runNegativeTest( + new String[] { + "pa/Caller.java", + "package pa;\n" + + "import pb.Concrete;\n" + + "public class Caller {\n" + + "\n" + + " public static void main(String[] args) {\n" + + " Concrete aConcrete = new Concrete(); \n" + + " aConcrete.callme();\n" + + " }\n" + + "}\n", + "pa/Abstract.java", + "package pa;\n" + + "public abstract class Abstract {\n" + + "\n" + + " protected void callme(){}\n" + + "}\n", + "pb/Concrete.java", + "package pb;\n" + + "public class Concrete extends pa.Abstract {\n" + + "\n" + + " protected void callme(){ System.out.println(\"SUCCESS\"); }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in pa\\Caller.java (at line 7)\n" + + " aConcrete.callme();\n" + + " ^^^^^^\n" + + "The method callme() from the type Concrete is not visible\n" + + "----------\n"); +} + +public void test050() { + this.runNegativeTest(new String[] { + "p/X.java", + "package p;\n" + + "public class X {\n" + + " public static void main(String args[]) {\n" + + " foo();\n" + + " }\n" + + " public static void foo() {\n" + + " int a1 = 1;\n" + + " int a2 = 1;\n" + + " a1 = 2;\n" + + " while (false) {};\n" + + " a2 = 2;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in p\\X.java (at line 10)\n" + + " while (false) {};\n" + + " ^^\n" + + "Unreachable code\n" + + "----------\n"); +} + +public void test051() { + this.runNegativeTest(new String[] { + "p/X.java", + "package p;\n" + + "public class X {\n" + + " public static void main(String args[]) {\n" + + " foo();\n" + + " }\n" + + " public static void foo() {\n" + + " int a1 = 1;\n" + + " int a2 = 1;\n" + + " a1 = 2;\n" + + " while (false);\n" + + " a2 = 2;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in p\\X.java (at line 10)\n" + + " while (false);\n" + + " ^\n" + + "Unreachable code\n" + + "----------\n"); +} + +public void test052() { + this.runNegativeTest( + new String[] { + "p/A.java", + "package p;\n" + + "public class A {\n" + + " public static void main(String[] argv) {\n" + + " foo();\n" + + " }\n" + + " private int i;\n" + + " static class Y extends X {\n" + + " int x = i;\n" + + " }\n" + + " public static void foo() {\n" + + " return;\n" + + " }\n" + + "}", + + "p/X.java", + "package p;\n" + + "public class X {\n" + + " public static void main(String argv[]) {\n" + + " foo();\n" + + " }\n" + + " public static void foo() {\n" + + " int a1 = 1;\n" + + " int a2 = 1;\n" + + " a1 = 2;\n" + + " while (false);\n" + + " a2 = 2;\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. WARNING in p\\A.java (at line 6)\n" + + " private int i;\n" + + " ^\n" + + "The private field A.i is never read locally\n" + + "----------\n" + + "2. ERROR in p\\A.java (at line 8)\n" + + " int x = i;\n" + + " ^\n" + + "Cannot make a static reference to the non-static field i\n" + + "----------\n" + + "----------\n" + + "1. ERROR in p\\X.java (at line 10)\n" + + " while (false);\n" + + " ^\n" + + "Unreachable code\n" + + "----------\n" + ); +} + +public void test053() { + this.runConformTest( + new String[] { + "p/X.java", + "package p;\n" + + "class X {\n" + + " static class A {\n" + + " interface I {\n" + + " int a = 3;\n" + + " }\n" + + " } \n" + + " interface I { \n" + + " int b = 4;\n" + + " }\n" + + " class Y extends A implements I {\n" + + " Object F() {\n" + + " return new I() {\n" + + " int c = a; // WE SHOULD NOT BE ABLE TO SEE BOTH a and b\n" + + " int d = b; // WE SHOULD NOT BE ABLE TO SEE BOTH a and b\n" + + " };\n" + + " }\n" + + " }\n" + + "}", + } + ); +} + +public void test054() { + this.runConformTest( + new String[] { + "p/X.java", + "package p;\n" + + "public class X {\n" + + " static class A {\n" + + " interface I {\n" + + " int a = 3;\n" + + " void foo();\n" + + " }\n" + + " }\n" + + " interface I {\n" + + " int a = 4;\n" + + " void foo();\n" + + " }\n" + + " class Y extends A implements I {\n" + + " public void foo() {\n" + + " new I() {\n" + + " public void foo() {\n" + + " System.out.println(\"X$1::foo-\" + a);\n" + + " }\n" + + " }\n" + + " .foo();\n" + + " }\n" + + " }\n" + + "public static void main(String argv[]) {\n" + + " new X().new Y().foo();\n" + + "}\n" + + "}", + } + ); +} +public void test055() { + this.runNegativeTest( + new String[] { + "p/X.java", + "package p;\n" + + "public class X {\n" + + " static class A {\n" + + " interface I2 {\n" + + " int a = 3;\n" + + " void foo();\n" + + " }\n" + + " }\n" + + " interface I1 {\n" + + " int a = 4;\n" + + " void foo(int a);\n" + + " }\n" + + " class Y extends A implements I1 {\n" + + " public void foo(int a) {\n" + + " new I2() {\n" + + " public void foo() {\n" + + " System.out.println(\"X$1::foo-\" + a);\n" + + " }\n" + + " }\n" + + " .foo();\n" + + " }\n" + + " }\n" + + "public static void main(String argv[]) {\n" + + " new X().new Y().foo(8);\n" + + "}\n" + + "}", + }, + "----------\n" + + "1. WARNING in p\\X.java (at line 11)\n" + + " void foo(int a);\n" + + " ^\n" + + "The parameter a is hiding a field from type X.I1\n" + + "----------\n" + + "2. WARNING in p\\X.java (at line 14)\n" + + " public void foo(int a) {\n" + + " ^\n" + + "The parameter a is hiding a field from type X.I1\n" + + "----------\n" + ); +} + +/* + * http://bugs.eclipse.org/bugs/show_bug.cgi?id=11435 + * variant - must still complain when targeting super abstract method + */ +public void test062() { + + this.runNegativeTest( + new String[] { + "p1/Y.java", + "package p1; \n"+ + "public class Y extends AbstractT { \n"+ + " public void init(){ \n"+ + " super.init(); \n"+ + " } \n"+ + "} \n"+ + "abstract class AbstractT implements J { \n"+ + "} \n"+ + "interface J { \n"+ + " void init(); \n"+ + "} \n" + }, + "----------\n" + + "1. ERROR in p1\\Y.java (at line 4)\n" + + " super.init(); \n" + + " ^^^^^^^^^^^^\n" + + "Cannot directly invoke the abstract method init() for the type J\n" + + "----------\n"); // expected log +} + +public void test063() { + this.runNegativeTest( + new String[] { + /* p1/X.java */ + "p1/X.java", + "package p1; \n"+ + "public class X { \n"+ + " class Y extends X {} \n"+ + " class Z extends Y { \n"+ + " Z(){ \n"+ + " System.out.println(\"SUCCESS\"); \n"+ + " } \n" + + " } \n" + + " public static void main(String[] arguments) { \n"+ + " new X().new Z(); \n"+ + " } \n"+ + "} \n", + }, + "----------\n" + + "1. ERROR in p1\\X.java (at line 5)\n" + + " Z(){ \n" + + " ^^^\n" + + "No enclosing instance of type X is available due to some intermediate constructor invocation\n" + + "----------\n" + ); +} + +/** + * Refuse selection of own enclosing instance arg for super constructor call in 1.3 compliant mode + */ +public void test064() { + this.runNegativeTest( + new String[] { + "Foo.java", + "public class Foo {\n" + + " public static void main(String[] args) {\n"+ + " System.out.println(\"SUCCESS\");\n"+ + " }\n"+ + " public class Bar extends Foo {\n" + + " public Bar() {\n" + + " }\n" + + " }\n" + + " public class Baz extends Bar {\n" + + " public Baz() {\n" + + " }\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in Foo.java (at line 10)\n" + + " public Baz() {\n" + + " ^^^^^\n" + + "No enclosing instance of type Foo is available due to some intermediate constructor invocation\n" + + "----------\n"); +} + +public void test065() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X { \n"+ + " public static void main(String[] arguments) { \n"+ + " new X().new Y().new Z().bar(); \n"+ + " } \n"+ + " String foo() { return \"X-foo\"; } \n"+ + " class Y extends X { \n"+ + " String foo() { return \"Y-foo\"; } \n"+ + " class Z extends Y { \n"+ + " Z(){ \n"+ + " //X.this.super(); \n"+ + " } \n"+ + " String foo() { return \"Z-foo\"; } \n"+ + " void bar () { \n"+ + " System.out.println(X.this.foo()); \n"+ + " } \n"+ + " } \n"+ + " } \n"+ + "} \n" + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " Z(){ \n" + + " ^^^\n" + + "No enclosing instance of type X is available due to some intermediate constructor invocation\n" + + "----------\n"); +} + +/* + * Check that anonymous type allocation is denied access to compatible enclosing instance available as constructor argument + */ +public void test066() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " X(Object o) {}\n" + + " class M extends X {\n" + + " M(){\n" + + " super(null);\n" + + " }\n" + + " M(Object o) {\n" + + " super(new M(){});\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " super(new M(){});\n" + + " ^^^^^^^^^\n" + + "No enclosing instance of type X is available due to some intermediate constructor invocation\n" + + "----------\n" + + "2. ERROR in X.java (at line 8)\n" + + " super(new M(){});\n" + + " ^^^\n" + + "No enclosing instance of type X is available due to some intermediate constructor invocation\n" + + "----------\n"); +} + +/* + * Check that indirect member type allocation is denied access to compatible enclosing instance available as constructor argument + */ +public void test067() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " X(Object o) {\n" + + " }\n" + + " class N extends X {\n" + + " N(Object o) {\n" + + " super(o);\n" + + " }\n" + + " }\n" + + " class M extends N {\n" + + " M() {\n" + + " super(null); //1\n" + + " }\n" + + " M(Object o) {\n" + + " super(new M());//2\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 11)\n" + + " super(null); //1\n" + + " ^^^^^^^^^^^\n" + + "No enclosing instance of type X is available due to some intermediate constructor invocation\n" + + "----------\n" + + "2. ERROR in X.java (at line 14)\n" + + " super(new M());//2\n" + + " ^^^^^^^^^^^^^^\n" + + "No enclosing instance of type X is available due to some intermediate constructor invocation\n" + + "----------\n" + + "3. ERROR in X.java (at line 14)\n" + + " super(new M());//2\n" + + " ^^^^^^^\n" + + "No enclosing instance of type X is available due to some intermediate constructor invocation\n" + + "----------\n"); +} + +/* + * Check that indirect member type allocation is denied access to compatible enclosing instance available as constructor argument + */ +public void test068() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " class MX1 extends X {\n" + + " MX1() {\n" + + " }\n" + + " }\n" + + " class MX2 extends MX1 {\n" + + " MX2() {\n" + + " super(); // ko\n" + + " }\n" + + " MX2(X x) {\n" + + " this(); // ok\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " super(); // ko\n" + + " ^^^^^^^\n" + + "No enclosing instance of type X is available due to some intermediate constructor invocation\n" + + "----------\n"); +} + +/* + * Check that indirect member type allocation is denied access to compatible enclosing instance available as constructor argument + */ +public void test069() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " class MX3 extends X {\n" + + " MX3(X x) {\n" + + " }\n" + + " }\n" + + " class MX4 extends MX3 {\n" + + " MX4() {\n" + + " super(new MX4()); // ko\n" + + " }\n" + + " MX4(X x) {\n" + + " this(); // ok\n" + + " }\n" + + " MX4(int i) {\n" + + " this(new MX4()); // ko\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " super(new MX4()); // ko\n" + + " ^^^^^^^^^^^^^^^^\n" + + "No enclosing instance of type X is available due to some intermediate constructor invocation\n" + + "----------\n" + + "2. ERROR in X.java (at line 8)\n" + + " super(new MX4()); // ko\n" + + " ^^^^^^^^^\n" + + "No enclosing instance of type X is available due to some intermediate constructor invocation\n" + + "----------\n" + + "3. ERROR in X.java (at line 14)\n" + + " this(new MX4()); // ko\n" + + " ^^^^^^^^^\n" + + "No enclosing instance of type X is available due to some intermediate constructor invocation\n" + + "----------\n"); +} + +// binary compatibility +public void test070() { + this.runConformTest( + new String[] { + "X.java", + "public class X extends Middle {\n" + + " public static void main(String argv[]) {\n" + + " System.out.println(new X().field);\n" + + " }\n" + + "}\n" + + "class Middle extends Top {\n" + + "}\n" + + "class Top {\n" + + " String field = \"Top.field\";\n" + + "}\n" + }, + "Top.field"); + + this.runConformTest( + new String[] { + "Middle.java", + "public class Middle extends Top {\n" + + " public static void main(String[] arguments) { \n"+ + " X.main(arguments); \n" + + " } \n" + + " String field = \"Middle.field\";\n" + + "}\n" + }, + "Middle.field", + null, // use default class-path + false, // do not flush previous output dir content + null); // no special vm args +} + +/* + * 43429 - AbstractMethodError calling clone() at runtime when using Eclipse compiler + */ +public void test071() { + this.runConformTest( + new String[] { + "X.java", //================================ + "public class X {\n" + + " public interface Copyable extends Cloneable {\n" + + " public Object clone() throws CloneNotSupportedException;\n" + + " }\n" + + " public interface TestIf extends Copyable {\n" + + " }\n" + + " public static class ClassA implements Copyable {\n" + + " public Object clone() throws CloneNotSupportedException {\n" + + " return super.clone();\n" + + " }\n" + + " }\n" + + " public static class ClassB implements TestIf {\n" + + " public Object clone() throws CloneNotSupportedException {\n" + + " return super.clone();\n" + + " }\n" + + " }\n" + + " public static void main(String[] args) throws Exception {\n" + + " Copyable o1 = new ClassA();\n" + + " ClassB o2 = new ClassB();\n" + + " TestIf o3 = o2;\n" + + " Object clonedObject;\n" + + " clonedObject = o1.clone();\n" + + " clonedObject = o2.clone();\n" + + " // The following line fails at runtime with AbstractMethodError when\n" + + " // compiled with Eclipse\n" + + " clonedObject = o3.clone();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}", + }, + "SUCCESS"); +} +public void test072() { + + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " try {\n" + + " f();\n" + + " } catch(NullPointerException e) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " }\n" + + " static void f() {\n" + + " Object x = new Object() {\n" + + " {\n" + + " if (true) throw null;\n" + + " }\n" + + " };\n" + + " }\n" + + "}", + }, + "SUCCESS"); +} +// 52221 +public void test073() { + + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n" + + " public static void main(String[] args) {\n" + + " \n" + + " switch(args.length) {\n" + + " \n" + + " case 1:\n" + + " int i = 0;\n" + + " class Local {\n" + + " }\n" + + " break;\n" + + " \n" + + " case 0 :\n" + + " System.out.println(i); // local var can be referred to, only an initialization pb\n" + + " System.out.println(new Local());\n" + + " break;\n" + + "\n" + + " case 2 :\n" + + " class Local { // not a duplicate\n" + + " }\n" + + " break;\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 14)\n" + + " System.out.println(new Local());\n" + + " ^^^^^\n" + + "Local cannot be resolved to a type\n" + + "----------\n"); +} + +// checking for captured outer local initialization status +// NOTE: only complain against non-inlinable outer locals +// http://bugs.eclipse.org/bugs/show_bug.cgi?id=26134 +public void test074() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X { \n" + + " public static void main(String[] args) { \n" + + " String nonInlinedString = \"[Local]\"; \n" + + " int i = 2; \n" + + " switch(i){ \n" + + " case 1: \n" + + " final String displayString = nonInlinedString;\n" + + " final String inlinedString = \"a\"; \n" + + " class Local { \n" + + " public String toString() { \n" + + " return inlinedString + displayString; \n" + + " } \n" + + " } \n" + + " case 2: \n" + + " System.out.print(new Local()); \n" + + " System.out.print(\"-\"); \n" + + " System.out.println(new Local(){ \n" + + " public String toString() { \n" + + " return super.toString()+\": anonymous\"; \n" + + " } \n" + + " }); \n" + + " } \n" + + " } \n" + + "} \n", + }, + "----------\n" + + "1. ERROR in X.java (at line 15)\n" + + " System.out.print(new Local()); \n" + + " ^^^^^\n" + + "Local cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 17)\n" + + " System.out.println(new Local(){ \n" + + " ^^^^^\n" + + "Local cannot be resolved to a type\n" + + "----------\n"); +} +public void test075() { + this.runConformTest( + new String[] { + "X.java", + "public class X { \n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " public void foo(int p1) {} \n" + + " public void foo(short p1) {} \n" + + "} \n", + "Y.java", + "public class Y extends X { \n" + + " public void foo(long p1) {} \n" + + " public void testEc() { foo((short)1); } \n" + + "} \n", + }, + "SUCCESS"); +} + +/** + * Test fix for bug 58069. + * @see <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=58069">58069</a> + */ +public void test076() { + docSupport = true; + runNegativeTest( + new String[] { + "IX.java", + "interface IX {\n" + + " public static class Problem extends Exception {}\n" + + "}\n", + "X.java", + "public abstract class X {\n" + + " public static class Problem extends Exception {}\n" + + " public abstract static class InnerClass implements IX {\n" + + " /**\n" + + " * @throws Problem \n" + + " */\n" + + " public void foo() throws IllegalArgumentException {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " * @throws Problem \n" + + " ^^^^^^^\n" + + "Javadoc: Exception Problem is not declared\n" + + "----------\n" + ); +} +/** + * Test fix bug 58069 for method. + * Note that problem is not flagged in doc comments as it is only raised while verifying + * implicit method and javadoc resolution does not use it. + */ +public void test077() { + docSupport = true; + this.runConformTest( + new String[] { + "p1/Test.java", + "package p1; \n"+ + "public class Test { \n"+ + " public static void main(String[] arguments) { \n"+ + " new Test().foo(); \n"+ + " } \n"+ + " String bar() { \n"+ + " return \"FAILED\"; \n" + + " } \n"+ + " void foo(){ \n"+ + " /** @see #bar() */\n" + + " class Y extends Secondary { \n"+ + " /** @see #bar() */\n" + + " String z = bar(); \n" + + " }; \n"+ + " System.out.println(new Y().z); \n" + + " } \n"+ + "} \n" + + "class Secondary { \n" + + " String bar(){ return \"FAILED\"; } \n" + + "} \n" + } + ); +} +/** + * Test fix bug 58069 for field. + * Note that problem is not flagged in doc comments as it is only raised while verifying + * Name or Qualified name references and javadoc reference is a field reference. + */ +public void test078() { + docSupport = true; + this.runConformTest( + new String[] { + "p1/Test.java", + "package p1; \n"+ + "public class Test { \n"+ + " public static void main(String[] arguments) { \n"+ + " new Test().foo(); \n"+ + " } \n"+ + " String bar = \"FAILED\";"+ + " void foo(){ \n"+ + " /** @see #bar */\n" + + " class Y extends Secondary { \n"+ + " /** @see #bar */\n" + + " String z = bar; \n"+ + " }; \n"+ + " System.out.println(new Y().z); \n" + + " } \n"+ + "} \n" + + "class Secondary { \n" + + " String bar = \"FAILED\"; \n" + + "} \n" + } + ); +} +/* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47227 + */ +public void test079() { + this.runNegativeTest( + new String[] { + "Hello.java", + "void ___eval() {\n" + + " new Runnable() {\n" + + " int ___run() throws Throwable {\n" + + " return blah;\n" + + " }\n" + + " private String blarg;\n" + + " public void run() {\n" + + " }\n" + + " };\n" + + "}\n" + + "public class Hello {\n" + + " private static int x;\n" + + " private String blah;\n" + + " public static void main(String[] args) {\n" + + " }\n" + + " public void hello() {\n" + + " }\n" + + " public boolean blah() {\n" + + " return false;\n" + + " }\n" + + " public void foo() {\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in Hello.java (at line 1)\n" + + " void ___eval() {\n" + + " ^^^^\n" + + "Syntax error on token \"void\", AT expected\n" + + "----------\n" + + "2. ERROR in Hello.java (at line 1)\n" + + " void ___eval() {\n" + + " ^\n" + + "Syntax error on token \")\", delete this token\n" + + "----------\n" + + "3. ERROR in Hello.java (at line 9)\n" + + " };\n" + + " ^\n" + + "Syntax error on token \"}\", { expected\n" + + "----------\n" + + "4. ERROR in Hello.java (at line 23)\n" + + " }\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete ClassBody\n" + + "----------\n" + + "5. ERROR in Hello.java (at line 23)\n" + + " }\n" + + " ^\n" + + "Syntax error, insert \"}\" to complete MemberValueArrayInitializer\n" + + "----------\n" + + "6. ERROR in Hello.java (at line 23)\n" + + " }\n" + + " ^\n" + + "Syntax error, insert \")\" to complete Modifiers\n" + + "----------\n" + + "7. ERROR in Hello.java (at line 23)\n" + + " }\n" + + " ^\n" + + "Syntax error, insert \"enum Identifier\" to complete EnumHeader\n" + + "----------\n" + + "8. ERROR in Hello.java (at line 23)\n" + + " }\n" + + " ^\n" + + "Syntax error, insert \"EnumBody\" to complete CompilationUnit\n" + + "----------\n" + ); +} +/* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67643 + * from 1.5 source level on most specific common super type is allowed + */ +public void test080() { + this.runConformTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "public class X {\n" + + " private static class C1 extends ArrayList {\n" + + " }\n" + + " private static class C2 extends ArrayList {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " ArrayList list = args == null ? new C1(): new C2();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); +} +public static Class testClass() { + return Compliance_1_5.class; +} +} diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java index c465b02547..c3cd46df04 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java @@ -418,10 +418,83 @@ public void test009() { " [pc: 61, pc: 95] local: b index: 1 type: Z\n" + " [pc: 71, pc: 95] local: s index: 2 type: Ljava/lang/String;\n" + " [pc: 86, pc: 95] local: s2 index: 3 type: Ljava/lang/String;\n"; - if (actualOutput.indexOf(expectedOutput) == -1){ - System.out.println(Util.displayString(actualOutput, 2)); + + String expectedOutput15 = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 3, Locals: 4\n" + + " public static void main(String[] args);\n" + + " 0 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 3 ldc #23 <String \"1\">\n" + + " 5 invokevirtual #29 <Method java/io/PrintStream.print(Ljava/lang/String;)V>\n" + + " 8 aconst_null\n" + + " 9 goto 13\n" + + " 12 aconst_null\n" + + " 13 aconst_null\n" + + " 14 goto 18\n" + + " 17 aconst_null\n" + + " 18 if_acmpne 29\n" + + " 21 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 24 ldc #31 <String \"2\">\n" + + " 26 invokevirtual #29 <Method java/io/PrintStream.print(Ljava/lang/String;)V>\n" + + " 29 new #33 java/lang/StringBuilder\n" + + " 32 dup\n" + + " 33 ldc #35 <String \"[\">\n" + + " 35 invokespecial #37 <Method java/lang/StringBuilder.<init>(Ljava/lang/String;)V>\n" + + " 38 aconst_null\n" + + " 39 invokevirtual #41 <Method java/lang/StringBuilder.append(Ljava/lang/String;)Ljava/lang/StringBuilder;>\n" + + " 42 ldc #43 <String \"]\">\n" + + " 44 invokevirtual #41 <Method java/lang/StringBuilder.append(Ljava/lang/String;)Ljava/lang/StringBuilder;>\n" + + " 47 invokevirtual #47 <Method java/lang/StringBuilder.toString()Ljava/lang/String;>\n" + + " 50 ldc #49 <String \"[null]\">\n" + + " 52 if_acmpne 59\n" + + " 55 iconst_1\n" + + " 56 goto 60\n" + + " 59 iconst_0\n" + + " 60 istore_1\n" + + " 61 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 64 ldc #51 <String \"3\">\n" + + " 66 invokevirtual #29 <Method java/io/PrintStream.print(Ljava/lang/String;)V>\n" + + " 69 aconst_null\n" + + " 70 astore_2\n" + + " 71 aload_2\n" + + " 72 ifnonnull 83\n" + + " 75 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 78 ldc #53 <String \"4\">\n" + + " 80 invokevirtual #29 <Method java/io/PrintStream.print(Ljava/lang/String;)V>\n" + + " 83 ldc #55 <String \"aaa\">\n" + + " 85 astore_3\n" + + " 86 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 89 ldc #57 <String \"5\">\n" + + " 91 invokevirtual #60 <Method java/io/PrintStream.println(Ljava/lang/String;)V>\n" + + " 94 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 3]\n" + + " [pc: 8, line: 4]\n" + + " [pc: 21, line: 5]\n" + + " [pc: 29, line: 6]\n" + + " [pc: 61, line: 7]\n" + + " [pc: 69, line: 8]\n" + + " [pc: 71, line: 9]\n" + + " [pc: 83, line: 10]\n" + + " [pc: 86, line: 11]\n" + + " [pc: 94, line: 12]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 95] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 61, pc: 95] local: b index: 1 type: Z\n" + + " [pc: 71, pc: 95] local: s index: 2 type: Ljava/lang/String;\n" + + " [pc: 86, pc: 95] local: s2 index: 3 type: Ljava/lang/String;\n"; + + if (COMPLIANCE_1_5.equals(this.complianceLevel)) { + if (actualOutput.indexOf(expectedOutput15) == -1){ + System.out.println(Util.displayString(actualOutput, 2)); + } + assertTrue("unexpected bytecode sequence", actualOutput.indexOf(expectedOutput15) != -1); + } else { + if (actualOutput.indexOf(expectedOutput) == -1){ + System.out.println(Util.displayString(actualOutput, 2)); + } + assertTrue("unexpected bytecode sequence", actualOutput.indexOf(expectedOutput) != -1); } - assertTrue("unexpected bytecode sequence", actualOutput.indexOf(expectedOutput) != -1); } /* @@ -470,7 +543,14 @@ public void test010() { " 9 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + " 12 ldc #31 <String \"SHOULDN\'T BE GENERATED\">\n" + " 14 invokevirtual #29 <Method java/io/PrintStream.print(Ljava/lang/String;)V>\n" + - " 17 return\n"; + " 17 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 4]\n" + + " [pc: 8, line: 5]\n" + + " [pc: 9, line: 7]\n" + + " [pc: 17, line: 8]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 18] local: args index: 0 type: [Ljava/lang/String;\n"; if (actualOutput.indexOf(expectedOutput) == -1){ System.out.println(Util.displayString(actualOutput, 2)); } 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 new file mode 100644 index 0000000000..707dd6565d --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java @@ -0,0 +1,1434 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.regression; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +import junit.framework.Test; + +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; + +import org.eclipse.jdt.core.ToolFactory; +import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; + +public class ForeachStatementTest extends AbstractRegressionTest { + +public ForeachStatementTest(String name) { + super(name); +} + +/* + * Toggle compiler in mode -1.5 + */ +protected Map getCompilerOptions() { + Map options = super.getCompilerOptions(); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); + return options; +} +static { + // Names of tests to run: can be "testBugXXXX" or "BugXXXX") +// testsNames = new String[] { "Bug51529a", "Bug51529b" }; + // Numbers of tests to run: "test<number>" will be run for each number of this array +// testsNumbers = new int[] { 22 }; + // Range numbers of tests to run: all tests between "test<first>" and "test<last>" will be run for { first, last } +// testsRange = new int[] { 21, 50 }; +// testsRange = new int[] { -1, 50 }; // run all tests with a number less or equals to 50 +// testsRange = new int[] { 10, -1 }; // run all tests with a number greater or equals to 10 +} +public static Test suite() { + if (testsNames != null || testsNumbers!=null || testsRange!=null) { + return new RegressionTestSetup(buildTestSuite(testClass()), highestComplianceLevels()); + } + return setupSuite(testClass()); +} +public void test001() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " \n" + + " for (char c : \"SUCCESS\".toCharArray()) {\n" + + " System.out.print(c);\n" + + " }\n" + + " System.out.println();\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); +} +public void test002() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " \n" + + " for (int value : new int[] {value}) {\n" + + " System.out.println(value);\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " for (int value : new int[] {value}) {\n" + + " ^^^^^\n" + + "The local variable value may not have been initialized\n" + + "----------\n"); +} +public void test003() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " \n" + + " for (int value : value) {\n" + + " System.out.println(value);\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " for (int value : value) {\n" + + " ^^^^^\n" + + "Can only iterate over an array or an instance of java.lang.Iterable\n" + + "----------\n"); +} +public void test004() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[] tab = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };\n" + + " int sum = 0;\n" + + " loop: for (final int e : tab) {\n" + + " sum += e;\n" + + " if (e == 3) {\n" + + " break loop;\n" + + " }\n" + + " }\n" + + " System.out.println(sum);\n" + + " }\n" + + "}\n", + }, + "6"); +} +public void test005() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " final int i;\n" + + " int[] tab = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };\n" + + " int sum = 0;\n" + + " loop: for (final int e : tab) {\n" + + " sum += e;\n" + + " if (e == 3) {\n" + + " i = 1;\n" + + " break loop;\n" + + " }\n" + + " }\n" + + " System.out.println(sum + i);\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 13)\n" + + " System.out.println(sum + i);\n" + + " ^\n" + + "The local variable i may not have been initialized\n" + + "----------\n"); +} +public void test006() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " final int i;\n" + + " int[] tab = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };\n" + + " loop: for (final int e : tab) {\n" + + " i = e;\n" + + " if (e == 3) {\n" + + " i = 1;\n" + + " break loop;\n" + + " }\n" + + " }\n" + + " System.out.println(i);\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " i = e;\n" + + " ^\n" + + "The final local variable i may already have been assigned\n" + + "----------\n" + + "2. ERROR in X.java (at line 9)\n" + + " i = 1;\n" + + " ^\n" + + "The final local variable i may already have been assigned\n" + + "----------\n" + + "3. ERROR in X.java (at line 13)\n" + + " System.out.println(i);\n" + + " ^\n" + + "The local variable i may not have been initialized\n" + + "----------\n"); +} +public void test007() { + Map customOptions = this.getCompilerOptions(); + customOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE); + + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int i;\n" + + " int[] tab = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };\n" + + " for (final int e : tab) {\n" + + " i = e;\n" + + " }\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS", + null, + true, + null, + customOptions); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 4, Locals: 7\n" + + " public static void main(String[] args);\n" + + " 0 bipush 9\n" + + " 2 newarray #10 int\n" + + " 4 dup\n" + + " 5 iconst_0\n" + + " 6 iconst_1\n" + + " 7 iastore\n" + + " 8 dup\n" + + " 9 iconst_1\n" + + " 10 iconst_2\n" + + " 11 iastore\n" + + " 12 dup\n" + + " 13 iconst_2\n" + + " 14 iconst_3\n" + + " 15 iastore\n" + + " 16 dup\n" + + " 17 iconst_3\n" + + " 18 iconst_4\n" + + " 19 iastore\n" + + " 20 dup\n" + + " 21 iconst_4\n" + + " 22 iconst_5\n" + + " 23 iastore\n" + + " 24 dup\n" + + " 25 iconst_5\n" + + " 26 bipush 6\n" + + " 28 iastore\n" + + " 29 dup\n" + + " 30 bipush 6\n" + + " 32 bipush 7\n" + + " 34 iastore\n" + + " 35 dup\n" + + " 36 bipush 7\n" + + " 38 bipush 8\n" + + " 40 iastore\n" + + " 41 dup\n" + + " 42 bipush 8\n" + + " 44 bipush 9\n" + + " 46 iastore\n" + + " 47 astore_2\n" + + " 48 aload_2\n" + + " 49 astore 6\n" + + " 51 iconst_0\n" + + " 52 istore 4\n" + + " 54 aload 6\n" + + " 56 arraylength\n" + + " 57 istore 5\n" + + " 59 goto 73\n" + + " 62 aload 6\n" + + " 64 iload 4\n" + + " 66 iaload\n" + + " 67 istore_3\n" + + " 68 iload_3\n" + + " 69 istore_1\n" + + " 70 iinc 4 1\n" + + " 73 iload 4\n" + + " 75 iload 5\n" + + " 77 if_icmplt 62\n" + + " 80 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 83 ldc #23 <String \"SUCCESS\">\n" + + " 85 invokevirtual #29 <Method java/io/PrintStream.println(Ljava/lang/String;)V>\n" + + " 88 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 5]\n" + + " [pc: 48, line: 6]\n" + + " [pc: 68, line: 7]\n" + + " [pc: 70, line: 6]\n" + + " [pc: 80, line: 9]\n" + + " [pc: 88, line: 10]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 89] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 70, pc: 73] local: i index: 1 type: I\n" + + " [pc: 48, pc: 89] local: tab index: 2 type: [I\n" + + " [pc: 68, pc: 80] local: e index: 3 type: I\n"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } +} +public void test008() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(Iterable col) {\n" + + " for (X x : col) {\n" + + " System.out.println(x);\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " for (X x : col) {\n" + + " ^^^\n" + + "Type mismatch: cannot convert from element type Object to X\n" + + "----------\n"); +} +public void test009() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(Iterable<String> col) {\n" + + " for (X x : col) {\n" + + " System.out.println(x);\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " for (X x : col) {\n" + + " ^^^\n" + + "Type mismatch: cannot convert from element type String to X\n" + + "----------\n"); +} +/* + * Test implicit conversion to float. If missing, VerifyError + */ +public void test010() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[] tab = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };\n" + + " int sum = 0;\n" + + " loop: for (final float e : tab) {\n" + + " sum += e;\n" + + " if (e == 3) {\n" + + " break loop;\n" + + " }\n" + + " }\n" + + " System.out.println(sum);\n" + + " }\n" + + "}\n", + }, + "6"); +} +/* + * Cannot convert int[] to int + */ +public void test011() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[][] tab = new int[][] {\n" + + " new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 },\n" + + " new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 },\n" + + " };\n" + + " loop: for (final int e : tab) {\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " loop: for (final int e : tab) {\n" + + " ^^^\n" + + "Type mismatch: cannot convert from element type int[] to int\n" + + "----------\n"); +} +/* + * Ensure access to int[] + */ +public void test012() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[][] tab = new int[][] {\n" + + " new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 },\n" + + " new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 },\n" + + " };\n" + + " for (final int[] e : tab) {\n" + + " System.out.print(e.length);\n" + + " }\n" + + " }\n" + + "}\n", + }, + "99"); +} +/* + * Ensure access to int[] + */ +public void test013() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[][] tab = new int[][] {\n" + + " new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 },\n" + + " new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 },\n" + + " };\n" + + " for (final int[] e : tab) {\n" + + " System.out.print(e[0]);\n" + + " }\n" + + " }\n" + + "}\n", + }, + "11"); +} +/* + * Empty block action + */ +public void test014() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[] tab = new int[] { 1 };\n" + + " for (final int e : tab) {\n" + + " }\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 4, Locals: 2\n" + + " public static void main(String[] args);\n" + + " 0 iconst_1\n" + + " 1 newarray #10 int\n" + + " 3 dup\n" + + " 4 iconst_0\n" + + " 5 iconst_1\n" + + " 6 iastore\n" + + " 7 astore_1\n" + + " 8 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 11 ldc #23 <String \"SUCCESS\">\n" + + " 13 invokevirtual #29 <Method java/io/PrintStream.println(Ljava/lang/String;)V>\n" + + " 16 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 4]\n" + + " [pc: 8, line: 7]\n" + + " [pc: 16, line: 8]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 17] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 8, pc: 17] local: tab index: 1 type: [I\n"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } +} +/* + * Empty statement action + */ +public void test015() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[] tab = new int[] { 1 };\n" + + " for (final int e : tab);\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 4, Locals: 2\n" + + " public static void main(String[] args);\n" + + " 0 iconst_1\n" + + " 1 newarray #10 int\n" + + " 3 dup\n" + + " 4 iconst_0\n" + + " 5 iconst_1\n" + + " 6 iastore\n" + + " 7 astore_1\n" + + " 8 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 11 ldc #23 <String \"SUCCESS\">\n" + + " 13 invokevirtual #29 <Method java/io/PrintStream.println(Ljava/lang/String;)V>\n" + + " 16 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 4]\n" + + " [pc: 8, line: 6]\n" + + " [pc: 16, line: 7]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 17] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 8, pc: 17] local: tab index: 1 type: [I\n"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } +} +/* + * Empty block action + */ +public void test016() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[] tab = new int[] { 1 };\n" + + " for (final int e : tab) {;\n" + + " }\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 4, Locals: 5\n" + + " public static void main(String[] args);\n" + + " 0 iconst_1\n" + + " 1 newarray #10 int\n" + + " 3 dup\n" + + " 4 iconst_0\n" + + " 5 iconst_1\n" + + " 6 iastore\n" + + " 7 astore_1\n" + + " 8 aload_1\n" + + " 9 astore 4\n" + + " 11 iconst_0\n" + + " 12 istore_2\n" + + " 13 aload 4\n" + + " 15 arraylength\n" + + " 16 istore_3\n" + + " 17 goto 23\n" + + " 20 iinc 2 1\n" + + " 23 iload_2\n" + + " 24 iload_3\n" + + " 25 if_icmplt 20\n" + + " 28 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 31 ldc #23 <String \"SUCCESS\">\n" + + " 33 invokevirtual #29 <Method java/io/PrintStream.println(Ljava/lang/String;)V>\n" + + " 36 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 4]\n" + + " [pc: 8, line: 5]\n" + + " [pc: 28, line: 7]\n" + + " [pc: 36, line: 8]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 37] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 8, pc: 37] local: tab index: 1 type: [I\n"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } +} +/* + * Ensure access to int[] + */ +public void test017() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[] tab = new int[] { 1 };\n" + + " for (final int e : tab) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); +} +/* + * Break the loop + */ +public void test018() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[] tab = new int[] { 1 };\n" + + " for (final int e : tab) {\n" + + " System.out.println(e);\n" + + " break;\n" + + " }\n" + + " }\n" + + "}\n", + }, + "1"); + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 4, Locals: 6\n" + + " public static void main(String[] args);\n" + + " 0 iconst_1\n" + + " 1 newarray #10 int\n" + + " 3 dup\n" + + " 4 iconst_0\n" + + " 5 iconst_1\n" + + " 6 iastore\n" + + " 7 astore_1\n" + + " 8 aload_1\n" + + " 9 astore 5\n" + + " 11 iconst_0\n" + + " 12 istore_3\n" + + " 13 aload 5\n" + + " 15 arraylength\n" + + " 16 istore 4\n" + + " 18 goto 36\n" + + " 21 aload 5\n" + + " 23 iload_3\n" + + " 24 iaload\n" + + " 25 istore_2\n" + + " 26 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 29 iload_2\n" + + " 30 invokevirtual #27 <Method java/io/PrintStream.println(I)V>\n" + + " 33 goto 42\n" + + " 36 iload_3\n" + + " 37 iload 4\n" + + " 39 if_icmplt 21\n" + + " 42 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 4]\n" + + " [pc: 8, line: 5]\n" + + " [pc: 26, line: 6]\n" + + " [pc: 33, line: 7]\n" + + " [pc: 36, line: 5]\n" + + " [pc: 42, line: 9]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 43] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 8, pc: 43] local: tab index: 1 type: [I\n" + + " [pc: 26, pc: 42] local: e index: 2 type: I\n"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } +} +/* + * Break the loop + */ +public void test019() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[] tab = new int[] {};\n" + + " System.out.print(\"SUC\");\n" + + " for (final int e : tab) {\n" + + " System.out.print(\"1x\");\n" + + " break;\n" + + " }\n" + + " System.out.println(\"CESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 2, Locals: 5\n" + + " public static void main(String[] args);\n" + + " 0 iconst_0\n" + + " 1 newarray #10 int\n" + + " 3 astore_1\n" + + " 4 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 7 ldc #23 <String \"SUC\">\n" + + " 9 invokevirtual #29 <Method java/io/PrintStream.print(Ljava/lang/String;)V>\n" + + " 12 aload_1\n" + + " 13 astore 4\n" + + " 15 iconst_0\n" + + " 16 istore_2\n" + + " 17 aload 4\n" + + " 19 arraylength\n" + + " 20 istore_3\n" + + " 21 goto 35\n" + + " 24 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 27 ldc #31 <String \"1x\">\n" + + " 29 invokevirtual #29 <Method java/io/PrintStream.print(Ljava/lang/String;)V>\n" + + " 32 goto 40\n" + + " 35 iload_2\n" + + " 36 iload_3\n" + + " 37 if_icmplt 24\n" + + " 40 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 43 ldc #33 <String \"CESS\">\n" + + " 45 invokevirtual #36 <Method java/io/PrintStream.println(Ljava/lang/String;)V>\n" + + " 48 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 4]\n" + + " [pc: 4, line: 5]\n" + + " [pc: 12, line: 6]\n" + + " [pc: 24, line: 7]\n" + + " [pc: 32, line: 8]\n" + + " [pc: 35, line: 6]\n" + + " [pc: 40, line: 10]\n" + + " [pc: 48, line: 11]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 49] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 4, pc: 49] local: tab index: 1 type: [I\n"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } +} +/* + * Break the loop + */ +public void test020() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " int[] tab = new int[] {};\n" + + " System.out.print(\"SUC\");\n" + + " loop: for (final int e : tab) {\n" + + " System.out.print(\"1x\");\n" + + " continue loop;\n" + + " }\n" + + " System.out.println(\"CESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 2, Locals: 5\n" + + " public static void main(String[] args);\n" + + " 0 iconst_0\n" + + " 1 newarray #10 int\n" + + " 3 astore_1\n" + + " 4 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 7 ldc #23 <String \"SUC\">\n" + + " 9 invokevirtual #29 <Method java/io/PrintStream.print(Ljava/lang/String;)V>\n" + + " 12 aload_1\n" + + " 13 astore 4\n" + + " 15 iconst_0\n" + + " 16 istore_2\n" + + " 17 aload 4\n" + + " 19 arraylength\n" + + " 20 istore_3\n" + + " 21 goto 35\n" + + " 24 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 27 ldc #31 <String \"1x\">\n" + + " 29 invokevirtual #29 <Method java/io/PrintStream.print(Ljava/lang/String;)V>\n" + + " 32 iinc 2 1\n" + + " 35 iload_2\n" + + " 36 iload_3\n" + + " 37 if_icmplt 24\n" + + " 40 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 43 ldc #33 <String \"CESS\">\n" + + " 45 invokevirtual #36 <Method java/io/PrintStream.println(Ljava/lang/String;)V>\n" + + " 48 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 4]\n" + + " [pc: 4, line: 5]\n" + + " [pc: 12, line: 6]\n" + + " [pc: 24, line: 7]\n" + + " [pc: 35, line: 6]\n" + + " [pc: 40, line: 10]\n" + + " [pc: 48, line: 11]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 49] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 4, pc: 49] local: tab index: 1 type: [I\n"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } +} +public void test021() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " int[] tab = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };\n" + + " int sum = 0;\n" + + " int i = 0;\n" + + " loop1: while(true) {\n" + + " i++;\n" + + " loop: for (final int e : tab) {\n" + + " sum += e;\n" + + " if (i == 3) {\n" + + " break loop1;\n" + + " } else if (e == 5) {\n" + + " break loop;\n" + + " } else {\n" + + " continue;\n" + + " }\n" + + " }\n" + + " }\n" + + " System.out.println(sum);\n" + + " }\n" + + "}", + }, + "31"); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 4, Locals: 8\n" + + " public static void main(String[] args);\n" + + " 0 bipush 9\n" + + " 2 newarray #10 int\n" + + " 4 dup\n" + + " 5 iconst_0\n" + + " 6 iconst_1\n" + + " 7 iastore\n" + + " 8 dup\n" + + " 9 iconst_1\n" + + " 10 iconst_2\n" + + " 11 iastore\n" + + " 12 dup\n" + + " 13 iconst_2\n" + + " 14 iconst_3\n" + + " 15 iastore\n" + + " 16 dup\n" + + " 17 iconst_3\n" + + " 18 iconst_4\n" + + " 19 iastore\n" + + " 20 dup\n" + + " 21 iconst_4\n" + + " 22 iconst_5\n" + + " 23 iastore\n" + + " 24 dup\n" + + " 25 iconst_5\n" + + " 26 bipush 6\n" + + " 28 iastore\n" + + " 29 dup\n" + + " 30 bipush 6\n" + + " 32 bipush 7\n" + + " 34 iastore\n" + + " 35 dup\n" + + " 36 bipush 7\n" + + " 38 bipush 8\n" + + " 40 iastore\n" + + " 41 dup\n" + + " 42 bipush 8\n" + + " 44 bipush 9\n" + + " 46 iastore\n" + + " 47 astore_1\n" + + " 48 iconst_0\n" + + " 49 istore_2\n" + + " 50 iconst_0\n" + + " 51 istore_3\n" + + " 52 iinc 3 1\n" + + " 55 aload_1\n" + + " 56 astore 7\n" + + " 58 iconst_0\n" + + " 59 istore 5\n" + + " 61 aload 7\n" + + " 63 arraylength\n" + + " 64 istore 6\n" + + " 66 goto 101\n" + + " 69 aload 7\n" + + " 71 iload 5\n" + + " 73 iaload\n" + + " 74 istore 4\n" + + " 76 iload_2\n" + + " 77 iload 4\n" + + " 79 iadd\n" + + " 80 istore_2\n" + + " 81 iload_3\n" + + " 82 iconst_3\n" + + " 83 if_icmpne 89\n" + + " 86 goto 111\n" + + " 89 iload 4\n" + + " 91 iconst_5\n" + + " 92 if_icmpne 98\n" + + " 95 goto 108\n" + + " 98 iinc 5 1\n" + + " 101 iload 5\n" + + " 103 iload 6\n" + + " 105 if_icmplt 69\n" + + " 108 goto 52\n" + + " 111 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 114 iload_2\n" + + " 115 invokevirtual #27 <Method java/io/PrintStream.println(I)V>\n" + + " 118 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 3]\n" + + " [pc: 48, line: 4]\n" + + " [pc: 50, line: 5]\n" + + " [pc: 52, line: 7]\n" + + " [pc: 55, line: 8]\n" + + " [pc: 76, line: 9]\n" + + " [pc: 81, line: 10]\n" + + " [pc: 86, line: 11]\n" + + " [pc: 89, line: 12]\n" + + " [pc: 95, line: 13]\n" + + " [pc: 101, line: 8]\n" + + " [pc: 108, line: 6]\n" + + " [pc: 111, line: 19]\n" + + " [pc: 118, line: 20]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 119] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 48, pc: 119] local: tab index: 1 type: [I\n" + + " [pc: 50, pc: 119] local: sum index: 2 type: I\n" + + " [pc: 52, pc: 119] local: i index: 3 type: I\n" + + " [pc: 76, pc: 108] local: e index: 4 type: I\n"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } +} +public void test022() { + this.runConformTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " ArrayList<Integer> arrayList = new ArrayList<Integer>();\n" + + " for (int i = 0; i < 10; i++) {\n" + + " arrayList.add(new Integer(i));\n" + + " }\n" + + " int sum = 0;\n" + + " for (Integer e : arrayList) {\n" + + " sum += e.intValue();\n" + + " }\n" + + " System.out.println(sum);\n" + + " }\n" + + "}", + }, + "45"); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 4, Locals: 6\n" + + " public static void main(String[] args);\n" + + " 0 new #17 java/util/ArrayList\n" + + " 3 dup\n" + + " 4 invokespecial #18 <Method java/util/ArrayList.<init>()V>\n" + + " 7 astore_1\n" + + " 8 iconst_0\n" + + " 9 istore_2\n" + + " 10 goto 29\n" + + " 13 aload_1\n" + + " 14 new #20 java/lang/Integer\n" + + " 17 dup\n" + + " 18 iload_2\n" + + " 19 invokespecial #23 <Method java/lang/Integer.<init>(I)V>\n" + + " 22 invokevirtual #27 <Method java/util/ArrayList.add(Ljava/lang/Object;)Z>\n" + + " 25 pop\n" + + " 26 iinc 2 1\n" + + " 29 iload_2\n" + + " 30 bipush 10\n" + + " 32 if_icmplt 13\n" + + " 35 iconst_0\n" + + " 36 istore_2\n" + + " 37 aload_1\n" + + " 38 dup\n" + + " 39 astore 5\n" + + " 41 invokevirtual #32 <Method java/util/ArrayList.iterator()Ljava/util/Iterator;>\n" + + " 44 astore 4\n" + + " 46 goto 67\n" + + " 49 aload 4\n" + + " 51 invokeinterface [nargs : 1] #38 <Interface method java/util/Iterator.next()Ljava/lang/Object;>\n" + + " 56 checkcast #20 java/lang/Integer\n" + + " 59 astore_3\n" + + " 60 iload_2\n" + + " 61 aload_3\n" + + " 62 invokevirtual #42 <Method java/lang/Integer.intValue()I>\n" + + " 65 iadd\n" + + " 66 istore_2\n" + + " 67 aload 4\n" + + " 69 invokeinterface [nargs : 1] #46 <Interface method java/util/Iterator.hasNext()Z>\n" + + " 74 ifne 49\n" + + " 77 getstatic #52 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 80 iload_2\n" + + " 81 invokevirtual #57 <Method java/io/PrintStream.println(I)V>\n" + + " 84 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 5]\n" + + " [pc: 8, line: 6]\n" + + " [pc: 13, line: 7]\n" + + " [pc: 26, line: 6]\n" + + " [pc: 35, line: 9]\n" + + " [pc: 37, line: 10]\n" + + " [pc: 60, line: 11]\n" + + " [pc: 67, line: 10]\n" + + " [pc: 77, line: 13]\n" + + " [pc: 84, line: 14]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 85] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 8, pc: 85] local: arrayList index: 1 type: Ljava/util/ArrayList;\n" + + " [pc: 10, pc: 35] local: i index: 2 type: I\n" + + " [pc: 37, pc: 85] local: sum index: 2 type: I\n" + + " [pc: 60, pc: 77] local: e index: 3 type: Ljava/lang/Integer;\n" + + " Local variable type table:\n" + + " [pc: 8, pc: 85] local: arrayList index: 1 type: Ljava/util/ArrayList<Ljava/lang/Integer;>;\n"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } +} + +/* + * Type mismatch, using non parameterized collection type (indirectly implementing parameterized type) + */ +public void test023() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.Iterator;\n" + + "\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " for (Thread s : new AX()) {\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "class AX implements Iterable<String> {\n" + + " \n" + + " public Iterator<String> iterator() {\n" + + " return null;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " for (Thread s : new AX()) {\n" + + " ^^^^^^^^\n" + + "Type mismatch: cannot convert from element type String to Thread\n" + + "----------\n"); +} +public void test024() { + this.runConformTest( + new String[] { + "X.java", + "import java.util.List;\n" + + "import java.util.ArrayList;\n" + + "\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " String[] tab = new String[] {\"SUCCESS\"};\n" + + " List list = new ArrayList();\n" + + " for (String arg : tab) { \n" + + " list.add(arg);\n" + + " }\n" + + " for (Object arg: list) {\n" + + " System.out.print(arg);\n" + + " }\n" + + " }\n" + + "}", + }, + "SUCCESS"); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 4, Locals: 7\n" + + " public static void main(String[] args);\n" + + " 0 iconst_1\n" + + " 1 anewarray #17 java/lang/String\n" + + " 4 dup\n" + + " 5 iconst_0\n" + + " 6 ldc #19 <String \"SUCCESS\">\n" + + " 8 aastore\n" + + " 9 astore_1\n" + + " 10 new #21 java/util/ArrayList\n" + + " 13 dup\n" + + " 14 invokespecial #22 <Method java/util/ArrayList.<init>()V>\n" + + " 17 astore_2\n" + + " 18 aload_1\n" + + " 19 astore 6\n" + + " 21 iconst_0\n" + + " 22 istore 4\n" + + " 24 aload 6\n" + + " 26 arraylength\n" + + " 27 istore 5\n" + + " 29 goto 49\n" + + " 32 aload 6\n" + + " 34 iload 4\n" + + " 36 aaload\n" + + " 37 astore_3\n" + + " 38 aload_2\n" + + " 39 aload_3\n" + + " 40 invokeinterface [nargs : 2] #28 <Interface method java/util/List.add(Ljava/lang/Object;)Z>\n" + + " 45 pop\n" + + " 46 iinc 4 1\n" + + " 49 iload 4\n" + + " 51 iload 5\n" + + " 53 if_icmplt 32\n" + + " 56 aload_2\n" + + " 57 dup\n" + + " 58 astore 5\n" + + " 60 invokeinterface [nargs : 1] #33 <Interface method java/util/List.iterator()Ljava/util/Iterator;>\n" + + " 65 astore 4\n" + + " 67 goto 85\n" + + " 70 aload 4\n" + + " 72 invokeinterface [nargs : 1] #39 <Interface method java/util/Iterator.next()Ljava/lang/Object;>\n" + + " 77 astore_3\n" + + " 78 getstatic #45 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 81 aload_3\n" + + " 82 invokevirtual #51 <Method java/io/PrintStream.print(Ljava/lang/Object;)V>\n" + + " 85 aload 4\n" + + " 87 invokeinterface [nargs : 1] #55 <Interface method java/util/Iterator.hasNext()Z>\n" + + " 92 ifne 70\n" + + " 95 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 6]\n" + + " [pc: 10, line: 7]\n" + + " [pc: 18, line: 8]\n" + + " [pc: 38, line: 9]\n" + + " [pc: 46, line: 8]\n" + + " [pc: 56, line: 11]\n" + + " [pc: 78, line: 12]\n" + + " [pc: 85, line: 11]\n" + + " [pc: 95, line: 14]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 96] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 10, pc: 96] local: tab index: 1 type: [Ljava/lang/String;\n" + + " [pc: 18, pc: 96] local: list index: 2 type: Ljava/util/List;\n" + + " [pc: 38, pc: 56] local: arg index: 3 type: Ljava/lang/String;\n" + + " [pc: 78, pc: 95] local: arg index: 3 type: Ljava/lang/Object;\n"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } +} +public void test025() { + this.runConformTest( + new String[] { + "X.java", + "import java.util.List;\n" + + "import java.util.ArrayList;\n" + + "\n" + + "public class X {\n" + + " public static void bug(List<String> lines) {\n" + + " for (int i=0; i<1; i++) {\n" + + " for (String test: lines) {\n" + + " System.out.print(test);\n" + + " }\n" + + " }\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " ArrayList<String> tab = new ArrayList<String>();\n" + + " tab.add(\"SUCCESS\");\n" + + " bug(tab);\n" + + " }\n" + + "}", + }, + "SUCCESS"); +} +// 68440 - verify error due to local variable invalid slot sharing +public void test026() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " Object[] array = {\n" + + " };\n" + + " void test() {\n" + + " for (Object object : array) {\n" + + " String str = object.toString();\n" + + " str += \"\";\n" + // force 'str' to be preserved during codegen + " }\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X().test();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); +} +// 68863 - missing local variable attribute after foreach statement +public void test027() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " Object[] array = {\n" + + " };\n" + + " java.util.ArrayList i; \n" + + " for (Object object : array) {\n" + + " if (args == null) {\n" + + " i = null;\n" + + " break;\n" + + " }\n" + + " return;\n" + + " };\n" + + " System.out.println(\"SUCCESS\"); \n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 2, Locals: 5\n" + + " public static void main(String[] args);\n" + + " 0 iconst_0\n" + + " 1 anewarray #4 java/lang/Object\n" + + " 4 astore_1\n" + + " 5 aload_1\n" + + " 6 astore 4\n" + + " 8 iconst_0\n" + + " 9 istore_2\n" + + " 10 aload 4\n" + + " 12 arraylength\n" + + " 13 istore_3\n" + + " 14 goto 27\n" + + " 17 aload_0\n" + + " 18 ifnonnull 26\n" + + " 21 aconst_null\n" + + " 22 pop\n" + + " 23 goto 32\n" + + " 26 return\n" + + " 27 iload_2\n" + + " 28 iload_3\n" + + " 29 if_icmplt 17\n" + + " 32 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 35 ldc #23 <String \"SUCCESS\">\n" + + " 37 invokevirtual #29 <Method java/io/PrintStream.println(Ljava/lang/String;)V>\n" + + " 40 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 3]\n" + + " [pc: 5, line: 6]\n" + + " [pc: 17, line: 7]\n" + + " [pc: 21, line: 8]\n" + + " [pc: 23, line: 9]\n" + + " [pc: 26, line: 11]\n" + + " [pc: 27, line: 6]\n" + + " [pc: 32, line: 13]\n" + + " [pc: 40, line: 14]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 41] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 5, pc: 41] local: array index: 1 type: [Ljava/lang/Object;\n" + + "}"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } +} + +public static Class testClass() { + return ForeachStatementTest.class; +} +} diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java new file mode 100644 index 0000000000..5a2146ab69 --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeSignatureTest.java @@ -0,0 +1,1032 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.regression; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Map; + +import junit.framework.Test; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.ToolFactory; +import org.eclipse.jdt.core.tests.runtime.TargetException; +import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.core.util.IAttributeNamesConstants; +import org.eclipse.jdt.core.util.IClassFileAttribute; +import org.eclipse.jdt.core.util.IClassFileReader; +import org.eclipse.jdt.core.util.ICodeAttribute; +import org.eclipse.jdt.core.util.ILocalVariableTypeTableAttribute; +import org.eclipse.jdt.core.util.ILocalVariableTypeTableEntry; +import org.eclipse.jdt.core.util.IMethodInfo; +import org.eclipse.jdt.core.util.ISignatureAttribute; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; +import org.eclipse.jdt.internal.compiler.env.IBinaryField; +import org.eclipse.jdt.internal.compiler.env.IBinaryMethod; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; + +public class GenericTypeSignatureTest extends AbstractRegressionTest { + class Logger extends Thread { + StringBuffer buffer; + InputStream inputStream; + String type; + Logger(InputStream inputStream, String type) { + this.inputStream = inputStream; + this.type = type; + this.buffer = new StringBuffer(); + } + + public void run() { + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(this.inputStream)); + String line = null; + while ((line = reader.readLine()) != null) { + buffer.append(this.type).append("->").append(line); + } + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + static final String RUN_SUN_JAVAC = System.getProperty("run.javac"); + static boolean RunJavac = CompilerOptions.ENABLED.equals(RUN_SUN_JAVAC); + static { + // Use this static to specify a subset of tests using testsNames, testNumbers or testsRange arrays +// testsRange = new int[] { 66, -1 }; +// testsNumbers = new int[] { 6, 7 }; + } + public static Test suite() { + if (testsNames != null || testsNumbers!=null || testsRange!=null) { + return new RegressionTestSetup(buildTestSuite(testClass()), highestComplianceLevels()); + } + return setupSuite(testClass()); + } + + public static Class testClass() { + return GenericTypeSignatureTest.class; + } + + IPath dirPath = new Path(OUTPUT_DIR); + + public GenericTypeSignatureTest(String name) { + super(name); + } + + /** + * @throws TargetException + */ + protected void cleanUp() { + Util.flushDirectoryContent(new File(OUTPUT_DIR)); + } + + /* + * Toggle compiler in mode -1.5 + */ + protected Map getCompilerOptions() { + Map options = super.getCompilerOptions(); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + return options; + } + + protected String[] getFileNames(String[] testFiles) { + int length = testFiles.length; + int max = length / 2; + String[] fileNames = new String[max]; + for (int i=0; i < max; i++) { + fileNames[i] = testFiles[i*2]; + } + return fileNames; + } + /* + * Run Sun compilation using javac. + * Use JRE directory to retrieve javac bin directory and current classpath for + * compilation. + * Launch compilation in a thread and verify that it does not take more than 5s + * to perform it. Otherwise abort the process and log in console. + */ + protected void runJavac(final String testName, String[] testFiles) { + try { + // Write files in dir + writeFiles(testFiles); + + final String[] fileNames = getFileNames(testFiles); + Process process = null; + try { + // Compute classpath + String[] classpath = getDefaultClassPaths(); + StringBuffer cp = new StringBuffer(); + int length = classpath.length; + for (int i = 0; i < length; i++) { + if (classpath[i].indexOf(" ") != -1) { + cp.append("\"" + classpath[i] + "\""); + } else { + cp.append(classpath[i]); + } + if (i<(length-1)) cp.append(";"); + } + // Compute command line + IPath jdkDir = (new Path(Util.getJREDirectory())).removeLastSegments(1); + IPath javacPath = jdkDir.append("bin").append("javac.exe"); + StringBuffer cmdLine = new StringBuffer(javacPath.toString()); + cmdLine.append(" -classpath "); + cmdLine.append(cp); + cmdLine.append(" -source 1.5 -deprecation -g -Xlint "); // enable recommended warnings + for (int i = 0, length2 = fileNames.length; i < length2; i++) { + cmdLine.append(fileNames[i] + " "); + } +// System.out.println(testName+": "+cmdLine.toString()); +// System.out.println(GenericTypeTest.this.dirPath.toFile().getAbsolutePath()); + // Launch process + process = Runtime.getRuntime().exec(cmdLine.toString(), null, GenericTypeSignatureTest.this.dirPath.toFile()); + // Log errors + Logger errorLogger = new Logger(process.getErrorStream(), "ERROR"); + + // Log output + Logger outputLogger = new Logger(process.getInputStream(), "OUTPUT"); + + // start the threads to run outputs (standard/error) + errorLogger.start(); + outputLogger.start(); + + // Wait for end of process + if (process.waitFor() != 0) { + System.out.println(testName+": javac has found error(s)!"); + } + } catch (IOException ioe) { + System.out.println(testName+": Not possible to launch Sun javac compilation!"); + } catch (InterruptedException e1) { + if (process != null) process.destroy(); + System.out.println(testName+": Sun javac compilation was aborted!"); + } + } catch (Exception e) { + // fails silently... + e.printStackTrace(); + } + } + + public void test001() { + final String[] testsSource = new String[] { + "X.java", + "public class X <T> extends p.A<T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " super(t);\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X<X<String>> xs = new X<X<String>>(new X<String>(\"SUCCESS\"));\n" + + " System.out.print(xs.t.t);\n" + + " }\n" + + "}", + "p/A.java", + "package p;\n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p;\n" + + " }\n" + + "}" + }; + this.runConformTest( + testsSource, + "SUCCESS"); + + try { + ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "X.class"); + assertEquals("Wrong signature", "<T:Ljava/lang/Object;>Lp/A<TT;>;", new String(classFileReader.getGenericSignature())); + } catch (ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + + IClassFileReader classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "X.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + IClassFileAttribute classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + ISignatureAttribute signatureAttribute = (ISignatureAttribute) classFileAttribute; + char[] signature = signatureAttribute.getSignature(); + assertNotNull("no signature", signature); + assertEquals("Wrong signature", "<T:Ljava/lang/Object;>Lp/A<TT;>;", new String(signature)); + IMethodInfo[] methodInfos = classFileReader.getMethodInfos(); + int length = methodInfos.length; + assertEquals("Wrong size", 2, length); + IMethodInfo mainMethod = null; + for (int i = 0; i < length; i++) { + IMethodInfo methodInfo = methodInfos[i]; + if ("main".equals(new String(methodInfo.getName()))) { + mainMethod = methodInfo; + break; + } + } + assertNotNull(mainMethod); + ICodeAttribute codeAttribute = mainMethod.getCodeAttribute(); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(codeAttribute, IAttributeNamesConstants.LOCAL_VARIABLE_TYPE_TABLE); + assertNotNull(classFileAttribute); + ILocalVariableTypeTableAttribute localVariableTypeTableAttribute = (ILocalVariableTypeTableAttribute) classFileAttribute; + ILocalVariableTypeTableEntry[] entries = localVariableTypeTableAttribute.getLocalVariableTypeTable(); + ILocalVariableTypeTableEntry xsEntry = null; + for (int i = 0, max = entries.length; i < max; i++) { + ILocalVariableTypeTableEntry entry = entries[i]; + if ("xs".equals(new String(entry.getName()))) { + xsEntry = entry; + break; + } + } + assertNotNull(xsEntry); + signature = xsEntry.getSignature(); + assertNotNull("no signature", signature); + assertEquals("Wrong signature", "LX<LX<Ljava/lang/String;>;>;", new String(signature)); + + IMethodInfo constructorMethod = null; + for (int i = 0; i < length; i++) { + IMethodInfo methodInfo = methodInfos[i]; + if ("<init>".equals(new String(methodInfo.getName()))) { + constructorMethod = methodInfo; + break; + } + } + assertNotNull(constructorMethod); + codeAttribute = constructorMethod.getCodeAttribute(); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(codeAttribute, IAttributeNamesConstants.LOCAL_VARIABLE_TYPE_TABLE); + assertNotNull(classFileAttribute); + localVariableTypeTableAttribute = (ILocalVariableTypeTableAttribute) classFileAttribute; + entries = localVariableTypeTableAttribute.getLocalVariableTypeTable(); + ILocalVariableTypeTableEntry thisEntry = null; + for (int i = 0, max = entries.length; i < max; i++) { + ILocalVariableTypeTableEntry entry = entries[i]; + if ("this".equals(new String(entry.getName()))) { + thisEntry = entry; + break; + } + } + assertNotNull(thisEntry); + signature = thisEntry.getSignature(); + assertNotNull("no signature", signature); + assertEquals("Wrong signature", "LX<TT;>;", new String(signature)); + ILocalVariableTypeTableEntry tEntry = null; + for (int i = 0, max = entries.length; i < max; i++) { + ILocalVariableTypeTableEntry entry = entries[i]; + if ("t".equals(new String(entry.getName()))) { + tEntry = entry; + break; + } + } + assertNotNull(tEntry); + signature = tEntry.getSignature(); + assertNotNull("no signature", signature); + assertEquals("Wrong signature", "TT;", new String(signature)); + + if (!RunJavac) return; + + // Compare with javac + cleanUp(); + runJavac("test001", testsSource); + + classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "X.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + signatureAttribute = (ISignatureAttribute) classFileAttribute; + signature = signatureAttribute.getSignature(); + assertNotNull("no signature", signature); + assertEquals("Wrong signature", "<T:Ljava/lang/Object;>Lp/A<TT;>;", new String(signature)); + methodInfos = classFileReader.getMethodInfos(); + length = methodInfos.length; + assertEquals("Wrong size", 2, length); + mainMethod = null; + for (int i = 0; i < length; i++) { + IMethodInfo methodInfo = methodInfos[i]; + if ("main".equals(new String(methodInfo.getName()))) { + mainMethod = methodInfo; + break; + } + } + assertNotNull(mainMethod); + codeAttribute = mainMethod.getCodeAttribute(); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(codeAttribute, IAttributeNamesConstants.LOCAL_VARIABLE_TYPE_TABLE); + assertNotNull(classFileAttribute); + localVariableTypeTableAttribute = (ILocalVariableTypeTableAttribute) classFileAttribute; + entries = localVariableTypeTableAttribute.getLocalVariableTypeTable(); + xsEntry = null; + for (int i = 0, max = entries.length; i < max; i++) { + ILocalVariableTypeTableEntry entry = entries[i]; + if ("xs".equals(new String(entry.getName()))) { + xsEntry = entry; + break; + } + } + assertNotNull(xsEntry); + signature = xsEntry.getSignature(); + assertNotNull("no signature", signature); + assertEquals("Wrong signature", "LX<LX<Ljava/lang/String;>;>;", new String(signature)); + + constructorMethod = null; + for (int i = 0; i < length; i++) { + IMethodInfo methodInfo = methodInfos[i]; + if ("<init>".equals(new String(methodInfo.getName()))) { + constructorMethod = methodInfo; + break; + } + } + assertNotNull(constructorMethod); + codeAttribute = constructorMethod.getCodeAttribute(); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(codeAttribute, IAttributeNamesConstants.LOCAL_VARIABLE_TYPE_TABLE); + assertNotNull(classFileAttribute); + localVariableTypeTableAttribute = (ILocalVariableTypeTableAttribute) classFileAttribute; + entries = localVariableTypeTableAttribute.getLocalVariableTypeTable(); + thisEntry = null; + for (int i = 0, max = entries.length; i < max; i++) { + ILocalVariableTypeTableEntry entry = entries[i]; + if ("this".equals(new String(entry.getName()))) { + thisEntry = entry; + break; + } + } + assertNotNull(thisEntry); + signature = thisEntry.getSignature(); + assertNotNull("no signature", signature); + assertEquals("Wrong signature", "LX<TT;>;", new String(signature)); + tEntry = null; + for (int i = 0, max = entries.length; i < max; i++) { + ILocalVariableTypeTableEntry entry = entries[i]; + if ("t".equals(new String(entry.getName()))) { + tEntry = entry; + break; + } + } + assertNotNull(tEntry); + signature = tEntry.getSignature(); + assertNotNull("no signature", signature); + assertEquals("Wrong signature", "TT;", new String(signature)); + } + + public void test002() { + final String[] testsSource = new String[] { + "X.java", + "class X extends p.A<String> {\n" + + " X() {\n" + + " super(null);\n" + + " }\n" + + "}", + "p/A.java", + "package p;\n" + + "public class A<P> {\n" + + " protected A(P p) {\n" + + " }\n" + + "}" + }; + this.runConformTest(testsSource); + + IClassFileReader classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "X.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + IClassFileAttribute classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + ISignatureAttribute signatureAttribute = (ISignatureAttribute) classFileAttribute; + assertEquals("Wrong signature", "Lp/A<Ljava/lang/String;>;", new String(signatureAttribute.getSignature())); + + classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "p/A.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + signatureAttribute = (ISignatureAttribute) classFileAttribute; + char[] signature = signatureAttribute.getSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "<P:Ljava/lang/Object;>Ljava/lang/Object;", new String(signature)); + + IMethodInfo[] methodInfos = classFileReader.getMethodInfos(); + int length = methodInfos.length; + assertEquals("Wrong size", 1, length); + IMethodInfo constructorMethod = methodInfos[0]; + ICodeAttribute codeAttribute = constructorMethod.getCodeAttribute(); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(codeAttribute, IAttributeNamesConstants.LOCAL_VARIABLE_TYPE_TABLE); + assertNotNull(classFileAttribute); + ILocalVariableTypeTableAttribute localVariableTypeTableAttribute = (ILocalVariableTypeTableAttribute) classFileAttribute; + ILocalVariableTypeTableEntry[] entries = localVariableTypeTableAttribute.getLocalVariableTypeTable(); + ILocalVariableTypeTableEntry thisEntry = null; + for (int i = 0, max = entries.length; i < max; i++) { + ILocalVariableTypeTableEntry entry = entries[i]; + if ("this".equals(new String(entry.getName()))) { + thisEntry = entry; + break; + } + } + assertNotNull(thisEntry); + assertEquals("Wrong signature", "Lp/A<TP;>;", new String(thisEntry.getSignature())); + ILocalVariableTypeTableEntry tEntry = null; + for (int i = 0, max = entries.length; i < max; i++) { + ILocalVariableTypeTableEntry entry = entries[i]; + if ("p".equals(new String(entry.getName()))) { + tEntry = entry; + break; + } + } + assertNotNull(tEntry); + signature = tEntry.getSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "TP;", new String(signature)); + + if (!RunJavac) return; + + // Compare with javac + cleanUp(); + runJavac("test002", testsSource); + + classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "X.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + signatureAttribute = (ISignatureAttribute) classFileAttribute; + assertEquals("Wrong signature", "Lp/A<Ljava/lang/String;>;", new String(signatureAttribute.getSignature())); + + classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "p/A.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + signatureAttribute = (ISignatureAttribute) classFileAttribute; + signature = signatureAttribute.getSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "<P:Ljava/lang/Object;>Ljava/lang/Object;", new String(signature)); + + methodInfos = classFileReader.getMethodInfos(); + length = methodInfos.length; + assertEquals("Wrong size", 1, length); + constructorMethod = methodInfos[0]; + codeAttribute = constructorMethod.getCodeAttribute(); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(codeAttribute, IAttributeNamesConstants.LOCAL_VARIABLE_TYPE_TABLE); + assertNotNull(classFileAttribute); + localVariableTypeTableAttribute = (ILocalVariableTypeTableAttribute) classFileAttribute; + entries = localVariableTypeTableAttribute.getLocalVariableTypeTable(); + thisEntry = null; + for (int i = 0, max = entries.length; i < max; i++) { + ILocalVariableTypeTableEntry entry = entries[i]; + if ("this".equals(new String(entry.getName()))) { + thisEntry = entry; + break; + } + } + assertNotNull(thisEntry); + signature = thisEntry.getSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "Lp/A<TP;>;", new String(signature)); + tEntry = null; + for (int i = 0, max = entries.length; i < max; i++) { + ILocalVariableTypeTableEntry entry = entries[i]; + if ("p".equals(new String(entry.getName()))) { + tEntry = entry; + break; + } + } + assertNotNull(tEntry); + signature = tEntry.getSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "TP;", new String(signature)); + } + + public void test003() { + final String[] testsSource = new String[] { + "X.java", + "public class X <T extends Object & p.B<? super T>> extends p.A<T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " super(t);\n" + + " this.t = t;\n" + + " }\n" + + "}", + "p/A.java", + "package p;\n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p;\n" + + " }\n" + + "}", + "p/B.java", + "package p;\n" + + "public interface B<T> {\n" + + "}" + }; + this.runConformTest(testsSource); + + IClassFileReader classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "X.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + IClassFileAttribute classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + ISignatureAttribute signatureAttribute = (ISignatureAttribute) classFileAttribute; + assertEquals("Wrong signature", "<T:Ljava/lang/Object;:Lp/B<-TT;>;>Lp/A<TT;>;", new String(signatureAttribute.getSignature())); + + if (!RunJavac) return; + + // Compare with javac + cleanUp(); + runJavac("test003", testsSource); + + classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "X.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + signatureAttribute = (ISignatureAttribute) classFileAttribute; + assertEquals("Wrong signature", "<T:Ljava/lang/Object;:Lp/B<-TT;>;>Lp/A<TT;>;", new String(signatureAttribute.getSignature())); + } + + public void test004() { + final String[] testsSource = new String[] { + "X.java", + "public class X <T extends Object & p.B> extends p.A<T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " super(t);\n" + + " this.t = t;\n" + + " }\n" + + "}", + "p/A.java", + "package p;\n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p;\n" + + " }\n" + + "}", + "p/B.java", + "package p;\n" + + "public interface B<T> {\n" + + "}" + }; + this.runConformTest(testsSource); + + IClassFileReader classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "X.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + IClassFileAttribute classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + ISignatureAttribute signatureAttribute = (ISignatureAttribute) classFileAttribute; + assertEquals("Wrong signature", "<T:Ljava/lang/Object;:Lp/B;>Lp/A<TT;>;", new String(signatureAttribute.getSignature())); + + if (!RunJavac) return; + + // Compare with javac + cleanUp(); + runJavac("test004", testsSource); + + classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "X.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + signatureAttribute = (ISignatureAttribute) classFileAttribute; + assertEquals("Wrong signature", "<T:Ljava/lang/Object;:Lp/B;>Lp/A<TT;>;", new String(signatureAttribute.getSignature())); + } + + public void test005() { + final String[] testsSource = new String[] { + "X.java", + "public class X <T extends Object & p.B & p.C> extends p.A<T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " super(t);\n" + + " this.t = t;\n" + + " }\n" + + "}", + "p/A.java", + "package p;\n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p;\n" + + " }\n" + + "}", + "p/B.java", + "package p;\n" + + "public interface B<T> {\n" + + "}", + "p/C.java", + "package p;\n" + + "public interface C<T> {\n" + + "}" + }; + this.runConformTest(testsSource); + + IClassFileReader classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "X.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + IClassFileAttribute classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + ISignatureAttribute signatureAttribute = (ISignatureAttribute) classFileAttribute; + char[] signature = signatureAttribute.getSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "<T:Ljava/lang/Object;:Lp/B;:Lp/C;>Lp/A<TT;>;", new String(signature)); + + if (!RunJavac) return; + + // Compare with javac + cleanUp(); + runJavac("test005", testsSource); + + classFileReader = ToolFactory.createDefaultClassFileReader(OUTPUT_DIR + File.separator + "X.class", IClassFileReader.ALL); + assertNotNull(classFileReader); + classFileAttribute = org.eclipse.jdt.internal.core.util.Util.getAttribute(classFileReader, IAttributeNamesConstants.SIGNATURE); + assertNotNull(classFileAttribute); + signatureAttribute = (ISignatureAttribute) classFileAttribute; + signature = signatureAttribute.getSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "<T:Ljava/lang/Object;:Lp/B;:Lp/C;>Lp/A<TT;>;", new String(signature)); + } + + public void test006() { + final String[] testsSource = new String[] { + "X.java", + "public class X <T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " T foo(T t1) {\n" + + " return t1;\n" + + " }\n" + + " T field;\n" + + " public static void main(String[] args) {\n" + + " System.out.print(\"SUCCESS\");\n" + + " }\n" + + "}", + }; + this.runConformTest( + testsSource, + "SUCCESS"); + + try { + ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "X.class"); + assertEquals("Wrong signature", "<T:Ljava/lang/Object;>Ljava/lang/Object;", new String(classFileReader.getGenericSignature())); + + IBinaryField[] fields = classFileReader.getFields(); + assertNotNull("No fields", fields); + assertEquals("Wrong size", 2, fields.length); + assertEquals("Wrong name", "field", new String(fields[1].getName())); + char[] signature = fields[1].getGenericSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "TT;", new String(signature)); + + IBinaryMethod[] methods = classFileReader.getMethods(); + assertNotNull("No methods", methods); + assertEquals("Wrong size", 3, methods.length); + assertEquals("Wrong name", "foo", new String(methods[1].getSelector())); + signature = methods[1].getGenericSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "(TT;)TT;", new String(signature)); + } catch (ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + } + + public void test007() { + final String[] testsSource = new String[] { + "X.java", + "public class X <T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " T foo(X<T> x1) {\n" + + " return x1.t;\n" + + " }\n" + + " X<T> field;\n" + + " public static void main(String[] args) {\n" + + " System.out.print(\"SUCCESS\");\n" + + " }\n" + + "}", + }; + this.runConformTest( + testsSource, + "SUCCESS"); + + try { + ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "X.class"); + assertEquals("Wrong signature", "<T:Ljava/lang/Object;>Ljava/lang/Object;", new String(classFileReader.getGenericSignature())); + + IBinaryField[] fields = classFileReader.getFields(); + assertNotNull("No fields", fields); + assertEquals("Wrong size", 2, fields.length); + assertEquals("Wrong name", "field", new String(fields[1].getName())); + char[] signature = fields[1].getGenericSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "LX<TT;>;", new String(signature)); + + IBinaryMethod[] methods = classFileReader.getMethods(); + assertNotNull("No methods", methods); + assertEquals("Wrong size", 3, methods.length); + assertEquals("Wrong name", "foo", new String(methods[1].getSelector())); + signature = methods[1].getGenericSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "(LX<TT;>;)TT;", new String(signature)); + } catch (ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + } + + public void test008() { + final String[] testsSource = new String[] { + "X.java", + "public class X <T> {\n" + + " T newInstance() throws IllegalAccessException {\n" + + " return null;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " System.out.print(\"SUCCESS\");\n" + + " }\n" + + "}", + }; + this.runConformTest( + testsSource, + "SUCCESS"); + + try { + ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "X.class"); + IBinaryMethod[] methods = classFileReader.getMethods(); + assertNotNull("No methods", methods); + assertEquals("Wrong size", 3, methods.length); + assertEquals("Wrong name", "newInstance", new String(methods[1].getSelector())); + char[] signature = methods[1].getGenericSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "()TT;", new String(signature)); + } catch (ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + } + + public void test009() { + final String[] testsSource = new String[] { + "X.java", + "public class X<T> {\n" + + "class MX<U> {\n" + + "}\n" + + " \n" + + "public static void main(String[] args) {\n" + + " new X<Thread>().foo(new X<String>().new MX<Thread>());\n" + + "}\n" + + "void foo(X<String>.MX<Thread> mx) {\n" + + " System.out.println(\"SUCCESS\");\n" + + "}\n" + + "}", + }; + this.runConformTest( + testsSource, + "SUCCESS"); + + try { + ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "X.class"); + IBinaryMethod[] methods = classFileReader.getMethods(); + assertNotNull("No methods", methods); + assertEquals("Wrong size", 3, methods.length); + assertEquals("Wrong name", "foo", new String(methods[2].getSelector())); + char[] signature = methods[2].getGenericSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "(LX<Ljava/lang/String;>.MX<Ljava/lang/Thread;>;)V", new String(signature)); + } catch (ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + } + + public void test010() { + final String[] testsSource = new String[] { + "X.java", + "public class X<T> {\n" + + "class MX<U> {\n" + + "}\n" + + " \n" + + "public static void main(String[] args) {\n" + + " new X<Thread>().foo(new X<String>().new MX<Thread>());\n" + + "}\n" + + "void foo(X.MX<Thread> mx) {\n" + + " System.out.println(\"SUCCESS\");\n" + + "}\n" + + "}", + }; + this.runConformTest( + testsSource, + "SUCCESS"); + + try { + ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "X.class"); + IBinaryMethod[] methods = classFileReader.getMethods(); + assertNotNull("No methods", methods); + assertEquals("Wrong size", 3, methods.length); + assertEquals("Wrong name", "foo", new String(methods[2].getSelector())); + char[] signature = methods[2].getGenericSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "(LX$MX<Ljava/lang/Thread;>;)V", new String(signature)); + } catch (ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + } + + public void test011() { + final String[] testsSource = new String[] { + "X.java", + "public class X<T> {\n" + + " class MX<U> {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new X<Thread>().foo(new X<String>().new MX<Thread>());\n" + + " }\n" + + " void foo(X<String>.MX mx) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}", + }; + this.runConformTest( + testsSource, + "SUCCESS"); + + try { + ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "X.class"); + IBinaryMethod[] methods = classFileReader.getMethods(); + assertNotNull("No methods", methods); + assertEquals("Wrong size", 3, methods.length); + assertEquals("Wrong name", "foo", new String(methods[2].getSelector())); + char[] signature = methods[2].getGenericSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "(LX<Ljava/lang/String;>.MX;)V", new String(signature)); + } catch (ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + } + + /* + * Write given source test files in current output sub-directory. + * Use test name for this sub-directory name (ie. test001, test002, etc...) + */ + private void writeFiles(String[] testFiles) { + // Compute and create specific dir + IPath dirFilePath = (IPath) this.dirPath.clone(); + File dir = dirFilePath.toFile(); + if (!dir.exists()) { + dir.mkdirs(); + } + + // For each given test files + for (int i=0, length=testFiles.length; i<length; i++) { + dirFilePath = (IPath) this.dirPath.clone(); + String contents = testFiles[i+1]; + String fileName = testFiles[i++]; + IPath filePath = dirFilePath.append(fileName); + if (fileName.lastIndexOf('/') >= 0) { + dirFilePath = filePath.removeLastSegments(1); + dir = dirFilePath.toFile(); + if (!dir.exists()) { + dir.mkdirs(); + } + } + Util.writeToFile(contents, filePath.toString()); + } + } + + public void test012() { + final String[] testsSource = new String[] { + "X.java", + "public class X<T> {\n" + + " class MX<U> {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new X<Thread>().foo(new X<String>().new MX<Thread>());\n" + + " }\n" + + " void foo(X.MX mx) { // pas de signature\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}", + }; + this.runConformTest( + testsSource, + "SUCCESS"); + + try { + ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "X.class"); + IBinaryMethod[] methods = classFileReader.getMethods(); + assertNotNull("No methods", methods); + assertEquals("Wrong size", 3, methods.length); + assertEquals("Wrong name", "foo", new String(methods[2].getSelector())); + assertNull("Wrong signature", methods[2].getGenericSignature()); + } catch (ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + } + + public void test013() { + final String[] testsSource = new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "\n" + + "public class X<T> {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " public <U> void foo(ArrayList<U> arr) {\n" + + " for (U e : arr) {\n" + + " System.out.println(e);\n" + + " }\n" + + " }\n" + + "}", + }; + this.runConformTest( + testsSource, + "SUCCESS"); + + try { + ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "X.class"); + IBinaryMethod[] methods = classFileReader.getMethods(); + assertNotNull("No methods", methods); + assertEquals("Wrong size", 3, methods.length); + assertEquals("Wrong name", "foo", new String(methods[2].getSelector())); + char[] signature = methods[2].getGenericSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "<U:Ljava/lang/Object;>(Ljava/util/ArrayList<TU;>;)V", new String(signature)); + } catch (ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + } + // 59983 - incorrect signature for List<X> + public void test014() { + final String[] testsSource = new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "import java.util.List;\n" + + "public class X {\n" + + " private List<X> games = new ArrayList<X>();\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}", + }; + this.runConformTest( + testsSource, + "SUCCESS"); + + try { + ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "X.class"); + IBinaryField[] fields = classFileReader.getFields(); + assertNotNull("No fields", fields); + assertEquals("Wrong size", 1, fields.length); + assertEquals("Wrong name", "games", new String(fields[0].getName())); + char[] signature = fields[0].getGenericSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "Ljava/util/List<LX;>;", new String(signature)); + } catch (ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + } + // 65953 - incorrect signature for generic interface + public void test015() { + final String[] testsSource = new String[] { + "X.java", + "public interface X<T> {\n" + + "}", + }; + this.runConformTest( + testsSource, + ""); + + try { + ClassFileReader classFileReader = ClassFileReader.read(OUTPUT_DIR + File.separator + "X.class"); + char[] signature = classFileReader.getGenericSignature(); + assertNotNull("No signature", signature); + assertEquals("Wrong signature", "<T:Ljava/lang/Object;>Ljava/lang/Object;", new String(signature)); + } catch (ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..fe0df0472c --- /dev/null +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java @@ -0,0 +1,5957 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.tests.compiler.regression; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Map; + +import junit.framework.AssertionFailedError; +import junit.framework.Test; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.ToolFactory; +import org.eclipse.jdt.core.tests.runtime.TargetException; +import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; + +public class GenericTypeTest extends AbstractRegressionTest { + + class Logger extends Thread { + StringBuffer buffer; + InputStream inputStream; + String type; + Logger(InputStream inputStream, String type) { + this.inputStream = inputStream; + this.type = type; + this.buffer = new StringBuffer(); + } + + public void run() { + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(this.inputStream)); + String line = null; + while ((line = reader.readLine()) != null) { + this.buffer./*append(this.type).append("->").*/append(line).append("\n"); + } + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + static final String RUN_SUN_JAVAC = System.getProperty("run.javac"); + static boolean runJavac = CompilerOptions.ENABLED.equals(RUN_SUN_JAVAC); + IPath dirPath; + + public GenericTypeTest(String name) { + super(name); + } + + public static Class testClass() { + return GenericTypeTest.class; + } + + /* + * Toggle compiler in mode -1.5 + */ + protected Map getCompilerOptions() { + Map options = super.getCompilerOptions(); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_ReportFinalParameterBound, CompilerOptions.WARNING); + options.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.WARNING); + return options; + } + // Use this static initializer to specify subset for tests + // All specified tests which does not belong to the class are skipped... + static { + // Names of tests to run: can be "testBugXXXX" or "BugXXXX") +// testsNames = new String[] { "Bug51529a", "Bug51529b" }; + // Numbers of tests to run: "test<number>" will be run for each number of this array +// testsNumbers = new int[] { 3, 7, 10, 21 }; + // Range numbers of tests to run: all tests between "test<first>" and "test<last>" will be run for { first, last } +// testsRange = new int[] { 21, 50 }; +// testsRange = new int[] { -1, 50 }; // run all tests with a number less or equals to 50 +// testsRange = new int[] { 10, -1 }; // run all tests with a number greater or equals to 10 + } + public static Test suite() { + if (testsNames != null || testsNumbers!=null || testsRange!=null) { + return new RegressionTestSetup(buildTestSuite(testClass()), highestComplianceLevels()); + } + return setupSuite(testClass()); + } + + /* + * Get short test name (without compliance info) + */ + String shortTestName() { + String fname = getName(); + int idx = fname.indexOf(" - "); + if (idx < 0) { + return fname; + } + return fname.substring(idx+3); + } + + /*###################################### + * Specific method to let tests Sun javac compilation available... + #######################################*/ + /* + * Cleans up the given directory by removing all the files it contains as well + * but leaving the directory. + * @throws TargetException if the target path could not be cleaned up + */ + private void cleanupDirectory(File directory) throws TargetException { + if (!directory.exists()) { + return; + } + String[] fileNames = directory.list(); + for (int i = 0; i < fileNames.length; i++) { + File file = new File(directory, fileNames[i]); + if (file.isDirectory()) { + cleanupDirectory(file); + } else { + if (!file.delete()) { + throw new TargetException("Could not delete file " + file.getPath()); + } + } + } + if (!directory.delete()) { + throw new TargetException("Could not delete directory " + directory.getPath()); + } + } + /* + * Write given source test files in current output sub-directory. + * Use test name for this sub-directory name (ie. test001, test002, etc...) + */ + private IPath writeFiles(String[] testFiles) { + // Compute and create specific dir + IPath outDir = new Path(Util.getOutputDirectory()); + this.dirPath = outDir.append(shortTestName()); + File dir = this.dirPath.toFile(); + if (!dir.exists()) { + dir.mkdirs(); + } + + // For each given test files + IPath dirFilePath = null; + for (int i=0, length=testFiles.length; i<length; i++) { + String contents = testFiles[i+1]; + String fileName = testFiles[i++]; + IPath filePath = this.dirPath.append(fileName); + if (fileName.lastIndexOf('/') >= 0) { + dir = filePath.removeLastSegments(1).toFile(); + if (!dir.exists()) { + dir.mkdirs(); + } + } + if (dirFilePath == null|| (filePath.segmentCount()-1) < dirFilePath.segmentCount()) { + dirFilePath = filePath.removeLastSegments(1); + } + Util.writeToFile(contents, filePath.toString()); + } + return dirFilePath; + } + /* + * Write given source test files in current output sub-directory. + * Use test name for this sub-directory name (ie. test001, test002, etc...) + */ + private void printFiles(String[] testFiles) { + for (int i=0, length=testFiles.length; i<length; i++) { + System.out.println(testFiles[i++]); + System.out.println(testFiles[i]); + } + System.out.println(""); + } + + /* + * Run Sun compilation using javac. + * Use JRE directory to retrieve javac bin directory and current classpath for + * compilation. + * Launch compilation in a thread and verify that it does not take more than 5s + * to perform it. Otherwise abort the process and log in console. + */ + protected void runJavac(String[] testFiles, final String expectedProblemLog) { + try { + // Write files in dir + IPath dirFilePath = writeFiles(testFiles); + + String testName = shortTestName(); + Process process = null; + try { + // Compute classpath + String[] classpath = getDefaultClassPaths(); + StringBuffer cp = new StringBuffer(); + int length = classpath.length; + for (int i = 0; i < length; i++) { + if (classpath[i].indexOf(" ") != -1) { + cp.append("\"" + classpath[i] + "\""); + } else { + cp.append(classpath[i]); + } + if (i<(length-1)) cp.append(";"); + } + // Compute command line + IPath jdkDir = (new Path(Util.getJREDirectory())).removeLastSegments(1); + IPath javacPath = jdkDir.append("bin").append("javac.exe"); + StringBuffer cmdLine = new StringBuffer(javacPath.toString()); + cmdLine.append(" -classpath "); + cmdLine.append(cp); + cmdLine.append(" -source 1.5 -deprecation -Xlint:unchecked "); // enable recommended warnings + if (this.dirPath.equals(dirFilePath)) { + cmdLine.append("*.java"); + } else { + IPath subDirPath = dirFilePath.append("*.java").removeFirstSegments(GenericTypeTest.this.dirPath.segmentCount()); + String subDirName = subDirPath.toString().substring(subDirPath.getDevice().length()); + cmdLine.append(subDirName); + } +// System.out.println(testName+": "+cmdLine.toString()); +// System.out.println(GenericTypeTest.this.dirPath.toFile().getAbsolutePath()); + // Launch process + process = Runtime.getRuntime().exec(cmdLine.toString(), null, GenericTypeTest.this.dirPath.toFile()); + // Log errors + Logger errorLogger = new Logger(process.getErrorStream(), "ERROR"); + + // Log output + Logger outputLogger = new Logger(process.getInputStream(), "OUTPUT"); + + // start the threads to run outputs (standard/error) + errorLogger.start(); + outputLogger.start(); + + // Wait for end of process + int exitValue = process.waitFor(); + + // Compare compilation results + if (expectedProblemLog == null) { + if (exitValue != 0) { + System.out.println("========================================"); + System.out.println(testName+": javac has found error(s) although we're expecting conform result:\n"); + System.out.println(errorLogger.buffer.toString()); + printFiles(testFiles); + } + else if (errorLogger.buffer.length() > 0) { + System.out.println("========================================"); + System.out.println(testName+": javac displays warning(s) although we're expecting conform result:\n"); + System.out.println(errorLogger.buffer.toString()); + printFiles(testFiles); + } + } else if (exitValue == 0) { + if (errorLogger.buffer.length() == 0) { + System.out.println("========================================"); + System.out.println(testName+": javac has found no error/warning although we're expecting negative result:"); + System.out.println(expectedProblemLog); + printFiles(testFiles); + } else if (expectedProblemLog.indexOf("ERROR") >0 ){ + System.out.println("========================================"); + System.out.println(testName+": javac has found warning(s) although we're expecting error(s):"); + System.out.println("javac:"); + System.out.println(errorLogger.buffer.toString()); + System.out.println("eclipse:"); + System.out.println(expectedProblemLog); + printFiles(testFiles); + } else { + // TODO (frederic) compare warnings in each result and verify they are similar... +// System.out.println(testName+": javac has found warnings :"); +// System.out.print(errorLogger.buffer.toString()); +// System.out.println(testName+": we're expecting warning results:"); +// System.out.println(expectedProblemLog); + } + } else if (errorLogger.buffer.length() == 0) { + System.out.println("========================================"); + System.out.println(testName+": javac displays no output although we're expecting negative result:\n"); + System.out.println(expectedProblemLog); + printFiles(testFiles); + } + } catch (IOException ioe) { + System.out.println(testName+": Not possible to launch Sun javac compilation!"); + } catch (InterruptedException e1) { + if (process != null) process.destroy(); + System.out.println(testName+": Sun javac compilation was aborted!"); + } + + // Clean up written file(s) + IPath testDir = new Path(Util.getOutputDirectory()).append(shortTestName()); + cleanupDirectory(testDir.toFile()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /*######################################### + * Override basic runConform and run Negative methods to compile test files + * with Sun compiler (if specified) and compare its results with ours. + ##########################################*/ + /* (non-Javadoc) + * @see org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest#runConformTest(java.lang.String[], java.lang.String) + */ + protected void runConformTest(String[] testFiles, + String expectedSuccessOutputString, String[] classLib, + boolean shouldFlushOutputDirectory, String[] vmArguments, + Map customOptions) { + try { + super.runConformTest(testFiles, expectedSuccessOutputString, + classLib, shouldFlushOutputDirectory, vmArguments, + customOptions); + } catch (AssertionFailedError e) { + throw e; + } finally { + if (runJavac) + runJavac(testFiles, null); + } + } + /* (non-Javadoc) + * Override to compile test files with Sun compiler if specified and compare its results with ours. + * @see org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest#runNegativeTest(java.lang.String[], java.lang.String) + */ + protected void runNegativeTest(String[] testFiles, + String expectedProblemLog, String[] classLib, + boolean shouldFlushOutputDirectory, Map customOptions, + boolean generateOutput) { + try { + super.runNegativeTest(testFiles, expectedProblemLog, classLib, + shouldFlushOutputDirectory, customOptions, generateOutput); + } catch (AssertionFailedError e) { + throw e; + } finally { + if (runJavac) + runJavac(testFiles, expectedProblemLog); + } + } + + public void test001() { + this.runConformTest( + new String[] { + "X.java", + "public class X<Tx1 extends String, Tx2 extends Comparable> extends XS<Tx2> {\n" + + "\n" + + " public static void main(String[] args) {\n" + + " Integer w = new X<String,Integer>().get(new Integer(12));\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "class XS <Txs> {\n" + + " Txs get(Txs t) {\n" + + " return t;\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + + public void test002() { + this.runConformTest( + new String[] { + "X.java", + "public class X<Xp1 extends String, Xp2 extends Comparable> extends XS<Xp2> {\n" + + "\n" + + " public static void main(String[] args) {\n" + + " Integer w = new X<String,Integer>().get(new Integer(12));\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " Xp2 get(Xp2 t){\n" + + " System.out.print(\"{X::get}\");\n" + + " return super.get(t);\n" + + " }\n" + + "}\n" + + "\n" + + "class XS <XSp1> {\n" + + " XSp1 get(XSp1 t) {\n" + + " System.out.print(\"{XS::get}\");\n" + + " return t;\n" + + " }\n" + + "}\n" + }, + "{X::get}{XS::get}SUCCESS"); + } + + // check cannot bind superclass to type variable + public void test003() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <X> extends X {\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <X> extends X {\n" + + " ^\n" + + "Cannot refer to the type parameter X as a supertype\n" + + "----------\n"); + } + + // check cannot bind superinterface to type variable + public void test004() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <X> implements X {\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <X> implements X {\n" + + " ^\n" + + "Cannot refer to the type parameter X as a supertype\n" + + "----------\n"); + } + + // check cannot bind type variable in static context + public void test005() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " \n" + + " T t;\n" + + " static {\n" + + " T s;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " T s;\n" + + " ^\n" + + "Cannot make a static reference to the type parameter T\n" + + "----------\n"); + } + + // check static references to type variables + public void test006() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " \n" + + " T ok1;\n" + + " static {\n" + + " T wrong1;\n" + + " }\n" + + " static void foo(T wrong2) {\n" + + " T wrong3;\n" + + " }\n" + + " class MX extends T {\n" + + " T ok2;\n" + + " }\n" + + " static class SMX extends T {\n" + + " T wrong4;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " T wrong1;\n" + + " ^\n" + + "Cannot make a static reference to the type parameter T\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " static void foo(T wrong2) {\n" + + " ^\n" + + "Cannot make a static reference to the type parameter T\n" + + "----------\n" + + "3. ERROR in X.java (at line 8)\n" + + " T wrong3;\n" + + " ^\n" + + "Cannot make a static reference to the type parameter T\n" + + "----------\n" + + "4. ERROR in X.java (at line 10)\n" + + " class MX extends T {\n" + + " ^\n" + + "Cannot refer to the type parameter T as a supertype\n" + + "----------\n" + + "5. ERROR in X.java (at line 13)\n" + + " static class SMX extends T {\n" + + " ^\n" + + "Cannot refer to the type parameter T as a supertype\n" + + "----------\n" + + "6. ERROR in X.java (at line 14)\n" + + " T wrong4;\n" + + " ^\n" + + "Cannot make a static reference to the type parameter T\n" + + "----------\n"); + } + + // check static references to type variables + public void test007() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " \n" + + " T ok1;\n" + + " static class SMX {\n" + + " T wrong4;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " T wrong4;\n" + + " ^\n" + + "Cannot make a static reference to the type parameter T\n" + + "----------\n"); + } + + // check static references to type variables + public void test008() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " \n" + + " T ok;\n" + + " static T wrong;\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " static T wrong;\n" + + " ^\n" + + "Cannot make a static reference to the type parameter T\n" + + "----------\n"); + } + + // Object cannot be generic + public void test009() { + this.runNegativeTest( + new String[] { + "Object.java", + "package java.lang;\n" + + "public class Object <T> {\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in Object.java (at line 2)\n" + + " public class Object <T> {\n" + + " ^\n" + + "The type java.lang.Object cannot be declared as a generic\n" + + "----------\n"); + } + + public void test010() { + this.runNegativeTest( + new String[] { + "X.java", + "class Foo {} \n" + + "public class X<T extends Object & Comparable<? super T>> {\n" + + " public static void main(String[] args) {\n" + + " new X<Foo>();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " new X<Foo>();\n" + + " ^^^\n" + + "Bound mismatch: The type Foo is not a valid substitute for the bounded parameter <T extends Object & Comparable<? super T>> of the type X<T>\n" + + "----------\n"); + } + + public void test011() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T extends Object & Comparable<? super T>> {\n" + + " public static void main(String[] args) {\n" + + " new X<Foo>();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " new X<Foo>();\n" + + " ^^^\n" + + "Foo cannot be resolved to a type\n" + + "----------\n"); + } + + public void test012() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends String> {\n" + + " T foo(T t) {\n" + + " return t;\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " String s = new X<String>().foo(\"SUCCESS\");\n" + + " System.out.println(s);\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + + public void test013() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends String> {\n" + + " T foo(T t) {\n" + + " return t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>().baz(\"SUCCESS\");\n" + + " }\n" + + " void baz(final T t) {\n" + + " new Object() {\n" + + " void print() {\n" + + " System.out.println(foo(t));\n" + + " }\n" + + " }.print();\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + + public void test014() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T extends Exception> {\n" + + " T foo(T t) throws T {\n" + + " return t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<EX>().baz(new EX());\n" + + " }\n" + + " void baz(final T t) {\n" + + " new Object() {\n" + + " void print() {\n" + + " System.out.println(foo(t));\n" + + " }\n" + + " }.print();\n" + + " }\n" + + "}\n" + + "class EX extends Exception {\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 11)\n" + + " System.out.println(foo(t));\n" + + " ^^^^^^\n" + + "Unhandled exception type T\n" + + "----------\n"); + } + + public void test015() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends Exception> {\n" + + " String foo() throws T {\n" + + " return \"SUCCESS\";\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<EX>().baz(new EX());\n" + + " }\n" + + " void baz(final T t) {\n" + + " new Object() {\n" + + " void print() {\n" + + " try {\n" + + " System.out.println(foo());\n" + + " } catch (T t) {\n" + + " }\n" + + " }\n" + + " }.print();\n" + + " }\n" + + "}\n" + + "class EX extends Exception {\n" + + "}\n", + }, + "SUCCESS"); + } + + public void test016() { + this.runConformTest( + new String[] { + "X.java", + "public class X <E extends Exception> {\n" + + " void foo(E e) throws E {\n" + + " throw e;\n" + + " }\n" + + " void bar(E e) {\n" + + " try {\n" + + " foo(e);\n" + + " } catch(E ex) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<Exception>().bar(new Exception());\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + public void test017() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.io.IOException;\n" + + "public class X <E extends Exception> {\n" + + " void foo(E e) throws E {\n" + + " throw e;\n" + + " }\n" + + " void bar(E e) {\n" + + " try {\n" + + " foo(e);\n" + + " } catch(E ex) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<IOException>().bar(new Exception());\n" + + " }\n" + + "}\n" , + }, + "----------\n" + + "1. ERROR in X.java (at line 14)\n" + + " new X<IOException>().bar(new Exception());\n" + + " ^^^\n" + + "The method bar(IOException) in the type X<IOException> is not applicable for the arguments (Exception)\n" + + "----------\n"); + } + public void test018() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " T foo(T t) {\n" + + " System.out.println(t);\n" + + " return t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<XY>() {\n" + + " void run() {\n" + + " foo(new XY());\n" + + " }\n" + + " }.run();\n" + + " }\n" + + "}\n" + + "class XY {\n" + + " public String toString() {\n" + + " return \"SUCCESS\";\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + public void test019() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " private T foo(T t) {\n" + + " System.out.println(t);\n" + + " return t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<XY>() {\n" + + " void run() {\n" + + " foo(new XY());\n" + + " }\n" + + " }.run();\n" + + " }\n" + + "}\n" + + "class XY {\n" + + " public String toString() {\n" + + " return \"SUCCESS\";\n" + + " }\n" + + "}", + }, + // TODO (philippe) should eliminate 1st diagnosis, as foo is still used even if incorrectly + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " private T foo(T t) {\n" + + " ^^^^^^^^\n" + + "The private method foo(T) from the type X<T> is never used locally\n" + + "----------\n" + + "2. ERROR in X.java (at line 9)\n" + + " foo(new XY());\n" + + " ^^^\n" + + "The method foo(T) in the type X<T> is not applicable for the arguments (XY)\n" + + "----------\n"); + } + public void test020() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " void foo(Y<T> y) {\n" + + " System.out.print(\"SUCC\");\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>().bar();\n" + + " }\n" + + " void bar() {\n" + + " new Y<T>() {\n" + + " public void pre() {\n" + + " foo(this);\n" + + " }\n" + + " }.print(\"ESS\");\n" + + " }\n" + + "}\n" + + "class Y <P> {\n" + + " public void print(P p) {\n" + + " pre();\n" + + " System.out.println(p);\n" + + " }\n" + + " public void pre() {\n" + + " }\n" + + "}", + }, + "----------\n" + + "1. ERROR in X.java (at line 13)\n" + + " }.print(\"ESS\");\n" + + " ^^^^^\n" + + "The method print(T) in the type Y<T> is not applicable for the arguments (String)\n" + + "----------\n"); + } + public void test021() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T extends String> {\n" + + " void foo(T t) {\n" + + " }\n" + + " void bar(String x) {\n" + + " foo(x);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>().foo(new Object());\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 1)\n" + + " public class X <T extends String> {\n" + + " ^^^^^^\n" + + "The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "2. ERROR in X.java (at line 5)\n" + + " foo(x);\n" + + " ^^^\n" + + "The method foo(T) in the type X<T> is not applicable for the arguments (String)\n" + + "----------\n" + + "3. ERROR in X.java (at line 8)\n" + + " new X<String>().foo(new Object());\n" + + " ^^^\n" + + "The method foo(String) in the type X<String> is not applicable for the arguments (Object)\n" + + "----------\n"); + } + + public void test022() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends String> {\n" + + " X(T t) {\n" + + " System.out.println(t);\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " new X<String>(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + + public void test023() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends String> {\n" + + " X(final T t) {\n" + + " new Object() {\n" + + " void print() {\n" + + " System.out.println(t);\n" + + " }\n" + + " }.print();\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + + public void test024() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T extends Exception> {\n" + + " X(final T t) throws T {\n" + + " new Object() {\n" + + " void print() {\n" + + " System.out.println(t);\n" + + " }\n" + + " }.print();\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<EX>(new EX());\n" + + " }\n" + + "}\n" + + "class EX extends Exception {\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 10)\n" + + " new X<EX>(new EX());\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "Unhandled exception type EX\n" + + "----------\n"); + } + + public void test025() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends Exception> {\n" + + " String foo() throws T {\n" + + " return \"SUCCESS\";\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<EX>(new EX());\n" + + " }\n" + + " X(final T t) {\n" + + " new Object() {\n" + + " void print() {\n" + + " try {\n" + + " System.out.println(foo());\n" + + " } catch (T t) {\n" + + " }\n" + + " }\n" + + " }.print();\n" + + " }\n" + + "}\n" + + "class EX extends Exception {\n" + + "}\n", + }, + "SUCCESS"); + } + + public void test026() { + this.runConformTest( + new String[] { + "X.java", + "public class X <E extends Exception> {\n" + + " void foo(E e) throws E {\n" + + " throw e;\n" + + " }\n" + + " X(E e) {\n" + + " try {\n" + + " foo(e);\n" + + " } catch(E ex) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<Exception>(new Exception());\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + public void test027() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.io.IOException;\n" + + "public class X <E extends Exception> {\n" + + " void foo(E e) throws E {\n" + + " throw e;\n" + + " }\n" + + " X(E e) {\n" + + " try {\n" + + " foo(e);\n" + + " } catch(E ex) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<IOException>(new Exception());\n" + + " }\n" + + "}\n" , + }, + "----------\n" + + "1. ERROR in X.java (at line 14)\n" + + " new X<IOException>(new Exception());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "The constructor X<IOException>(Exception) is undefined\n" + + "----------\n"); + } + + public void test028() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " String s = new X<String>(\"SU\").t;\n" + + " System.out.print(s);\n" + + " s = new X<String>(\"failed\").t = \"CC\";\n" + + " System.out.print(s);\n" + + " s = new X<String>(\"\").t += \"ESS\";\n" + + " System.out.println(s);\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + + public void test029() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " T t;\n" + + " X() {\n" + + " }\n" + + " T foo(T a, T b) {\n" + + " T s;\n" + + " s = t = a;\n" + + " s = t += b;\n" + + " return t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " System.out.println(new X<String>().foo(\"SUC\", \"CESS\"));\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " s = t += b;\n" + + " ^^^^^^\n" + + "The operator += is undefined for the argument type(s) T, T\n" + + "----------\n"); + } + + public void test030() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " T t;\n" + + " X() {\n" + + " }\n" + + " T foo(T a) {\n" + + " T s;\n" + + " s = t = a;\n" + + " return t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " System.out.println(new X<String>().foo(\"SUCCESS\"));\n" + + " }\n" + + "}\n" , + }, + "SUCCESS"); + } + + public void test031() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>(\"OUTER\").bar();\n" + + " }\n" + + " void bar() {\n" + + " new X<String>(\"INNER\") {\n" + + " void run() {\n" + + " \n" + + " new Object() {\n" + + " void run() {\n" + + " String s = t = \"SUC\";\n" + + " s = t+= \"CESS\";\n" + + " System.out.println(t);\n" + + " }\n" + + " }.run();\n" + + " }\n" + + " }.run();\n" + + " }\n" + + "}\n" , + }, + "SUCCESS"); + } + + public void test032() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>(\"OUTER\").bar();\n" + + " }\n" + + " void bar() {\n" + + " new X<String>(\"INNER\") {\n" + + " void run() {\n" + + " String s = t = \"SUC\";\n" + + " s = t+= \"CESS\";\n" + + " System.out.println(t);\n" + + " }\n" + + " }.run();\n" + + " }\n" + + "}\n" , + }, + "SUCCESS"); + } + + public void test033() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <E, T> {\n" + + " void foo(E e){}\n" + + " void foo(T t){}\n" + + "}\n" , + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(E e){}\n" + + " ^^^^^^^^\n" + + "Method foo(E) has the same erasure foo(Object) as another method in type X<E,T>\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " void foo(T t){}\n" + + " ^^^^^^^^\n" + + "Method foo(T) has the same erasure foo(Object) as another method in type X<E,T>\n" + + "----------\n"); + } + + public void test034() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <E extends Exception, T extends Exception> {\n" + + " void foo(E e){}\n" + + " void foo(T t){}\n" + + "}\n" , + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(E e){}\n" + + " ^^^^^^^^\n" + + "Method foo(E) has the same erasure foo(Exception) as another method in type X<E,T>\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " void foo(T t){}\n" + + " ^^^^^^^^\n" + + "Method foo(T) has the same erasure foo(Exception) as another method in type X<E,T>\n" + + "----------\n"); + } + + public void test035() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <E extends Exception, T extends Thread> {\n" + + " void foo(E e, Thread t){}\n" + + " void foo(Exception e, T t){}\n" + + "}\n" , + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(E e, Thread t){}\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "Method foo(E, Thread) has the same erasure foo(Exception, Thread) as another method in type X<E,T>\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " void foo(Exception e, T t){}\n" + + " ^^^^^^^^^^^^^^^^^^^^^\n" + + "Method foo(Exception, T) has the same erasure foo(Exception, Thread) as another method in type X<E,T>\n" + + "----------\n"); + } + + public void test036() { + this.runConformTest( + new String[] { + "X.java", + "public class X <E extends Exception, T extends Thread> {\n" + + " void foo(E e){}\n" + + " void foo(T t){}\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" , + }, + "SUCCESS"); + } + + public void test037() { + this.runConformTest( + new String[] { + "X.java", + "public class X <E extends Cloneable, T extends Thread & Cloneable> {\n" + + " void foo(E e){}\n" + + " void foo(T t){}\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" , + }, + "SUCCESS"); + } + + public void test038() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <E extends Cloneable, T extends Thread & Cloneable> {\n" + + " void foo(E e){}\n" + + " void foo(T t){}\n" + + " public static void main(String[] args) {\n" + + " X<XY,XY> x = new X<XY, XY>();\n" + + " x.foo(new XY());\n" + + " }\n" + + "}\n" + + "class XY extends Thread implements Cloneable {\n" + + "}\n" , + }, "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " x.foo(new XY());\n" + + " ^^^\n" + + "The method foo(XY) is ambiguous for the type X<XY,XY>\n" + + "----------\n"); + } + + public void test039() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <E extends Cloneable, T extends Thread> {\n" + + " void foo(L<E> l1){}\n" + + " void foo(L<T> l2){}\n" + + " void foo(L l){}\n" + + "}\n" + + "\n" + + "class L<E> {\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(L<E> l1){}\n" + + " ^^^^^^^^^^^^\n" + + "Method foo(L<E>) has the same erasure foo(L<E>) as another method in type X<E,T>\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " void foo(L<T> l2){}\n" + + " ^^^^^^^^^^^^\n" + + "Method foo(L<T>) has the same erasure foo(L<E>) as another method in type X<E,T>\n" + + "----------\n" + + "3. ERROR in X.java (at line 4)\n" + + " void foo(L l){}\n" + + " ^^^^^^^^\n" + + "Duplicate method foo(L) in type X<E,T>\n" + + "----------\n"); + } + + public void test040() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends X> {\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " } \n" + + "}\n", + }, + "SUCCESS"); + } + + public void test041() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T, U extends T> {\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " } \n" + + "}\n", + }, + "SUCCESS"); + } + + public void test042() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T extends U, U> {\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T extends U, U> {\n" + + " ^\n" + + "Illegal forward reference to type parameter U\n" + + "----------\n"); + } + + public void test043() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends L<T> , U extends T> {\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "class L<E>{}\n", + }, + "SUCCESS"); + } + + public void test044() { + this.runConformTest( + new String[] { + "X.java", + "public class X extends L<X> {\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " } \n" + + "}\n" + + "class L<E> {}\n", + }, + "SUCCESS"); + } + + public void test045() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public Z<T> var;\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public Z<T> var;\n" + + " ^\n" + + "Z cannot be resolved to a type\n" + + "----------\n"); + } + public void test046() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public Object<T> var;\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public Object<T> var;\n" + + " ^\n" + + "T cannot be resolved to a type\n" + + "----------\n"); + } + public void test047() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " private T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>(\"OUTER\").bar();\n" + + " }\n" + + " void bar() {\n" + + " new MX<String>(\"INNER\") {\n" + + " void run() {\n" + + " \n" + + " new Object() {\n" + + " void run() {\n" + + " String s = t = \"SUC\";\n" + + " s = t+= \"CESS\";\n" + + " System.out.println(t);\n" + + " }\n" + + " }.run();\n" + + " }\n" + + " }.run();\n" + + " }\n" + + "}\n" + + "class MX<U> {\n" + + " MX(U u){}\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 15)\n" + + " String s = t = \"SUC\";\n" + + " ^\n" + + "Type mismatch: cannot convert from T to String\n" + + "----------\n" + + "2. ERROR in X.java (at line 15)\n" + + " String s = t = \"SUC\";\n" + + " ^^^^^\n" + + "Type mismatch: cannot convert from String to T\n" + + "----------\n" + + "3. ERROR in X.java (at line 16)\n" + + " s = t+= \"CESS\";\n" + + " ^^^^^^^^^^\n" + + "The operator += is undefined for the argument type(s) T, String\n" + + "----------\n"); + } + // Access to enclosing 't' of type 'T' (not substituted from X<X> as private thus non inherited) + // javac finds no error/warning on this test but it should + public void test048() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " private T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>(\"OUTER\").bar();\n" + + " }\n" + + " void bar() {\n" + + " new X<X>(this) {\n" + + " void run() {\n" + + " new Object() {\n" + + " void run() {\n" + + " X x = t;\n" + + " System.out.println(x);\n" + + " }\n" + + " }.run();\n" + + " }\n" + + " }.run();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 14)\n" + + " X x = t;\n" + + " ^\n" + + "Type mismatch: cannot convert from T to X\n" + + "----------\n"); + } + public void test049() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " public T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>(\"OUTER\").bar();\n" + + " }\n" + + " void bar() {\n" + + " new X<X>(this) {\n" + + " void run() {\n" + + " new Object() {\n" + + " void run() {\n" + + " X x = t;\n" + + " System.out.println(\"SUCCESS:\"+x);\n" + + " }\n" + + " }.run();\n" + + " }\n" + + " }.run();\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + public void test050() { + this.runNegativeTest( + new String[] { + "X.java", + "class Super {class M {}}\n" + + "public class X <T extends M> extends Super {\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " public class X <T extends M> extends Super {\n" + + " ^\n" + + "M cannot be resolved to a type\n" + + "----------\n"); + } + public void test051() { + this.runConformTest( + new String[] { + "X.java", + "class Super {class M {}}\n" + + "public class X extends Super {\n" + + " class N <T extends M> {}\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS:\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + public void test052() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> extends p.A<T> {\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS:\");\n" + + " }\n" + + "}\n", + "p/A.java", + "package p; \n" + + "public class A<P> {\n" + + "}\n", + }, + "SUCCESS"); + } + public void test053() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> extends p.A<T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>(\"OUTER\").bar();\n" + + " }\n" + + " void bar() {\n" + + " new X<X>(this) {\n" + + " void run() {\n" + + " new Object() {\n" + + " void run() {\n" + + " print(t);\n" + + " }\n" + + " }.run();\n" + + " }\n" + + " }.run();\n" + + " }\n" + + "}\n", + "p/A.java", + "package p; \n" + + "public class A<P> {\n" + + " protected void print(P p) {\n" + + " System.out.println(\"SUCCESS\"+p);\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + public void test054() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> extends p.A<T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>(\"OUTER\").bar();\n" + + " }\n" + + " void bar() {\n" + + " new X<X>(this) {\n" + + " void run() {\n" + + " new Object() {\n" + + " void run() {\n" + + " print(X.this.t);\n" + + " }\n" + + " }.run();\n" + + " }\n" + + " }.run();\n" + + " }\n" + + "}\n", + "p/A.java", + "package p; \n" + + "public class A<P> {\n" + + " protected void print(P p) {\n" + + " System.out.println(\"SUCCESS\"+p);\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 14)\n" + + " print(X.this.t);\n" + + " ^^^^^\n" + + "The method print(X) in the type A<X> is not applicable for the arguments (T)\n" + + "----------\n"); + } + + public void test055() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> extends p.A<T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " super(t);\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X<String> xs = new X<String>(\"SUCCESS\");\n" + + " System.out.println(xs.t);\n" + + " }\n" + + "}\n", + "p/A.java", + "package p; \n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p; \n" + + " } \n" + + " protected void print(P p) {\n" + + " System.out.println(\"SUCCESS\"+p);\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + + public void test056() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> extends p.A<T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " super(t);\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X<String> xs = new X<String>(\"SUCCESS\");\n" + + " System.out.println((X)xs.t);\n" + + " }\n" + + "}\n", + "p/A.java", + "package p; \n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p; \n" + + " } \n" + + " protected void print(P p) {\n" + + " System.out.println(\"SUCCESS\"+p);\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " System.out.println((X)xs.t);\n" + + " ^^^^^^^\n" + + "Cannot cast from String to X\n" + + "----------\n" + + "----------\n" + + "1. WARNING in p\\A.java (at line 7)\n" + + " protected void print(P p) {\n" + + " ^\n" + + "The parameter p is hiding a field from type A<P>\n" + + "----------\n"); + } + + public void test057() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> extends p.A<T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " super(t);\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X<X<String>> xs = new X<X<String>>(new X<String>(\"SUCCESS\"));\n" + + " System.out.println(xs.t.t);\n" + + " }\n" + + "}\n", + "p/A.java", + "package p; \n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p; \n" + + " } \n" + + " protected void print(P p) {\n" + + " System.out.println(\"SUCCESS\"+p);\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + + // JSR14-v10[§2.1,§2.2]: Valid multiple parameter types + public void test058() { + this.runConformTest( + new String[] { + "test/X.java", + "package test;\n" + + "// Valid Parameterized Type Declaration\n" + + "public class X<A1, A2, A3> {\n" + + "}\n" + + "// Valid Type Syntax\n" + + "class Y {\n" + + " X<String, Number, Integer> x;\n" + + "}\n" + } + ); + } + // JSR14-v10[§2.1,§2.2]: Invalid multiple parameter types: more declared than referenced + public void test059() { + this.runNegativeTest( + new String[] { + "test/X.java", + "package test;\n" + + "// Valid Parameterized Type Declaration\n" + + "public class X<A1, A2, A3, A4> {\n" + + "}\n" + + "// Invalid Valid Type Syntax (not enough parameters)\n" + + "class Y {\n" + + " X<String, Number, Integer> x;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in test\\X.java (at line 7)\n" + + " X<String, Number, Integer> x;\n" + + " ^\n" + + "Incorrect number of arguments for type X<A1,A2,A3,A4>; it cannot be parameterized with arguments <String, Number, Integer>\n" + + "----------\n" + ); + } + // JSR14-v10[§2.1,§2.2]: Invalid multiple parameter types: more referenced than declared + public void test060() { + this.runNegativeTest( + new String[] { + "test/X.java", + "package test;\n" + + "// Valid Parameterized Type Declaration\n" + + "public class X<A1, A2> {\n" + + "}\n" + + "// Invalid Valid Type Syntax (too many parameters)\n" + + "class Y {\n" + + " X<String, Number, Integer> x;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in test\\X.java (at line 7)\n" + + " X<String, Number, Integer> x;\n" + + " ^\n" + + "Incorrect number of arguments for type X<A1,A2>; it cannot be parameterized with arguments <String, Number, Integer>\n" + + "----------\n" + ); + } + // JSR14-v10[§2.1,§2.2]: Invalid multiple parameter types: primitive types + public void test061() { + this.runNegativeTest( + new String[] { + "test/X.java", + "package test;\n" + + "// Valid Parameterized Type Declaration\n" + + "public class X<A1, A2, A3, A4, A5, A6, A7> {\n" + + "}\n" + + "// Invalid Valid Type Syntax (primitive cannot be parameters)\n" + + "class Y {\n" + + " X<int, short, long, float, double, boolean, char> x;\n" + + "}\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" + ); + } + // JSR14-v10[§2.1,§2.2]: Valid multiple parameter types: primitive type arrays + public void test062() { + this.runConformTest( + new String[] { + "test/X.java", + "package test;\n" + + "// Valid Parameterized Type Declaration\n" + + "public class X<A1, A2, A3, A4, A5, A6, A7, A8> {\n" + + "}\n" + + "// Valid Type Syntax\n" + + "class Y {\n" + + " X<int[], short[][], long[][][], float[][][][], double[][][][][], boolean[][][][][][], char[][][][][][][], Object[][][][][][][][][]> x;\n" + + "}\n" + }, + "" + ); + } + public void test063() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T> extends p.A<T> {\n" + + " \n" + + " X(T t) {\n" + + " super(t);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X x = new X(args);\n" + + " X<String> xs = new X<String>(args);\n" + + " }\n" + + "}\n", + "p/A.java", + "package p; \n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p; \n" + + " } \n" + + " protected void print(P p) {\n" + + " System.out.println(\"SUCCESS\"+p);\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 7)\n" + + " X x = new X(args);\n" + + " ^^^^^^^^^^^\n" + + "Unsafe type operation: Should not invoke the constructor X(T) of raw type X. References to generic type X<T> should be parameterized\n" + + "----------\n" + + "2. ERROR in X.java (at line 8)\n" + + " X<String> xs = new X<String>(args);\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "The constructor X<String>(String[]) is undefined\n" + + "----------\n" + + "----------\n" + + "1. WARNING in p\\A.java (at line 7)\n" + + " protected void print(P p) {\n" + + " ^\n" + + "The parameter p is hiding a field from type A<P>\n" + + "----------\n"); + } + // raw type: variable map to its strict erasure + public void test064() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T extends Exception & IX> {\n" + + " T t;\n" + + " void bar(T t) {\n" + + " t.getMessage();\n" + + " t.foo();\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X x = new X();\n" + // raw type + " x.t.getMessage();\n" + // T is strictly exception ! + " x.t.foo();\n" + + " }\n" + + "}\n" + + "\n" + + "interface IX {\n" + + " void foo();\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " void bar(T t) {\n" + + " ^\n" + + "The parameter t is hiding a field from type X<T>\n" + + "----------\n" + + "2. ERROR in X.java (at line 10)\n" + + " x.t.foo();\n" + + " ^^^\n" + + "The method foo() is undefined for the type Exception\n" + + "----------\n"); + } + // raw type: assignments + public void test065() { + Map customOptions = getCompilerOptions(); + this.runNegativeTest( + new String[] { + "X.java", + "import java.io.IOException;\n" + + "\n" + + "public class X<T extends Exception> {\n" + + "\n" + + " public static void main(String[] args) {\n" + + " X x = new X();\n" + + " X<IOException> xioe = new X<IOException>(); // ok\n" + + " \n" + + " X x2 = xioe;\n" + + " X<IOException> xioe2 = x; // unsafe\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 10)\n" + + " X<IOException> xioe2 = x; // unsafe\n" + + " ^\n" + + "Unsafe type operation: Should not assign expression of raw type X to type X<IOException>. References to generic type X<T> should be parameterized\n" + + "----------\n", + null, + true, + customOptions); + } + + // JSR14-v10[§2.1,§2.2]: Invalid PT declaration (mix with reference) + public void test066() { + this.runNegativeTest( + new String[] { + "test/X1.java", + "package test;\n" + + "// Valid Consecutive Parameterized Type Declaration\n" + + "public class X1<A1 extends X2<A2>> {\n" + + " A1 a1;\n" + + "}\n" + + "// Valid Parameterized Type Declaration\n" + + "class X2<A2>{\n" + + " A2 a2;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in test\\X1.java (at line 3)\n" + + " public class X1<A1 extends X2<A2>> {\n" + + " ^^\n" + + "A2 cannot be resolved to a type\n" + + "----------\n" + ); + } + + // JSR14-v10[§2.1,§2.2]: Invalid PT declaration (mix with reference) + public void test067() { + this.runNegativeTest( + new String[] { + "test/X1.java", + "package test;\n" + + "// Valid Consecutive Parameterized Type Declaration\n" + + "public class X1< A1 extends X2 < A2 > > {\n" + + " A1 a1;\n" + + "}\n" + + "// Valid Parameterized Type Declaration\n" + + "class X2<A2>{\n" + + " A2 a2;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in test\\X1.java (at line 3)\n" + + " public class X1< A1 extends X2 < A2 > > {\n" + + " ^^\n" + + "A2 cannot be resolved to a type\n" + + "----------\n" + ); + } + + // JSR14-V10[§2.4]: Not terminated consecutive declaration + // TODO (david) diagnosis message on error 3 sounds strange, doesn't it? + public void test068() { + this.runNegativeTest( + new String[] { + "test/X1.java", + "package test;\n" + + "// Invalid Consecutive Parameterized Type Declaration\n" + + "public class X1<A1 extends X2<A2> {\n" + + " A1 a1;\n" + + "}\n" + + "// Invalid Parameterized Type Declaration\n" + + "class X2<A2 {\n" + + " A2 a2;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in test\\X1.java (at line 3)\n" + + " public class X1<A1 extends X2<A2> {\n" + + " ^^\n" + + "A2 cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in test\\X1.java (at line 3)\n" + + " public class X1<A1 extends X2<A2> {\n" + + " ^\n" + + "Syntax error, insert \">\" to complete ReferenceType1\n" + + "----------\n" + + "3. ERROR in test\\X1.java (at line 3)\n" + + " public class X1<A1 extends X2<A2> {\n" + + " ^\n" + + "Syntax error, insert \"Dimensions\" to complete ArrayType\n" + + "----------\n" + + "4. ERROR in test\\X1.java (at line 7)\n" + + " class X2<A2 {\n" + + " ^^\n" + + "Syntax error on token \"A2\", > expected after this token\n" + + "----------\n" + ); + } + + // JSR14-V10[§2.4]: Not terminated consecutive declaration + public void test069() { + this.runNegativeTest( + new String[] { + "test/X1.java", + "package test;\n" + + "// Invalid Consecutive Parameterized Type Declaration\n" + + "public class X1<A1 extends X2<A2 {\n" + + " A1 a1;\n" + + "}\n" + + "// Invalid Parameterized Type Declaration\n" + + "class X2<A2> {\n" + + " A2 a2;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in test\\X1.java (at line 3)\n" + + " public class X1<A1 extends X2<A2 {\n" + + " ^^\n" + + "Syntax error, insert \">>\" to complete ReferenceType2\n" + + "----------\n" + ); + } + + // JSR14-v10[§2.4]: Unexpected consecutive PT declaration (right-shift symbol) + // TODO (david) surround expected token with (double-)quotes + public void test070() { + this.runNegativeTest( + new String[] { + "test/X1.java", + "package test;\n" + + "// Invalid Consecutive Parameterized Type Declaration\n" + + "public class X1<A1>> {\n" + + " A1 a1;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in test\\X1.java (at line 3)\n" + + " public class X1<A1>> {\n" + + " ^^\n" + + "Syntax error on token \">>\", > expected\n" + + "----------\n" + ); + } + + // JSR14-v10[§2.1,§2.2]: Unexpected consecutive PT declaration (with spaces) + public void test071() { + this.runNegativeTest( + new String[] { + "test/X1.java", + "package test;\n" + + "// Invalid Consecutive Parameterized Type Declaration\n" + + "public class X1 < A1 > > {\n" + + " A1 a1;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in test\\X1.java (at line 3)\n" + + " public class X1 < A1 > > {\n" + + " ^\n" + + "Syntax error on token \">\", delete this token\n" + + "----------\n" + ); + } + + // JSR14-v10[§2.4]: Unexpected consecutive PT declaration (unary right-shift symbol) + // TODO (david) surround expected token with (double-)quotes + public void test072() { + this.runNegativeTest( + new String[] { + "test/X1.java", + "package test;\n" + + "// Invalid Consecutive Parameterized Type Declaration\n" + + "public class X1<A1>>> {\n" + + " A1 a1;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in test\\X1.java (at line 3)\n" + + " public class X1<A1>>> {\n" + + " ^^^\n" + + "Syntax error on token \">>>\", > expected\n" + + "----------\n" + ); + } + + // JSR14-v10[§2.4]: Unexpected consecutive PT declaration (right-shift symbol) + // TODO (david) surround expected token with (double-)quotes + public void test073() { + this.runNegativeTest( + new String[] { + "test/X1.java", + "package test;\n" + + "// Invalid Consecutive Parameterized Type Declaration\n" + + "public class X1<A1 extends X2<A1>>> {\n" + + " A1 a1;\n" + + "}\n" + + "// Valid Parameterized Type Declaration\n" + + "class X2<A2> {\n" + + " A2 a2;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in test\\X1.java (at line 3)\n" + + " public class X1<A1 extends X2<A1>>> {\n" + + " ^^^\n" + + "Syntax error on token \">>>\", >> expected\n" + + "----------\n" + ); + } + + // JSR14-v10[§2.1,§2.2]: Unexpected consecutive PT declaration (with spaces) + public void test074() { + this.runNegativeTest( + new String[] { + "test/X1.java", + "package test;\n" + + "// Invalid Consecutive Parameterized Type Declaration\n" + + "public class X1 < A1 > > > {\n" + + " A1 a1;\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in test\\X1.java (at line 3)\n" + + " public class X1 < A1 > > > {\n" + + " ^^^\n" + + "Syntax error on tokens, delete these tokens\n" + + "----------\n" + ); + } + + // A is not an interface + public void test075() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T extends Object & p.A<? super T>> extends p.A<T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " super(t);\n" + + " this.t = t;\n" + + " }\n" + + "}", + "p/A.java", + "package p;\n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p;\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T extends Object & p.A<? super T>> extends p.A<T> {\n" + + " ^^^\n" + + "The type A<? super T> is not an interface; it cannot be specified as a bounded parameter\n" + + "----------\n" + ); + } + + // A is not an interface + public void test076() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T extends Object & p.A> extends p.A<T> {\n" + + " protected T t;\n" + + " X(T t) {\n" + + " super(t);\n" + + " this.t = t;\n" + + " }\n" + + "}", + "p/A.java", + "package p;\n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p;\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X <T extends Object & p.A> extends p.A<T> {\n" + + " ^^^\n" + + "The type A is not an interface; it cannot be specified as a bounded parameter\n" + + "----------\n" + ); + } + // unsafe type operation: only for constructors with signature change + public void test077() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T> extends p.A<T> {\n" + + " X() {\n" + + " super(null);\n" + + " }\n"+ + " X(T t) {\n" + + " super(t);\n" + + " }\n" + + " X(X<T> xt) {\n" + + " super(xt.t);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X x = new X();\n" + + " X x1 = new X(args);\n" + + " X x2 = new X(x);\n" + + " X<String> xs = new X<String>(args);\n" + + " }\n" + + "}\n", + "p/A.java", + "package p;\n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p;\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " super(xt.t);\n" + + " ^^^^\n" + + "xt.t cannot be resolved or is not a field\n" + + "----------\n" + + "2. WARNING in X.java (at line 13)\n" + + " X x1 = new X(args);\n" + + " ^^^^^^^^^^^\n" + + "Unsafe type operation: Should not invoke the constructor X(T) of raw type X. References to generic type X<T> should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 14)\n" + + " X x2 = new X(x);\n" + + " ^^^^^^^^\n" + + "Unsafe type operation: Should not invoke the constructor X(X<T>) of raw type X. References to generic type X<T> should be parameterized\n" + + "----------\n" + + "4. ERROR in X.java (at line 15)\n" + + " X<String> xs = new X<String>(args);\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "The constructor X<String>(String[]) is undefined\n" + + "----------\n"); + } + public void test078() { + this.runNegativeTest( + new String[] { + "X.java", + "import p.A;\n" + + "public class X {\n" + + " X(A<String> a, A<String> b) {\n" + + " }\n" + + " void foo(A<String> a) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X x = new X((A)null, (A)null);\n" + + " A a = new A((A)null);\n" + + " x.foo(a);\n" + + " a.print(x);\n" + + " A<String> as = new A<String>(null);\n" + + " as.print(\"hello\");\n" + + " }\n" + + "}\n", + "p/A.java", + "package p;\n" + + "public class A<P> {\n" + + " protected P p;\n" + + " protected A(P p) {\n" + + " this.p = p;\n" + + " }\n" + + " protected void print(P p) {\n" + + " System.out.println(\"SUCCESS\"+p);\n" + + " }\n" + + " protected void print(A<P> a) {\n" + + " print(a.p);\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 8)\n" + + " X x = new X((A)null, (A)null);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Unsafe type operation: The constructor X(A<String>, A<String>) should not be applied for the arguments (A, A). References to generic types should be parameterized\n" + + "----------\n" + + "2. ERROR in X.java (at line 9)\n" + + " A a = new A((A)null);\n" + + " ^^^^^^^^^^^^^^\n" + + "The constructor A(P) is not visible\n" + + "----------\n" + + "3. WARNING in X.java (at line 10)\n" + + " x.foo(a);\n" + + " ^^^^^^^^\n" + + "Unsafe type operation: The method foo(A<String>) in the type X should not be applied for the arguments (A). References to generic types should be parameterized\n" + + "----------\n" + + "4. ERROR in X.java (at line 11)\n" + + " a.print(x);\n" + + " ^^^^^\n" + + "The method print(P) from the type A is not visible\n" + + "----------\n" + + "5. ERROR in X.java (at line 12)\n" + + " A<String> as = new A<String>(null);\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "The constructor A<String>(P) is not visible\n" + + "----------\n" + + "6. ERROR in X.java (at line 13)\n" + + " as.print(\"hello\");\n" + + " ^^^^^\n" + + "The method print(P) from the type A<String> is not visible\n" + + "----------\n" + + "----------\n" + + "1. WARNING in p\\A.java (at line 7)\n" + + " protected void print(P p) {\n" + + " ^\n" + + "The parameter p is hiding a field from type A<P>\n" + + "----------\n"); + } + + // JSR14-v10[§2.4]: Valid consecutive Type Parameters Brackets + public void test079() { + this.runConformTest( + new String[] { + "test/X.java", + "package test;\n" + + "public class X<A extends X1<X2<X3<String>>>> {\n" + + " A a;\n" + + " public static void main(String[] args) {\n" + + " X<X1<X2<X3<String>>>> x = new X<X1<X2<X3<String>>>>();\n" + + " x.a = new X1<X2<X3<String>>>();\n" + + " x.a.a1 = new X2<X3<String>>();\n" + + " x.a.a1.a2 = new X3<String>();\n" + + " x.a.a1.a2.a3 = \"SUCCESS\";\n" + + " System.out.println(x.a.a1.a2.a3);\n" + + " }\n" + + "}\n" + + "class X1<A extends X2<X3<String>>> {\n" + + " A a1;\n" + + "}\n" + + "class X2<A extends X3<String>> {\n" + + " A a2;\n" + + "}\n" + + "class X3<A> {\n" + + " A a3;\n" + + "}\n" + }, + "SUCCESS" + ); + } + // TODO (david) remove errors: insert dimension to complete array type + public void test080() { + this.runNegativeTest( + new String[] { + "test/X.java", + "package test;\n" + + "public class X<A extends X1<X2<X3<String>>> {}\n" + + "class X1<A extends X2<X3<String>> {}\n" + + "class X2<A extends X3<String> {}\n" + + "class X3<A {}\n" + }, + "----------\n" + + "1. ERROR in test\\X.java (at line 2)\n" + + " public class X<A extends X1<X2<X3<String>>> {}\n" + + " ^^^\n" + + "Syntax error, insert \">\" to complete ReferenceType1\n" + + "----------\n" + + "2. ERROR in test\\X.java (at line 2)\n" + + " public class X<A extends X1<X2<X3<String>>> {}\n" + + " ^^^\n" + + "Syntax error, insert \"Dimensions\" to complete ArrayType\n" + + "----------\n" + + "3. ERROR in test\\X.java (at line 3)\n" + + " class X1<A extends X2<X3<String>> {}\n" + + " ^^\n" + + "Syntax error, insert \">\" to complete ReferenceType1\n" + + "----------\n" + + "4. ERROR in test\\X.java (at line 3)\n" + + " class X1<A extends X2<X3<String>> {}\n" + + " ^^\n" + + "Syntax error, insert \"Dimensions\" to complete ArrayType\n" + + "----------\n" + + "5. ERROR in test\\X.java (at line 4)\n" + + " class X2<A extends X3<String> {}\n" + + " ^\n" + + "Syntax error, insert \">\" to complete ReferenceType1\n" + + "----------\n" + + "6. ERROR in test\\X.java (at line 4)\n" + + " class X2<A extends X3<String> {}\n" + + " ^\n" + + "Syntax error, insert \"Dimensions\" to complete ArrayType\n" + + "----------\n" + + "7. ERROR in test\\X.java (at line 5)\n" + + " class X3<A {}\n" + + " ^\n" + + "Syntax error on token \"A\", > expected after this token\n" + + "----------\n" + ); + } + // TODO (david) remove errors: insert dimension to complete array type + public void test081() { + this.runNegativeTest( + new String[] { + "test/X.java", + "package test;\n" + + "public class X<A extends X1<X2<X3<String>> {}\n" + + "class X1<A extends X2<X3<String> {}\n" + + "class X2<A extends X3<String {}\n" + + "class X3<A> {}\n" + }, + "----------\n" + + "1. ERROR in test\\X.java (at line 2)\n" + + " public class X<A extends X1<X2<X3<String>> {}\n" + + " ^^\n" + + "Syntax error, insert \">>\" to complete ReferenceType2\n" + + "----------\n" + + "2. ERROR in test\\X.java (at line 2)\n" + + " public class X<A extends X1<X2<X3<String>> {}\n" + + " ^^\n" + + "Syntax error, insert \"Dimensions\" to complete ArrayType\n" + + "----------\n" + + "3. ERROR in test\\X.java (at line 3)\n" + + " class X1<A extends X2<X3<String> {}\n" + + " ^\n" + + "Syntax error, insert \">>\" to complete ReferenceType2\n" + + "----------\n" + + "4. ERROR in test\\X.java (at line 3)\n" + + " class X1<A extends X2<X3<String> {}\n" + + " ^\n" + + "Syntax error, insert \"Dimensions\" to complete ArrayType\n" + + "----------\n" + + "5. ERROR in test\\X.java (at line 4)\n" + + " class X2<A extends X3<String {}\n" + + " ^^^^^^\n" + + "Syntax error, insert \">>\" to complete ReferenceType2\n" + + "----------\n" + ); + } + // TODO (david) remove error: insert dimension to complete array type + public void test082() { + this.runNegativeTest( + new String[] { + "test/X.java", + "package test;\n" + + "public class X<A extends X1<X2<X3<String> {}\n" + + "class X1<A extends X2<X3<String {}\n" + + "class X2<A extends X3<String>> {}\n" + + "class X3<A> {}\n" + }, + "----------\n" + + "1. ERROR in test\\X.java (at line 2)\n" + + " public class X<A extends X1<X2<X3<String> {}\n" + + " ^\n" + + "Syntax error, insert \">>>\" to complete ReferenceType3\n" + + "----------\n" + + "2. ERROR in test\\X.java (at line 2)\n" + + " public class X<A extends X1<X2<X3<String> {}\n" + + " ^\n" + + "Syntax error, insert \"Dimensions\" to complete ArrayType\n" + + "----------\n" + + "3. ERROR in test\\X.java (at line 3)\n" + + " class X1<A extends X2<X3<String {}\n" + + " ^^^^^^\n" + + "Syntax error, insert \">>>\" to complete ReferenceType3\n" + + "----------\n" + ); + } + // TODO (david) remove error: insert dimension to complete array type + public void test083() { + this.runNegativeTest( + new String[] { + "test/X.java", + "package test;\n" + + "public class X<A extends X1<X2<X3<String {}\n" + + "class X1<A extends X2<X3<String>>> {}\n" + + "class X2<A extends X3<String>> {}\n" + + "class X3<A> {}\n" + }, + "----------\n" + + "1. ERROR in test\\X.java (at line 2)\n" + + " public class X<A extends X1<X2<X3<String {}\n" + + " ^^^^^^\n" + + "Syntax error, insert \">\" to complete ReferenceType1\n" + + "----------\n" + + "2. ERROR in test\\X.java (at line 2)\n" + + " public class X<A extends X1<X2<X3<String {}\n" + + " ^^^^^^\n" + + "Syntax error, insert \"Dimensions\" to complete ArrayType\n" + + "----------\n" + + "3. ERROR in test\\X.java (at line 2)\n" + + " public class X<A extends X1<X2<X3<String {}\n" + + " ^^^^^^\n" + + "Syntax error, insert \">>>\" to complete ReferenceType3\n" + + "----------\n" + ); + } + public void test084() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " X(AX<String> a, AX<String> b) {\n" + + " }\n" + + " void foo(AX<String> a) {\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X x = new X((AX)null, (AX)null);\n" + + " AX a = new AX((AX)null);\n" + + " AX a2 = new AX(null);\n" + + " x.foo(a);\n" + + " a.foo(a);\n" + + " a.bar(a);\n" + + " AX<String> as = new AX<String>(null);\n" + + " as.print(a);\n" + + " as.bar(a);\n" + + " }\n" + + "}\n" + + "class AX <P> {\n" + + " AX(AX<P> ax){}\n" + + " AX(P p){}\n" + + " void print(P p){}\n" + + " void foo(AX rawAx){}\n" + + " void bar(AX<P> ax){}\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 7)\n" + + " X x = new X((AX)null, (AX)null);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Unsafe type operation: The constructor X(AX<String>, AX<String>) should not be applied for the arguments (AX, AX). References to generic types should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 8)\n" + + " AX a = new AX((AX)null);\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Unsafe type operation: Should not invoke the constructor AX(AX<P>) of raw type AX. References to generic type AX<P> should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 9)\n" + + " AX a2 = new AX(null);\n" + + " ^^^^^^^^^^^^\n" + + "Unsafe type operation: Should not invoke the constructor AX(AX<P>) of raw type AX. References to generic type AX<P> should be parameterized\n" + + "----------\n" + + "4. WARNING in X.java (at line 10)\n" + + " x.foo(a);\n" + + " ^^^^^^^^\n" + + "Unsafe type operation: The method foo(AX<String>) in the type X should not be applied for the arguments (AX). References to generic types should be parameterized\n" + + "----------\n" + + "5. WARNING in X.java (at line 12)\n" + + " a.bar(a);\n" + + " ^^^^^^^^\n" + + "Unsafe type operation: Should not invoke the method bar(AX<P>) of raw type AX. References to generic type AX<P> should be parameterized\n" + + "----------\n" + + "6. ERROR in X.java (at line 13)\n" + + " AX<String> as = new AX<String>(null);\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "The constructor AX<String>(AX<String>) is ambiguous\n" + + "----------\n" + + "7. ERROR in X.java (at line 14)\n" + + " as.print(a);\n" + + " ^^^^^\n" + + "The method print(String) in the type AX<String> is not applicable for the arguments (AX)\n" + + "----------\n" + + "8. WARNING in X.java (at line 15)\n" + + " as.bar(a);\n" + + " ^^^^^^^^^\n" + + "Unsafe type operation: The method bar(AX<P>) in the type AX<String> should not be applied for the arguments (AX). References to generic types should be parameterized\n" + + "----------\n"); + } + + public void test085() { + this.runConformTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX ax = new AX();\n" + + " X x = (X)ax.p;\n" + + " System.out.println(x);\n" + + " }\n" + + "}\n" + + "\n" + + "class AX <P> {\n" + + " \n" + + " P p;\n" + + "}\n", + }, + "null"); + } + + public void test086() { + Map customOptions = getCompilerOptions(); + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX ax = new AX();\n" + + " AX ax2 = ax.p;\n" + + " ax.p = new AX<String>();\n" + + " System.out.println(ax2);\n" + + " }\n" + + "}\n" + + "\n" + + "class AX <P> {\n" + + " AX<P> p;\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " ax.p = new AX<String>();\n" + + " ^^^^\n" + + "Unsafe type operation: Should not assign expression of type AX<String> to the field p of raw type AX. References to generic type AX<P> should be parameterized\n" + + "----------\n", + null, + true, + customOptions); + } + + public void test087() { + Map customOptions = getCompilerOptions(); + // check no unsafe type operation problem is issued + customOptions.put(CompilerOptions.OPTION_ReportUnsafeTypeOperation, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX ax = new AX();\n" + + " AX ax2 = ax.p;\n" + + " AX ax3 = new AX<String>();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "\n" + + "class AX <P> {\n" + + " AX<P> p;\n" + + "}\n", + }, + "SUCCESS", + null, + true, + null, + customOptions); + } + + public void test088() { + Map customOptions = getCompilerOptions(); + // check no unsafe type operation problem is issued + customOptions.put(CompilerOptions.OPTION_ReportUnsafeTypeOperation, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " AX ax = new AX();\n" + + " AX ax2 = ax.p;\n" + + " AX ax3 = new AX<String>();\n" + + "}\n" + + "\n" + + "class AX <P> {\n" + + " AX<P> p;\n" + + "}\n", + }, + "", + null, + true, + null, + customOptions); + } + + public void test089() { + this.runConformTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " T q;\n" + + " public static void main(String[] args) {\n" + + " X<String[]> xss = new X<String[]>();\n" + + " X<X<String[]>> xxs = new X<X<String[]>>();\n" + + " xxs.q = xss;\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + + public void test090() { + Map customOptions = getCompilerOptions(); + // check no unsafe type operation problem is issued + customOptions.put(CompilerOptions.OPTION_ReportUnsafeTypeOperation, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " T q;\n" + + " \n" + + " public static void main(String[] args) {\n" + + " X<String[]> xss = new X<String[]>();\n" + + " X<X<String[]>> xxs = new X<X<String[]>>();\n" + + " xxs.q = xss;\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " void foo(X[] xs) {\n" + + " xs[0] = new X<String>();\n" + + " }\n" + + "}\n", + }, + "SUCCESS", + null, + true, + null, + customOptions); + } + + public void test091() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " void foo(X<String>[] xs) {\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(X<String>[] xs) {\n" + + " ^\n" + + "An array of parameterized type X<String> is an invalid type\n" + + "----------\n"); + } + + public void test092() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " void foo() {\n" + + " X<String> xs = new X<String>(\"\");\n" + + " X<String> xs2 = (X<String>) xs;\n" + + " \n" + + " ((X)xs).t = this;\n" + + " \n" + + " System.out.prinln((T) this.t);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X<String>(\"SUCCESS\").foo();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 8)\n" + + " X<String> xs2 = (X<String>) xs;\n" + + " ^^^^^^^^^^^^^^\n" + + "Unnecessary cast to type X<String> for expression of type X<String>\n" + + "----------\n" + + "2. WARNING in X.java (at line 10)\n" + + " ((X)xs).t = this;\n" + + " ^\n" + + "Unsafe type operation: Should not assign expression of type X<T> to the field t of raw type X. References to generic type X<T> should be parameterized\n" + + "----------\n" + + "3. ERROR in X.java (at line 12)\n" + + " System.out.prinln((T) this.t);\n" + + " ^^^^^^\n" + + "The method prinln(T) is undefined for the type PrintStream\n" + + "----------\n"); + } + + public void test093() { + this.runConformTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " public static void main(String[] args) {\n" + + " AX ax = new AX();\n" + + " AX ax2 = new AX();\n" + + " ax.p = ax2.p;\n" + // javac reports unchecked warning, which seems a bug as no difference in between lhs and rhs types + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "class AX <P> {\n" + + " AX<P> p;\n" + + "}\n", + }, + "SUCCESS"); + } + + // same as test001, but every type is now a SourceTypeBinding + public void test094() { + this.runConformTest( + new String[] { + "X.java", + "public class X<Tx1 extends S, Tx2 extends C> extends XS<Tx2> {\n" + + "\n" + + " public static void main(String[] args) {\n" + + " I w = new X<S,I>().get(new I());\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "class S {}\n" + + "class I implements C<I> {}\n" + + "interface C<Tc> {}\n" + + "class XS <Txs> {\n" + + " Txs get(Txs t) {\n" + + " return t;\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + public void test095() { + this.runConformTest( + new String[] { + "X.java", + "public class X<Tx1 extends S, Tx2 extends C> extends XS<Tx2> {\n" + + "\n" + + " public static void main(String[] args) {\n" + + " I w = new X<S,I>().get(new I());\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "class S {}\n" + + "class I implements C {}\n" + + "interface C<Tc> {}\n" + + "class XS <Txs> {\n" + + " Txs get(Txs t) {\n" + + " return t;\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + public void test096() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T> extends X {}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X<T> extends X {}\n" + + " ^\n" + + "Cycle detected: the type X cannot extend/implement itself or one of its own member types\n" + + "----------\n"); + } + public void test097() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T> extends X<String> {}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 1)\n" + + " public class X<T> extends X<String> {}\n" + + " ^\n" + + "Cycle detected: the type X cannot extend/implement itself or one of its own member types\n" + + "----------\n"); + } + public void test098() { + Map customOptions = getCompilerOptions(); + customOptions.put(CompilerOptions.OPTION_ReportUnsafeTypeOperation, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX ax = new AX();\n" + + " AX ax2 = ax.p;\n" + + " ax.p = new AX<String>();\n" + + " ax.q = new AX<String>();\n" + + " ax.r = new AX<Object>();\n" + + " ax.s = new AX<String>();\n" + + " System.out.println(ax2);\n" + + " }\n" + + "}\n" + + "\n" + + "class AX <P> {\n" + + " AX<P> p;\n" + + " AX<Object> q;\n" + + " AX<String> r;\n" + + " BX<String> s;\n" + + "}\n" + + "\n" + + "class BX<Q> {\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " ax.p = new AX<String>();\n" + + " ^^^^\n" + + "Unsafe type operation: Should not assign expression of type AX<String> to the field p of raw type AX. References to generic type AX<P> should be parameterized\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " ax.q = new AX<String>();\n" + + " ^^^^\n" + + "Unsafe type operation: Should not assign expression of type AX<String> to the field q of raw type AX. References to generic type AX<P> should be parameterized\n" + + "----------\n" + + "3. ERROR in X.java (at line 8)\n" + + " ax.r = new AX<Object>();\n" + + " ^^^^\n" + + "Unsafe type operation: Should not assign expression of type AX<Object> to the field r of raw type AX. References to generic type AX<P> should be parameterized\n" + + "----------\n" + + "4. ERROR in X.java (at line 9)\n" + + " ax.s = new AX<String>();\n" + + " ^^^^^^^^^^^^^^^^\n" + + "Type mismatch: cannot convert from AX<String> to BX\n" + + "----------\n", + null, + true, + customOptions); + } + // wildcard bound cannot be base type + // TODO (david) only syntax error should be related to wilcard bound being a base type. Ripple effect is severe here. + public void test099() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T extends AX<? super int>> {\n" + + " public static void main(String[] args) {\n" + + " AX<String> ax;\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " void foo(X<?> x) {\n" + + " }\n" + + "}\n" + + "\n" + + "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"); + } + + // type parameterized with wildcard cannot appear in allocation + public void test100() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " T t;\n" + + " X(T t){\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X<? extends AX> x = new X<? extends AX>(new AX<String>());\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "\n" + + "class AX<P> {\n" + + " P foo() { return null; }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " X<? extends AX> x = new X<? extends AX>(new AX<String>());\n" + + " ^\n" + + "Cannot instantiate the generic type X<T> using wildcard arguments (? extends AX)\n" + + "----------\n"); + } + + + // wilcard may not pass parameter bound check + public void test101() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T extends String> {\n" + + " T t;\n" + + " X(T t){\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X<? extends AX> x = new X<AX<String>>(new AX<String>());\n" + + " x.t.foo(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "\n" + + "class AX<P> {\n" + + " void foo(P p) { \n" + + " System.out.println(p);\n" + + " }\n" + + "}\n" + + "\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 1)\n" + + " public class X <T extends String> {\n" + + " ^^^^^^\n" + + "The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " X<? extends AX> x = new X<AX<String>>(new AX<String>());\n" + + " ^^^^^^^^^^^^\n" + + "Bound mismatch: The type ? extends AX is not a valid substitute for the bounded parameter <T extends String> of the type X<T>\n" + + "----------\n" + + "3. ERROR in X.java (at line 7)\n" + + " X<? extends AX> x = new X<AX<String>>(new AX<String>());\n" + + " ^^\n" + + "Bound mismatch: The type AX<String> is not a valid substitute for the bounded parameter <T extends String> of the type X<T>\n" + + "----------\n"); + } + // unbound wildcard implicitly bound by matching parameter bounds + public void test102() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T extends AX> {\n" + + " T t;\n" + + " X(T t){\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X<?> x = new X<BX<String>>(new BX<String>());\n" + + " x.t.foo(\"SUCC\");\n" + + " x.t.bar(\"ESS\");\n" + + " }\n" + + "}\n" + + "\n" + + "class AX<P> {\n" + + " void foo(P p) { \n" + + " System.out.print(p);\n" + + " }\n" + + "}\n" + + "\n" + + "class BX<Q> extends AX<Q> {\n" + + " void bar(Q q) { \n" + + " System.out.println(q);\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " x.t.bar(\"ESS\");\n" + + " ^^^\n" + + "The method bar(String) is undefined for the type ?\n" + + "----------\n"); + } + + public void test103() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends AX> {\n" + + " T t;\n" + + " X(T t){\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X<? extends BX> x = new X<BX<String>>(new BX<String>());\n" + + " x.t.foo(\"SUCC\");\n" + + " x.t.bar(\"ESS\");\n" + + " }\n" + + "}\n" + + "\n" + + "class AX<P> {\n" + + " void foo(P p) { \n" + + " System.out.print(p);\n" + + " }\n" + + "}\n" + + "\n" + + "class BX<Q> extends AX<Q> {\n" + + " void bar(Q q) { \n" + + " System.out.println(q);\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + + // wildcard bound check + public void test104() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T extends AX> {\n" + + " T t;\n" + + " X(T t){\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X<? extends BX> x = new X<AX<String>>(new AX<String>());\n" + + " x.t.foo(\"SUCC\");\n" + + " x.t.bar(\"ESS\");\n" + + " }\n" + + "}\n" + + "\n" + + "class AX<P> {\n" + + " void foo(P p) { \n" + + " System.out.print(p);\n" + + " }\n" + + "}\n" + + "\n" + + "class BX<Q> extends AX<Q> {\n" + + " void bar(Q q) { \n" + + " System.out.println(q);\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " X<? extends BX> x = new X<AX<String>>(new AX<String>());\n" + + " ^\n" + + "Type mismatch: cannot convert from X<AX<String>> to X<? extends BX>\n" + + "----------\n"); + } + public void test105() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends AX> {\n" + + " T t;\n" + + " X(T t){\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X<? extends AX> x = new X<AX<String>>(new AX<String>());\n" + + " x.t.foo(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "\n" + + "class AX<P> {\n" + + " void foo(P p) { \n" + + " System.out.println(p);\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + public void test106() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends AX> {\n" + + " T t;\n" + + " X(T t){\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " X<BX<String>> x = new X<BX<String>>(new BX<String>());\n" + + " x.t.foo(\"SUCC\");\n" + + " x.t.bar(\"ESS\");\n" + + " }\n" + + "}\n" + + "\n" + + "class AX<P> {\n" + + " void foo(P p) { \n" + + " System.out.print(p);\n" + + " }\n" + + "}\n" + + "\n" + + "class BX<Q> extends AX<Q> {\n" + + " void bar(Q q) { \n" + + " System.out.println(q);\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // unsafe assignment thru binaries + public void test107() { + Map customOptions = getCompilerOptions(); + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "\n" + + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " \n" + + " Iterable<String> is = new ArrayList();\n" + + " is.iterator();\n" + + " }\n" + + "}\n" + + "\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 7)\n" + + " Iterable<String> is = new ArrayList();\n" + + " ^^^^^^^^^^^^^^^\n" + + "Unsafe type operation: Should not assign expression of raw type ArrayList to type Iterable<String>. References to generic type Iterable<T> should be parameterized\n" + + "----------\n", + null, + true, + customOptions); + } + // class literal: Integer.class of type Class<Integer> + public void test108() { + // also ensure no unsafe type operation problem is issued (assignment to variable of type raw) + Map customOptions = getCompilerOptions(); + customOptions.put(CompilerOptions.OPTION_ReportUnsafeTypeOperation, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " Class k;\n" + + " public static void main(String args[]) {\n" + + " new X().foo();\n" + + " }\n" + + " void foo() {\n" + + " Class c = this.getClass();\n" + + " this.k = this.getClass();\n" + + " this.k = Integer.class;\n" + + " try {\n" + + " Integer i = Integer.class.newInstance();\n" + + " } catch (Exception e) {\n" + + " }\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS", + null, + true, + null, + customOptions); + } + // parameterized interface cannot be implemented simultaneously with distinct arguments + public void test109() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X implements AX<String> {}\n" + + "class Y extends X implements AX<Thread> {}\n" + + "interface AX<P> {}\n" + + "\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " class Y extends X implements AX<Thread> {}\n" + + " ^\n" + + "The interface AX cannot be implemented simultaneously with different arguments: AX<Thread> and AX<String>\n" + + "----------\n"); + } + public void test110() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X implements AX {}\n" + + "class Y extends X implements AX<Thread> {}\n" + + "interface AX<P> {}\n" + + "\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " class Y extends X implements AX<Thread> {}\n" + + " ^\n" + + "The interface AX cannot be implemented simultaneously with different arguments: AX<Thread> and AX\n" + + "----------\n"); + } + public void test111() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X implements AX<Object> {}\n" + + "class Y extends X implements AX {}\n" + + "interface AX<P> {}\n" + + "\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " class Y extends X implements AX {}\n" + + " ^\n" + + "The interface AX cannot be implemented simultaneously with different arguments: AX and AX<Object>\n" + + "----------\n"); + } + // test member types + public void test112() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T extends X.MX<Runnable>.MMX<Iterable<String>>>{\n" + + " public static void main(String [] args) {\n" + + " \n" + + " new X<X.MX<Runnable>.MMX<Iterable<String>>>().new MX<Exception>();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " void foo(X<Thread>.MX.MMX<X> mx) {\n" + + " }\n" + + " \n" + + " class MX <MT> {\n" + + " class MMX <MMT> {\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " void foo(X<Thread>.MX.MMX<X> mx) {\n" + + " ^^^^^^\n" + + "Bound mismatch: The type Thread is not a valid substitute for the bounded parameter <T extends X.MX<Runnable>.MMX<Iterable<String>>> of the type X<T>\n" + + "----------\n"); + } + public void test113() { + this.runConformTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " class MX<U> {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new X<Thread>().foo();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " void foo() {\n" + + " new X<String>().new MX<T>();\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + public void test114() { + this.runConformTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " class MX<U> {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new X<Thread>().foo(new X<String>().new MX<Thread>());\n" + + " }\n" + + " void foo(X.MX<Thread> mx) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + public void test115() { + this.runConformTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " class MX<U> {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new X<Thread>().foo(new X<String>().new MX<Thread>());\n" + + " }\n" + + " void foo(X<String>.MX mx) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + public void test116() { + this.runConformTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " class MX<U> {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new X<Thread>().foo(new X<String>().new MX<Thread>());\n" + + " }\n" + + " void foo(X.MX mx) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // test member types + public void test117() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends X.MX<Runnable>.MMX<Iterable<String>>>{\n" + + " public static void main(String [] args) {\n" + + " \n" + + " new X<X.MX<Runnable>.MMX<Iterable<String>>>().new MX<Exception>();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " void foo(X<X.MX.MMX>.MX.MMX<X> mx) {\n" + + " }\n" + + " \n" + + " class MX <MT> {\n" + + " class MMX <MMT> {\n" + + " }\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // test generic method with recursive parameter bound <T extends Comparable<? super T>> + public void test118() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " java.util.Collections.sort(new java.util.LinkedList<String>());\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + // test binary member types + public void test119() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T extends X.MX<Runnable>.MMX<Iterable<String>>>{\n" + + " public static void main(String [] args) {\n" + + " \n" + + " new X<X.MX<Runnable>.MMX<Iterable<String>>>().new MX<Exception>();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " void foo(X<X.MX.MMX>.MX.MMX<X> mx) {\n" + + " }\n" + + " void foo2(X.MX.MMX<X> mx) {\n" + + " }\n" + + " void foo3(X<X.MX<Runnable>.MMX<Iterable<String>>> mx) {\n" + + " }\n" + + " \n" + + " class MX <MT> {\n" + + " class MMX <MMT> {\n" + + " }\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + + this.runConformTest( + new String[] { + "Y.java", + "public class Y extends X {\n" + + " public static void main(String [] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS", + null, + false, // do not flush output + null); + } + // test generic method + public void test120() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T>{\n" + + " public static void main(String[] args) {\n" + + " \n" + + " String s = new X<String>().foo(\"SUCCESS\");\n" + + " }\n" + + " <U extends String> T foo (U u) {\n" + + " System.out.println(u);\n" + + " return null;\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // substitute array types + public void test121() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " public static void main(String[] args) {\n" + + " new X<String>().foo(args);\n" + + " }\n" + + " \n" + + " void foo(T[] ts) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // generic method with most specific common supertype: U --> String + public void test122() { + this.runConformTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " public static void main(String[] args) {\n" + + " new X<String>().foo(args, new X<X<String>>());\n" + + " }\n" + + " <U> void foo(U[] us, X<X<U>> xxu) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // invalid parameterized type + public void test123() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " T<String> ts;\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " T<String> ts;\n" + + " ^\n" + + "The type T is not generic; it cannot be parameterized with arguments <String>\n" + + "----------\n"); + } + // generic method with indirect type inference: BX<String, Thread> --> AX<W> + public void test124() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " <W> void foo(AX<W> aw) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " new X().foo(new BX<String,Thread>());\n" + + " }\n" + + "}\n" + + "\n" + + "class AX<T> {\n" + + "}\n" + + "class BX<U, V> extends AX<V> {\n" + + "}\n", + }, + "SUCCESS"); + } + // generic method with indirect type inference: CX --> AX<W> + public void test125() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " <W> void foo(AX<W> aw) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " new X().foo(new CX());\n" + + " }\n" + + "}\n" + + "\n" + + "class AX<T> {\n" + + "}\n" + + "class BX<U, V> extends AX<V> {\n" + + "}\n" + + "class CX extends BX<String, Thread> {\n" + + "}\n", + }, + "SUCCESS"); + } + // variation on test125 with typo: CX extends B instead of BX. + public void test126() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " <W> void foo(AX<W> aw) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " new X().foo(new CX());\n" + + " }\n" + + "}\n" + + "\n" + + "class AX<T> {\n" + + "}\n" + + "class BX<U, V> extends AX<V> {\n" + + "}\n" + + "class CX extends B<String, Thread> {\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " new X().foo(new CX());\n" + + " ^^^\n" + + "The method foo(AX<W>) in the type X is not applicable for the arguments (CX)\n" + + "----------\n" + + "2. ERROR in X.java (at line 16)\n" + + " class CX extends B<String, Thread> {\n" + + " ^\n" + + "B cannot be resolved to a type\n" + + "----------\n"); + } + // 57784: test generic method + public void test127() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " java.util.Arrays.asList(new Object[] {\"1\"});\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + // 58666: special treatment for Object#getClass declared of type: Class<? extends Object> + // but implicitly converted to Class<? extends X> for free. + public void test128() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X { \n" + + " public static void main(String[] args) {\n" + + " X x = new X();\n" + + " Class c1 = x.getClass();\n" + + " Class<? extends X> c2 = x.getClass();\n" + + " String s = \"hello\";\n" + + " Class<? extends X> c3 = s.getClass();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " Class<? extends X> c3 = s.getClass();\n" + + " ^^\n" + + "Type mismatch: cannot convert from Class<? extends String> to Class<? extends X>\n" + + "----------\n"); + } + // variation on test128 + public void test129() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X { \n" + + "\n" + + " public static void main(String[] args) {\n" + + " XY xy = new XY();\n" + + " Class c1 = xy.getClass();\n" + + " Class<? extends XY> c2 = xy.getClass();\n" + + " String s = \"hello\";\n" + + " Class<? extends XY> c3 = s.getClass();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "\n" + + "class XY extends X {\n" + + " public Class <? extends Object> getClass() {\n" + + " return super.getClass();\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " Class<? extends XY> c3 = s.getClass();\n" + + " ^^\n" + + "Type mismatch: cannot convert from Class<? extends String> to Class<? extends XY>\n" + + "----------\n" + + "2. ERROR in X.java (at line 14)\n" + + " public Class <? extends Object> getClass() {\n" + + " ^^^^^^^^^^\n" + + "Cannot override the final method from Object\n" + + "----------\n"); + } + // getClass on array type + public void test130() { + this.runConformTest( + new String[] { + "X.java", + "public class X { \n" + + "\n" + + " public static void main(String[] args) {\n" + + " X[] x = new X[0];\n" + + " Class<? extends X[]> c = x.getClass();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + // 58979 + public void test131() { + this.runNegativeTest( + new String[] { + "ArrayList.java", + " interface List<T> {\n" + + " List<T> foo();\n" + + "}\n" + + "\n" + + " class ArrayList<T> implements List<T> {\n" + + " public List<T> foo() {\n" + + " List<T> lt = this;\n" + + " lt.bar();\n" + + " return this;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in ArrayList.java (at line 8)\n" + + " lt.bar();\n" + + " ^^^\n" + + "The method bar() is undefined for the type List<T>\n" + + "----------\n"); + } + public void test132() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " <T extends X<W>.Z> foo() {}\n" + + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " <T extends X<W>.Z> foo() {}\n" + + " ^\n" + + "W cannot be resolved to a type\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " <T extends X<W>.Z> foo() {}\n" + + " ^^^^^\n" + + "Return type for the method is missing\n" + + "----------\n"); + } + // bridge method + public void test133() { + this.runConformTest( + new String[] { + "X.java", + "public class X<T> {\n" + + " public static void main(String[] args) {\n" + + " X x = new Y();\n" + + " System.out.println(x.foo());\n" + + " }\n" + + " T foo() {return null;}\n" + + " void foo(T t) {}\n" + + "}\n" + + "class Y extends X<Object> {\n" + + " String foo() {return \"SUCCESS\";}\n" + + " void foo(String s) {}\n" + + "}\n" + }, + "SUCCESS"); + } + public void test134() { + this.runConformTest( + new String[] { + "Z.java", + "import java.util.ArrayList;\n" + + "import java.util.List;\n" + + "\n" + + "public class Z <T extends List> { \n" + + " T t;\n" + + " public static void main(String[] args) {\n" + + " foo(new Z<ArrayList>().set(new ArrayList<String>()));\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " Z<T> set(T t) {\n" + + " this.t = t;\n" + + " return this;\n" + + " }\n" + + " T get() { \n" + + " return this.t; \n" + + " }\n" + + " \n" + + " static void foo(Z<? super ArrayList> za) {\n" + + " za.get().isEmpty();\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + public void test135() { + this.runNegativeTest( + new String[] { + "Z.java", + "public class Z <T extends ZA> { \n" + + " public static void main(String[] args) {\n" + + " foo(new Z<ZA>());\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " static void foo(Z<? super String> zs) {\n" + + " }\n" + + "}\n" + + "\n" + + "class ZA {\n" + + " void foo() {}\n" + + "}\n" + + "\n" + + "class ZB extends ZA {\n" + + "}" + }, + "----------\n" + + "1. ERROR in Z.java (at line 3)\n" + + " foo(new Z<ZA>());\n" + + " ^^^\n" + + "The method foo(Z<? super String>) in the type Z<T> is not applicable for the arguments (Z<ZA>)\n" + + "----------\n" + + "2. ERROR in Z.java (at line 6)\n" + + " static void foo(Z<? super String> zs) {\n" + + " ^^^^^^^^^^^^^^\n" + + "Bound mismatch: The type ? super String is not a valid substitute for the bounded parameter <T extends ZA> of the type Z<T>\n" + + "----------\n"); + } + public void test136() { + this.runNegativeTest( + new String[] { + "Z.java", + "public class Z <T extends ZB> { \n" + + " public static void main(String[] args) {\n" + + " foo(new Z<ZB>());\n" + + " }\n" + + " static void foo(Z<? super ZA> zs) {\n" + + " zs.foo();\n" + + " }\n" + + "}\n" + + "class ZA {\n" + + "}\n" + + "class ZB extends ZA {\n" + + " void foo() {}\n" + + "}" + }, + "----------\n" + + "1. ERROR in Z.java (at line 3)\n" + + " foo(new Z<ZB>());\n" + + " ^^^\n" + + "The method foo(Z<? super ZA>) in the type Z<T> is not applicable for the arguments (Z<ZB>)\n" + + "----------\n" + + "2. ERROR in Z.java (at line 5)\n" + + " static void foo(Z<? super ZA> zs) {\n" + + " ^^^^^^^^^^\n" + + "Bound mismatch: The type ? super ZA is not a valid substitute for the bounded parameter <T extends ZB> of the type Z<T>\n" + + "----------\n" + + "3. ERROR in Z.java (at line 6)\n" + + " zs.foo();\n" + + " ^^^\n" + + "The method foo(Z<? super ZA>) in the type Z<? super ZA> is not applicable for the arguments ()\n" + + "----------\n"); + } + public void test137() { + this.runConformTest( + new String[] { + "Z.java", + "import java.util.ArrayList;\n" + + "import java.util.List;\n" + + "\n" + + "public class Z <T extends List> { \n" + + " T t;\n" + + " public static void main(String[] args) {\n" + + " foo(new Z<ArrayList>().set(new ArrayList<String>()));\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " Z<T> set(T t) {\n" + + " this.t = t;\n" + + " return this;\n" + + " }\n" + + " T get() { \n" + + " return this.t; \n" + + " }\n" + + " \n" + + " static void foo(Z<? extends ArrayList> za) {\n" + + " za.get().isEmpty();\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + // unbound wildcard still remembers its variable bound: Z<?> behaves like Z<AX> + public void test138() { + this.runConformTest( + new String[] { + "Z.java", + "public class Z <T extends AX> {\n" + + " T t;\n" + + " Z(T t){\n" + + " this.t = t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " Z<AX<String>> zax = new Z<AX<String>>(new AX<String>());\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " void baz(Z<?> zu){\n" + + " zu.t.foo(null);\n" + + " }\n" + + "}\n" + + "\n" + + "class AX<P> {\n" + + " void foo(P p) { \n" + + " System.out.print(p);\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + // extending wildcard considers its bound prior to its corresponding variable + public void test139() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T extends AX> {\n" + + " T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " T get() {\n" + + " return this.t;\n" + + " }\n" + + " void bar(X<? extends BX> x) {\n" + + " x.get().afoo();\n" + + " x.get().bfoo();\n" + + " }\n" + + "}\n" + + "class AX {\n" + + " void afoo() {}\n" + + "}\n" + + "class BX {\n" + + " void bfoo() {}\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " void bar(X<? extends BX> x) {\n" + + " ^^^^^^^^^^^^\n" + + "Bound mismatch: The type ? extends BX is not a valid substitute for the bounded parameter <T extends AX> of the type X<T>\n" + + "----------\n" + + "2. ERROR in X.java (at line 10)\n" + + " x.get().afoo();\n" + + " ^^^^\n" + + "The method afoo() is undefined for the type ? extends BX\n" + + "----------\n"); + } + // extending wildcard considers its bound prior to its corresponding variable + public void test140() { + this.runConformTest( + new String[] { + "X.java", + "public class X<T extends AX> {\n" + + " T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " T get() {\n" + + " return this.t;\n" + + " }\n" + + " void bar(X<? extends BX> x) {\n" + + " x.get().afoo();\n" + + " x.get().bfoo();\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + + "class AX {\n" + + " void afoo() {}\n" + + "}\n" + + "class BX extends AX {\n" + + " void bfoo() {}\n" + + "}\n", + }, + "SUCCESS"); + } + // super wildcard considers its variable for lookups + public void test141() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T extends AX> {\n" + + " T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " T get() {\n" + + " return this.t;\n" + + " }\n" + + " void bar(X<? super BX> x) {\n" + + " x.get().afoo();\n" + + " x.get().bfoo();\n" + + " }\n" + + "}\n" + + "class AX {\n" + + " void afoo() {}\n" + + "}\n" + + "class BX extends AX {\n" + + " void bfoo() {}\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 11)\n" + + " x.get().bfoo();\n" + + " ^^^^\n" + + "The method bfoo() is undefined for the type ? super BX\n" + + "----------\n"); + } + public void test142() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T extends AX> {\n" + + " T t;\n" + + " X(T t) {\n" + + " this.t = t;\n" + + " }\n" + + " T get() {\n" + + " return this.t;\n" + + " }\n" + + " void bar(X<? extends X> x) {\n" + + " x = identity(x);\n" + + " }\n" + + " <P extends AX> X<P> identity(X<P> x) {\n" + + " return x;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " }\n" + + "}\n" + + "class AX {\n" + + " void afoo() {}\n" + + "}\n" + + "class BX extends AX {\n" + + " void bfoo() {}\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " void bar(X<? extends X> x) {\n" + + " ^^^^^^^^^^^\n" + + "Bound mismatch: The type ? extends X is not a valid substitute for the bounded parameter <T extends AX> of the type X<T>\n" + + "----------\n" + + "2. ERROR in X.java (at line 10)\n" + + " x = identity(x);\n" + + " ^^^^^^^^\n" + + "Bound mismatch: The generic method identity(X<P>) of type X<T> is not applicable for the arguments (X<? extends X>) since the type ? extends X is not a valid substitute for the bounded parameter <P extends AX>\n" + + "----------\n"); + } + public void test143() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " Class<? extends X> xx = null;\n" + + " Class<? extends Object> xo = xx;\n" + + " Class<Object> xo2 = xx;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " Class<Object> xo2 = xx;\n" + + " ^^^\n" + + "Type mismatch: cannot convert from Class<? extends X> to Class<Object>\n" + + "----------\n"); + } + public void test144() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " Class<? extends X> xx = null;\n" + + " Class<? extends Object> xo = xx;\n" + + " X x = get(xx);\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " static <P> P get(Class<P> cp) {\n" + + " return null;\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // 59641: check assign/invoke with wildcards + public void test145() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " XList<?> lx = new XList<X>();\n" + + " X x = lx.get();\n" + + " lx.add(null);\n" + + " lx.add(x);\n" + + " lx.slot = x;\n" + + " lx.addAll(lx);\n" + + " } \n" + + "}\n" + + "class XList<E extends X> {\n" + + " E slot;\n" + + " void add(E e) {}\n" + + " E get() { return null; \n" + + " }\n" + + " void addAll(XList<E> le) {}\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " lx.add(x);\n" + + " ^^^^^^^^^\n" + + "Unsafe wildcard operation: The method add(?) of type XList<?> is not applicable for the arguments (X)\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " lx.slot = x;\n" + + " ^\n" + + "Unsafe wildcard operation: Cannot assign expression of type X to wildcard type ?\n" + + "----------\n"); + } + // 59628 + public void test146() { + this.runConformTest( + new String[] { + "X.java", + "import java.util.AbstractList;\n" + + "public class X extends AbstractList {\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " public int size() { return 0; }\n" + + " public Object get(int index) { return null; }\n" + + "}\n" + }, + "SUCCESS"); + } + // 59723 + public void test147() { + this.runConformTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " char[][] tokens = new char[0][];\n" + + " ArrayList list = new ArrayList();\n" + + " list.toArray(tokens);\n" + + " System.out.println(\"SUCCESS\");\n" + + " } \n" + + "}\n" + }, + "SUCCESS"); + } + // bridge method + public void test148() { + this.runConformTest( + new String[] { + "X.java", + "public class X extends AX<String>{\n" + + " \n" + + " String foo(String s) {\n" + + " System.out.println(s);\n" + + " return s;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X().bar(\"SUCCESS\");\n" + + " } \n" + + "}\n" + + "class AX<T> {\n" + + " T foo(T t) {\n" + + " return null;\n" + + " }\n" + + " void bar(T t) {\n" + + " foo(t);\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + // method compatibility + // TODO (kent) need to improve error message + public void test149() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.Collection;\n" + + "\n" + + "public abstract class X implements Collection<Object> {\n" + + "\n" + + " public Object[] toArray(Object[] a) {\n" + + " return a;\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " public Object[] toArray(Object[] a) {\n" + + " ^^^^^^^^^^^^^^^^^^^\n" + + "The return type is incompatible with Collection<Object>.toArray(T[])\n" + + "----------\n"); + } + public void test150() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.*;\n" + + "public class X {\n" + + " \n" + + " <T extends X> void foo(T[] ta, List<T> lt) {\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " new X().foo(args, new ArrayList<String>());\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " new X().foo(args, new ArrayList<String>());\n" + + " ^^^\n" + + "Bound mismatch: The generic method foo(T[], List<T>) of type X is not applicable for the arguments (String[], List<String>) since the type String is not a valid substitute for the bounded parameter <T extends X>\n" + + "----------\n"); + } + public void test151() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.*;\n" + + "public class X <E>{\n" + + " \n" + + " <T extends X> X(T[] ta, List<T> lt) {\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " new X<Object>(args, new ArrayList<String>());\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " new X<Object>(args, new ArrayList<String>());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Bound mismatch: The generic constructor X(T[], List<T>) of type X<E> is not applicable for the arguments (String[], List<String>) since the type String is not a valid substitute for the bounded parameter <T extends X>\n" + + "----------\n"); + } + // 60556 + public void test152() { + this.runConformTest( + new String[] { + "X.java", + "import java.util.*;\n" + + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " List<X> x(List<X> list) {\n" + + " return Collections.unmodifiableList(list);\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + public void test153() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>();\n" + + " AX<X> a = bar(ax);\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " public static <T> AX<T> bar(AX<? extends T> a) {\n" + + " return null;\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + "}\n" + }, + "SUCCESS"); + } + public void test154() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>();\n" + + " AX<X> a = bar(ax);\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " public static <T> AX<T> bar(AX<? super T> a) {\n" + + " return null;\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + "}\n" + }, + "SUCCESS"); + } + public void test155() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>();\n" + + " AX<X> a = bar(ax);\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " public static <T> AX<T> bar(AX<?> a) {\n" + + " return null;\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + "}\n" + }, + "SUCCESS"); + } + public void test156() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>();\n" + + " AX<X> a = bar(ax);\n" + + " }\n" + + " public static <T> AX<T> bar(AX<?> a) {\n" + + " return null;\n" + + " } \n" + + "}\n" + + "class AX<E extends X> {\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " public static <T> AX<T> bar(AX<?> a) {\n" + + " ^\n" + + "Bound mismatch: The type T is not a valid substitute for the bounded parameter <E extends X> of the type AX<E>\n" + + "----------\n"); + } + public void test157() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>();\n" + + " AX<String> as = new AX<String>();\n" + + " AX<X> a = bar(ax, as);\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " public static <T,U> AX<T> bar(AX<? extends U> a, AX<? super U> b) {\n" + + " return null;\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " AX<X> a = bar(ax, as);\n" + + " ^^^\n" + + "The method bar(AX<? extends U>, AX<? super U>) in the type X is not applicable for the arguments (AX<X>, AX<String>)\n" + + "----------\n"); + } + public void test158() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>();\n" + + " AX<String> as = new AX<String>();\n" + + " AX<X> a = bar(ax, as);\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " public static <T,U> AX<T> bar(AX<?> a, AX<? super U> b) {\n" + + " return null;\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + "}\n" + }, + "SUCCESS"); + } + public void test159() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>(new X());\n" + + " AX<String> as = new AX<String>(\"SUCCESS\");\n" + + " AX<X> a = bar(ax, as);\n" + + " }\n" + + " public static <T,U> T bar(AX<?> a, AX<? super U> b) {\n" + + " return a.get();\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " return a.get();\n" + + " ^^^^^^^\n" + + "Type mismatch: cannot convert from ? to T\n" + + "----------\n"); + } + public void test160() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " String s = foo(new AX<String>(\"aaa\"));\n" + + " }\n" + + " static <V> V foo(AX<String> a) {\n" + + " return a.get();\n" + + " }\n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " return a.get();\n" + + " ^^^^^^^\n" + + "Type mismatch: cannot convert from String to V\n" + + "----------\n"); + } + public void test161() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " boolean b = foo(new AX<String>(\"aaa\")).equals(args);\n" + + " }\n" + + " static <V> V foo(AX<String> a) {\n" + + " return a.get();\n" + + " }\n" + + " String bar() {\n" + + " return \"bbb\";\n" + + " }\n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " return a.get();\n" + + " ^^^^^^^\n" + + "Type mismatch: cannot convert from String to V\n" + + "----------\n"); + } + public void test162() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " String s = foo(new AX<String>(\"aaa\")).bar();\n" + + " }\n" + + " static <V> V foo(AX<String> a) {\n" + + " return a.get();\n" + + " }\n" + + " String bar() {\n" + + " return \"bbb\";\n" + + " }\n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " String s = foo(new AX<String>(\"aaa\")).bar();\n" + + " ^^^\n" + + "The method bar() is undefined for the type V\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " return a.get();\n" + + " ^^^^^^^\n" + + "Type mismatch: cannot convert from String to V\n" + + "----------\n"); + } + public void test163() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " String s = foo(new AX<String>(\"aaa\")).bar();\n" + + " }\n" + + " static <V> V foo(AX<String> a) {\n" + + " return a.get();\n" + + " }\n" + + " String bar() {\n" + + " return \"bbb\";\n" + + " }\n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " String s = foo(new AX<String>(\"aaa\")).bar();\n" + + " ^^^\n" + + "The method bar() is undefined for the type V\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " return a.get();\n" + + " ^^^^^^^\n" + + "Type mismatch: cannot convert from String to V\n" + + "----------\n"); + } + public void test164() { + this.runConformTest( + new String[] { + "X.java", + "import java.util.List;\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " foo(new AX<String>(\"SUCCESS\"));\n" + + " }\n" + + " static <V> List<V> foo(AX<String> a) {\n" + + " System.out.println(a.get());\n" + + " List<V> v = null;\n" + + " if (a == null) v = foo(a); \n" + + " return v;\n" + + " }\n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "SUCCESS"); + } + public void test165() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>();\n" + + " AX<String> a = bar(ax);\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " public static <T> AX<T> bar(AX<?> a) {\n" + + " if (a == null) {\n" + + " AX<String> as = bar(a);\n" + + " String s = as.get();\n" + + " }\n" + + " return null;\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + " E get() { return null; }\n" + + "}\n" + }, + "SUCCESS"); + } + public void test166() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>(new X());\n" + + " AX<String> a = bar(ax, true);\n" + + " String s = a.get();\n" + + " System.out.println(s);\n" + + " }\n" + + " public static <T> AX<T> bar(AX<?> a, boolean recurse) {\n" + + " if (recurse) {\n" + + " AX<String> as = bar(a, false);\n" + + " String s = as.get();\n" + + " }\n" + + " return new AX(\"SUCCESS\");\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "SUCCESS"); + } + public void test167() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<String, Thread> a = bar();\n" + + " String s = a.get();\n" + + " System.out.println(s);\n" + + " }\n" + + " public static <T, U> AX<T, U> bar() {\n" + + " return new AX(\"SUCCESS\");\n" + + " } \n" + + "}\n" + + "class AX<E, F> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "SUCCESS"); + } + public void test168() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<String, Thread> a = bar();\n" + + " String s = a.get();\n" + + " System.out.println(s);\n" + + " }\n" + + " public static <T, U> AX<AX<T, T>, U> bar() {\n" + + " return new AX(\"SUCCESS\");\n" + + " } \n" + + "}\n" + + "class AX<E, F> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " AX<String, Thread> a = bar();\n" + + " ^\n" + + "Type mismatch: cannot convert from AX<AX<T,T>,Thread> to AX<String,Thread>\n" + + "----------\n" + + "2. WARNING in X.java (at line 9)\n" + + " return new AX(\"SUCCESS\");\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Unsafe type operation: Should not invoke the constructor AX(E) of raw type AX. References to generic type AX<E,F> should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 9)\n" + + " return new AX(\"SUCCESS\");\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Unsafe type operation: Should not return value of raw type AX instead of type AX<AX<T,T>,U>. References to generic type AX<E,F> should be parameterized\n" + + "----------\n"); + } + public void test169() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<String> a = bar(new X());\n" + + " String s = a.get();\n" + + " System.out.println(s);\n" + + " }\n" + + " public static <T> AX<T> bar(T t) {\n" + + " return new AX(\"SUCCESS\");\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " AX<String> a = bar(new X());\n" + + " ^\n" + + "Type mismatch: cannot convert from AX<X> to AX<String>\n" + + "----------\n" + + "2. WARNING in X.java (at line 9)\n" + + " return new AX(\"SUCCESS\");\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Unsafe type operation: Should not invoke the constructor AX(E) of raw type AX. References to generic type AX<E> should be parameterized\n" + + "----------\n" + + "3. WARNING in X.java (at line 9)\n" + + " return new AX(\"SUCCESS\");\n" + + " ^^^^^^^^^^^^^^^^^\n" + + "Unsafe type operation: Should not return value of raw type AX instead of type AX<T>. References to generic type AX<E> should be parameterized\n" + + "----------\n"); + } + // Expected type inference for cast operation + public void test170() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>(new X());\n" + + " AX<String> as = new AX<String>(\"\");\n" + + " ax = (AX)bar(ax);\n" + // shouldn't complain about unnecessary cast + " }\n" + + " public static <T> T bar(AX<?> a) {\n" + + " return a.get();\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " ax = (AX)bar(ax);\n" + + " ^^^^^^^^^^^\n" + + "Unsafe type operation: Should not assign expression of raw type AX to type AX<X>. References to generic type AX<E> should be parameterized\n" + + "----------\n" + + "2. ERROR in X.java (at line 9)\n" + + " return a.get();\n" + + " ^^^^^^^\n" + + "Type mismatch: cannot convert from ? to T\n" + + "----------\n"); + } + // Expected type inference for cast operation + public void test171() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>(new X());\n" + + " AX<String> as = new AX<String>(\"\");\n" + + " ax = (AX<X>)bar(ax);\n" + // should still complain about unnecessary cast as return type inference would have + " }\n" + // worked the same without the cast due to assignment + " public static <T> T bar(AX<?> a) {\n" + + " return a.get();\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " ax = (AX<X>)bar(ax);\n" + + " ^^^^^^^^^^^^^^\n" + + "Unnecessary cast to type AX<X> for expression of type AX<X>\n" + + "----------\n" + + "2. ERROR in X.java (at line 9)\n" + + " return a.get();\n" + + " ^^^^^^^\n" + + "Type mismatch: cannot convert from ? to T\n" + + "----------\n"); + } + // Expected type inference for cast operation + public void test172() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " AX<X> ax = new AX<X>(new X());\n" + + " AX<String> as = new AX<String>(\"SUCCESS\");\n" + + " ax = (AX<X>)bar(ax);\n" + // no warn for unsafe cast, since forbidden cast + " }\n" + + " public static <T> String bar(AX<?> a) {\n" + + " return null;\n" + + " } \n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " ax = (AX<X>)bar(ax);\n" + + " ^^^^^^^^^^^^^^\n" + + "Cannot cast from String to AX<X>\n" + + "----------\n"); + } + // Expected type inference for return statement + public void test173() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " foo();\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " public static <T> T bar(AX<?> a) {\n" + + " return null;\n" + + " } \n" + + " public static AX<X> foo() {\n" + + " AX<X> ax = new AX<X>(new X());\n" + + " return bar(ax);\n" + // use return type of enclosing method for type inference + " }\n" + + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + + "\n" + }, + "SUCCESS"); + } + // Expected type inference for field declaration + public void test174() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " \n" + + " public static void main(String[] args) {\n" + + " Object o = foo;\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " public static <T> T bar(AX<?> a) {\n" + + " return null;\n" + + " } \n" + + " static AX<X> foo = bar(new AX<X>(new X()));\n" + // use field type for type inference + "}\n" + + "class AX<E> {\n" + + " E e;\n" + + " AX(E e) { this.e = e; }\n" + + " E get() { return this.e; }\n" + + "}\n" + + "\n" + }, + "SUCCESS"); + } + // 60563 + public void test175() { + this.runConformTest( + new String[] { + "X.java", + " interface A<T> {\n" + + " T[] m1(T x); \n" + + " }\n" + + " public class X { \n" + + " public static void main(String[] args) {\n" + + " new X().m2(new A<X>(){ \n" + + " public X[] m1(X x) { \n" + + " System.out.println(\"SUCCESS\");\n" + + " return null;\n" + + " }\n" + + " });\n" + + " }\n" + + " void m2(A<X> x) { \n" + + " m3(x.m1(new X())); \n" + + " }\n" + + " void m3(X[] x) {\n" + + " } \n" + + " }\n" + }, + "SUCCESS"); + } + // unsafe raw return value + public void test176() { + Map customOptions = getCompilerOptions(); + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.*;\n" + + "\n" + + "public class X {\n" + + " <T> Vector<T> valuesOf(Hashtable<?, T> h) {\n" + + " return new Vector();\n" + + " }\n" + + " Vector<Object> data;\n" + + " \n" + + " public void t() {\n" + + " Vector<Object> v = (Vector<Object>) data.elementAt(0);\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 5)\n" + + " return new Vector();\n" + + " ^^^^^^^^^^^^\n" + + "Unsafe type operation: Should not return value of raw type Vector instead of type Vector<T>. References to generic type Vector<E> should be parameterized\n" + + "----------\n" + + "2. WARNING in X.java (at line 10)\n" + + " Vector<Object> v = (Vector<Object>) data.elementAt(0);\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Unsafe type operation: The cast from Object to parameterized type Vector<Object> will not check conformance of type arguments at runtime\n" + + "----------\n", + null, + true, + customOptions); + } + // cast to type variable allowed, can be diagnosed as unnecessary + public void test177() { + Map customOptions = getCompilerOptions(); + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " \n" + + " T foo(T t) {\n" + + " return (T) t;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 4)\n" + + " return (T) t;\n" + + " ^^^^^\n" + + "Unnecessary cast to type T for expression of type T\n" + + "----------\n", + null, + true, + customOptions); + } + // reject instanceof type variable or parameterized type + public void test178() { + Map customOptions = getCompilerOptions(); + this.runNegativeTest( + new String[] { + "X.java", + "public class X <T> {\n" + + " \n" + + " T foo(T t) {\n" + + " if (t instanceof X<T>) {\n" + + " return t;\n" + + " } else if (t instanceof X<String>) {\n" + + " return t;\n" + + " } else if (t instanceof T) {\n" + + " return t;\n" + + " } else if (t instanceof X) {\n" + + " return t;\n" + + " }\n" + + " return null;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 4)\n" + + " if (t instanceof X<T>) {\n" + + " ^^^^^^^^^^^^^^\n" + + "Cannot perform instanceof check against parameterized type X<T>. Use instead its raw form X since generic type information will be erased at runtime\n" + + "----------\n" + + "2. ERROR in X.java (at line 6)\n" + + " } else if (t instanceof X<String>) {\n" + + " ^^^^^^^^^^^^^^\n" + + "Cannot perform instanceof check against parameterized type X<String>. Use instead its raw form X since generic type information will be erased at runtime\n" + + "----------\n" + + "3. ERROR in X.java (at line 8)\n" + + " } else if (t instanceof T) {\n" + + " ^^^^^^^^^^^^^^\n" + + "Cannot perform instanceof check against type parameter T. Use instead its erasure Object since generic type information will be erased at runtime\n" + + "----------\n" + + "4. ERROR in X.java (at line 10)\n" + + " } else if (t instanceof X) {\n" + + " ^^^^^^^^^^^^^^\n" + + "Incompatible conditional operand types T and X\n" + + "----------\n", + null, + true, + customOptions); + } + // 61507 + public void test179() { + this.runConformTest( + new String[] { + "X.java", + "class U {\n" + + " static <T> T notNull(T t) { return t; }\n" + + "}\n" + + "public class X {\n" + + " void t() {\n" + + " String s = U.notNull(null);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X().t();\n" + + " System.out.println(\"SUCCESS\");\n" + + "}\n" + + "}\n", + }, + "SUCCESS"); + } + public void test180() { + this.runConformTest( + new String[] { + "X.java", + "class U {\n" + + " static <T> T notNull(T t) { return t; }\n" + + "}\n" + + "public class X {\n" + + " void t() {\n" + + " String s = U.notNull(\"\");\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X().t();\n" + + " System.out.println(\"SUCCESS\");\n" + + "}\n" + + "}\n", + }, + "SUCCESS"); + } + // 61507 - variation computing most specific type with 'null' + public void test181() { + this.runConformTest( + new String[] { + "X.java", + "class U {\n" + + " static <T> T notNull(T t, V<T> vt) { return t; }\n" + + "}\n" + + "class V<T> {}\n" + + "\n" + + "public class X {\n" + + " void t() {\n" + + " String s = U.notNull(null, new V<String>());\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X().t();\n" + + " System.out.println(\"SUCCESS\");\n" + + "}\n" + + "}\n", + }, + "SUCCESS"); + } + public void test182() { + Map customOptions = getCompilerOptions(); + this.runNegativeTest( + new String[] { + "X.java", + "public class X<E> {\n" + + " X<E> foo() {\n" + + " return (X<E>) this;\n" + + " }\n" + + " X<String> bar() {\n" + + " return (AX<String>) new X<String>();\n" + + " }\n" + + " X<String> bar(Object o) {\n" + + " return (AX<String>) o;\n" + + " }\n" + + " X<E> foo(Object o) {\n" + + " return (AX<E>) o;\n" + + " } \n" + + " X<E> baz(Object o) {\n" + + " return (AX<E>) null;\n" + + " }\n" + + " X<String> baz2(BX bx) {\n" + + " return (X<String>) bx;\n" + + " } \n" + + "}\n" + + "class AX<F> extends X<F> {}\n" + + "class BX extends AX<String> {}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " return (X<E>) this;\n" + + " ^^^^^^^^^^^\n" + + "Unnecessary cast to type X<E> for expression of type X<E>\n" + + "----------\n" + + "2. WARNING in X.java (at line 9)\n" + + " return (AX<String>) o;\n" + + " ^^^^^^^^^^^^^^\n" + + "Unsafe type operation: The cast from Object to parameterized type AX<String> will not check conformance of type arguments at runtime\n" + + "----------\n" + + "3. WARNING in X.java (at line 12)\n" + + " return (AX<E>) o;\n" + + " ^^^^^^^^^\n" + + "Unsafe type operation: The cast from Object to parameterized type AX<E> will not check conformance of type arguments at runtime\n" + + "----------\n" + + "4. WARNING in X.java (at line 15)\n" + + " return (AX<E>) null;\n" + + " ^^^^^^^^^^^^\n" + + "Unnecessary cast to type AX<E> for expression of type null\n" + + "----------\n" + + "5. WARNING in X.java (at line 18)\n" + + " return (X<String>) bx;\n" + + " ^^^^^^^^^^^^^^\n" + + "Unnecessary cast to type X<String> for expression of type BX\n" + + "----------\n", + null, + true, + customOptions); + } + public void test183() { + Map customOptions = getCompilerOptions(); + this.runNegativeTest( + new String[] { + "X.java", + "import java.util.*;\n" + + "\n" + + "public class X {\n" + + " \n" + + " {\n" + + " Dictionary<String, Integer> d;\n" + + " Object o;\n" + + " \n" + + " Object a1 = (Hashtable<String,Integer>) d;\n" + + " Object a2 = (Hashtable) o;\n" + + "\n" + + " Object a3 = (Hashtable<Float, Double>) d;\n" + + " Object a4 = (Hashtable<String,Integer>) o;\n" + + " \n" + + " abstract class Z1 extends Hashtable<String,Integer> {\n" + + " }\n" + + " Z1 z1;\n" + + " Object a5 = (Hashtable<String,Integer>) z1;\n" + + "\n" + + " abstract class Z2 extends Z1 {\n" + + " }\n" + + " Object a6 = (Z2) z1;\n" + + "\n" + + " abstract class Z3 extends Hashtable {\n" + + " }\n" + + " Z3 z3;\n" + + " Object a7 = (Hashtable<String,Integer>) z3;\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 12)\n" + + " Object a3 = (Hashtable<Float, Double>) d;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Cannot cast from Dictionary<String,Integer> to Hashtable<Float,Double>\n" + + "----------\n" + + "2. WARNING in X.java (at line 13)\n" + + " Object a4 = (Hashtable<String,Integer>) o;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Unsafe type operation: The cast from Object to parameterized type Hashtable<String,Integer> will not check conformance of type arguments at runtime\n" + + "----------\n" + + "3. WARNING in X.java (at line 18)\n" + + " Object a5 = (Hashtable<String,Integer>) z1;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Unnecessary cast to type Hashtable<String,Integer> for expression of type Z1\n" + + "----------\n" + + "4. WARNING in X.java (at line 27)\n" + + " Object a7 = (Hashtable<String,Integer>) z3;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Unnecessary cast to type Hashtable<String,Integer> for expression of type Z3\n" + + "----------\n", + null, + true, + customOptions); + } + // 62292 - parameterized message send + public void test184() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + "\n" + + " static <T, U> T foo(T t, U u) {\n" + + " return t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " System.out.println(X.<String,X>foo(\"SUCCESS\", null));\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // parameterized message send - variation on 184 with non-static generic method + public void test185() { + this.runConformTest( + new String[] { + "X.java", + "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" + + " System.out.println(new X().<String,X>foo(\"SUCCESS\", null));\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // message send parameterized with type not matching parameter bounds + public void test186() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + "\n" + + " <T, U extends String> T foo(T t, U u) {\n" + + " return t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " System.out.println(new X().<String, X>foo(\"SUCCESS\", null));\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " <T, U extends String> T foo(T t, U u) {\n" + + " ^^^^^^\n" + + "The type parameter U should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " System.out.println(new X().<String, X>foo(\"SUCCESS\", null));\n" + + " ^^^\n" + + "Bound mismatch: The generic method foo(T, U) of type X is not applicable for the arguments (String, X) since the type X is not a valid substitute for the bounded parameter <U extends String>\n" + + "----------\n"); + } + // invalid type argument arity for parameterized message send + public void test187() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + "\n" + + " <T, U extends String> T foo(T t, U u) {\n" + + " return t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " System.out.println(new X().<String>foo(\"SUCCESS\", null));\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " <T, U extends String> T foo(T t, U u) {\n" + + " ^^^^^^\n" + + "The type parameter U should not be bounded by the final type String. Final types cannot be further extended\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " System.out.println(new X().<String>foo(\"SUCCESS\", null));\n" + + " ^^^\n" + + "Incorrect number of type arguments for generic method <T, U>foo(T, U) of type X; it cannot be parameterized with arguments <String>\n" + + "----------\n"); + } + // parameterized invocation of non generic method with incorrect argument count + public void test188() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + "\n" + + " void foo() {\n" + + " return;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " System.out.println(new X().<String>foo(\"SUCCESS\", null));\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " System.out.println(new X().<String>foo(\"SUCCESS\", null));\n" + + " ^^^\n" + + "The method foo() in the type X is not applicable for the arguments (String, null)\n" + + "----------\n"); + } + // parameterized invocation of non generic method + public void test189() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + "\n" + + " void foo() {\n" + + " return;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " System.out.println(new X().<String>foo());\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " System.out.println(new X().<String>foo());\n" + + " ^^^\n" + + "The method foo() of type X is not generic; it cannot be parameterized with arguments <String>\n" + + "----------\n"); + } + // parameterized allocation + public void test190() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public <T> X(T t){\n" + + " System.out.println(t);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new <String>X(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // parameterized allocation - wrong arity + public void test191() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public <T> X(T t){\n" + + " System.out.println(t);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new <String, String>X(\"FAILED\");\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " new <String, String>X(\"FAILED\");\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Incorrect number of type arguments for generic constructor <T>X(T) of type X; it cannot be parameterized with arguments <String, String>\n" + + "----------\n"); + } + // parameterized allocation - non generic target constructor + public void test192() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public X(String t){\n" + + " System.out.println(t);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new <String>X(\"FAILED\");\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " new <String>X(\"FAILED\");\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^\n" + + "The constructor X(String) of type X is not generic; it cannot be parameterized with arguments <String>\n" + + "----------\n"); + } + // parameterized allocation - argument type mismatch + public void test193() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public <T> X(T t){\n" + + " System.out.println(t);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new <String>X(new X(null));\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 6)\n" + + " new <String>X(new X(null));\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "The parameterized constructor <String>X(String) of type X is not applicable for the arguments (X)\n" + + "----------\n"); + } + // parameterized invocation - argument type mismatch + public void test194() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + "\n" + + " <T> void foo(T t) {\n" + + " return;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " System.out.println(new X().<String>foo(new X()));\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 7)\n" + + " System.out.println(new X().<String>foo(new X()));\n" + + " ^^^\n" + + "The parameterized method <String>foo(String) of type X is not applicable for the arguments (X)\n" + + "----------\n"); + } + // parameterized qualified allocation + public void test195() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public class MX {\n" + + " public <T> MX(T t){\n" + + " System.out.println(t);\n" + + " }\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X().new <String>MX(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // parameterized qualified allocation - wrong arity + public void test196() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public class MX {\n" + + " public <T> MX(T t){\n" + + " System.out.println(t);\n" + + " }\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X().new <String,String>MX(\"FAILED\");\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " new X().new <String,String>MX(\"FAILED\");\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Incorrect number of type arguments for generic constructor <T>MX(T) of type X.MX; it cannot be parameterized with arguments <String, String>\n" + + "----------\n"); + } + // parameterized qualified allocation - non generic target constructor + public void test197() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public class MX {\n" + + " public MX(String t){\n" + + " System.out.println(t);\n" + + " }\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X().new <String>MX(\"FAILED\");\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " new X().new <String>MX(\"FAILED\");\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "The constructor MX(String) of type X.MX is not generic; it cannot be parameterized with arguments <String>\n" + + "----------\n"); + } + // parameterized qualified allocation - argument type mismatch + public void test198() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public class MX {\n" + + " public <T>MX(T t){\n" + + " System.out.println(t);\n" + + " }\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X().new <String>MX(new X());\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " new X().new <String>MX(new X());\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "The parameterized constructor <String>MX(String) of type X.MX is not applicable for the arguments (X)\n" + + "----------\n"); + } + // parameterized explicit constructor call + public void test199() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public <T> X(T t){\n" + + " System.out.println(t);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " class Local extends X {\n" + + " Local() {\n" + + " <String>super(\"SUCCESS\");\n" + + " }\n" + + " };\n" + + " new Local();\n" + + " }\n" + + "}\n", + }, + "SUCCESS"); + } + // parameterized explicit constructor call - wrong arity + public void test200() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public <T> X(T t){\n" + + " System.out.println(t);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " class Local extends X {\n" + + " Local() {\n" + + " <String,String>super(\"FAILED\");\n" + + " }\n" + + " };\n" + + " new Local();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " <String,String>super(\"FAILED\");\n" + + " ^^^^^^^^^^^^^^^\n" + + "Incorrect number of type arguments for generic constructor <T>X(T) of type X; it cannot be parameterized with arguments <String, String>\n" + + "----------\n"); + } + // parameterized explicit constructor call - non generic target constructor + public void test201() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public X(String t){\n" + + " System.out.println(t);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " class Local extends X {\n" + + " Local() {\n" + + " <String>super(\"FAILED\");\n" + + " }\n" + + " };\n" + + " new Local();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " <String>super(\"FAILED\");\n" + + " ^^^^^^^^^^^^^^^\n" + + "The constructor X(String) of type X is not generic; it cannot be parameterized with arguments <String>\n" + + "----------\n"); + } + // parameterized explicit constructor call - argument type mismatch + public void test202() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public <T> X(T t){\n" + + " System.out.println(t);\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " class Local extends X {\n" + + " Local() {\n" + + " <String>super(new X(null));\n" + + " }\n" + + " };\n" + + " new Local();\n" + + " }\n" + + "}\n", }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " <String>super(new X(null));\n" + + " ^^^^^^^^^^^^^^^^^^\n" + + "The parameterized constructor <String>X(String) of type X is not applicable for the arguments (X)\n" + + "----------\n"); + } + // 62822 - TODO (kent) reenable when fixed + public void _test203() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " demo.AD ad;\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + "demo/AD.java", + "package demo;\n" + + "public interface AD extends LIST<ADXP> {}\n", + "demo/ADXP.java", + "package demo;\n" + + "public interface ADXP extends BIN {}\n", + "demo/ANY.java", + "package demo;\n" + + "public interface ANY {}\n", + "demo/BL.java", + "package demo;\n" + + "public interface BL extends ANY {}\n", + "demo/LIST.java", + "package demo;\n" + + "public interface LIST<T extends ANY> extends ANY {}\n", + "demo/BIN.java", + "package demo;\n" + + "public interface BIN extends LIST<BL> {}\n", + }, + "SUCCESS"); + } + // 62806 + public void test204() { + this.runConformTest( + new String[] { + "Function.java", + "public abstract class Function<Y,X> {\n" + + " public abstract Y eval(X x);\n" + + "\n" + + "}\n", + "FunctionMappedComparator.java", + "import java.util.*;\n" + + "public class FunctionMappedComparator<Y,X> implements Comparator<X> {\n" + + " /*\n" + + " * \'Function\' is highlighted as an error here - the message is:\n" + + " * The type Function is not generic; it cannot be parameterized with arguments <Y, X>\n" + + " */\n" + + " protected Function<Y,X> function;\n" + + " protected Comparator<Y> comparator;\n" + + " public FunctionMappedComparator(Function<Y,X> function,Comparator<Y> comparator ) {\n" + + " this.function=function;\n" + + " this.comparator=comparator;\n" + + " }\n" + + "\n" + + " public int compare(X x1, X x2) {\n" + + " return comparator.compare(function.eval(x1),function.eval(x2));\n" + + " }\n" + + "}\n", + }, + ""); + } + // 63555 - reference to static type parameter allowed inside type itself + public void test205() { + this.runConformTest( + new String[] { + "Alpha.java", + "public class Alpha {\n" + + " static class Beta<T> {\n" + + " T obj;\n" + + " }\n" + + "}\n", + }, + ""); + } + // 63555 - variation on static method type parameter + public void test206() { + this.runConformTest( + new String[] { + "Alpha.java", + "public class Alpha {\n" + + " static <T> void Beta(T t) {\n" + + " }\n" + + "}\n", + }, + ""); + } + // 63590 - disallow parameterized type in catch/throws clause + public void test207() { + this.runNegativeTest( + new String[] { + "Alpha.java", + "public class Alpha<T> extends RuntimeException {\n" + + " public static void main(String[] args) {\n" + + " new Object() {\n" + + " public void m() throws Alpha<String> {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " }.m();\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in Alpha.java (at line 4)\r\n" + + " public void m() throws Alpha<String> {\r\n" + + " ^^^^^\n" + + "Cannot use the parameterized type Alpha<String> either in catch block or throws clause\n" + + "----------\n"); + } + // 63590 - disallow parameterized type in catch/throws clause + public void test208() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X<T> extends RuntimeException {\n" + + " public static void main(String[] args) {\n" + + " try {\n" + + " throw new X<String>();\n" + + " } catch(X<String> e) {\n" + + " System.out.println(\"X<String>\");\n" + + " } catch(X<X<String>> e) {\n" + + " System.out.println(\"X<X<String>>\");\n" + + " } catch(RuntimeException e) {\n" + + " System.out.println(\"RuntimeException\");\n" + + " }\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 5)\n" + + " } catch(X<String> e) {\n" + + " ^\n" + + "Cannot use the parameterized type X<String> either in catch block or throws clause\n" + + "----------\n" + + "2. ERROR in X.java (at line 7)\n" + + " } catch(X<X<String>> e) {\n" + + " ^\n" + + "Cannot use the parameterized type X<X<String>> either in catch block or throws clause\n" + + "----------\n"); + } + // 63556 - should resolve all occurrences of A to type variable + public void test209() { + this.runConformTest( + new String[] { + "X.java", + "public class X<A,B,C extends java.util.List<A>> {}\n" + + "class X2<A,C extends java.util.List<A>, B> {}\n" + + "class X3<B, A,C extends java.util.List<A>> {}\n", + }, + ""); + } + // 68006 - Invalid modifier after parse + public void test210() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(Map<? super Object, ? extends String> m){\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(Map<? super Object, ? extends String> m){\n" + + " ^^^\n" + + "Map cannot be resolved to a type\n" + + "----------\n"); + } + // test compilation against binaries + public void test211() { + this.runConformTest( + new String[] { + "p/Top.java", + "package p;\n" + + "public interface Top<T> {}\n", + }, + ""); + + this.runConformTest( + new String[] { + "p/Super.java", + "package p;\n" + + "public class Super<T> implements Top<T>{\n" + + " public static void main(String [] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n", + }, + "SUCCESS", + null, + false, // do not flush output + null); + } + // check type variable equivalence + public void test212() { + this.runConformTest( + new String[] { + "X.java", + "import java.util.*;\n" + + "\n" + + "public class X<T>{\n" + + " public static void main(String [] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + " X<T> _recurse; \n" + + " public List<T> toList(){\n" + + " List<T> result = new ArrayList<T>();\n" + + " result.addAll(_recurse.toList()); // should be applicable\n" + + " return result;\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + public void test213() { + this.runConformTest( + new String[] { + "X.java", + "public class X<R,T extends Comparable<T>>{\n" + + " T test;\n" + + " public Comparable<? extends T> getThis(){\n" + + " return test;\n" + + " }\n" + + " public static void main(String [] args) {\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + // 68133 - verify error + public void test214() { + this.runConformTest( + new String[] { + "X.java", + "import java.util.ArrayList;\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " ArrayList<Object> l;\n" + + " switch (args.length) {\n" + + " case 1:\n" + + " l = new ArrayList<Object>();\n" + + " System.out.println(l);\n" + + " break;\n" + + " default:\n" + + " System.out.println(\"SUCCESS\");\n" + + " return;\n" + + " }\n" + + " }\n" + + "}\n" + }, + "SUCCESS"); + } + // 68133 variation + public void test215() { + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " java.util.ArrayList<Object> i; \n" + + " outer: {\n" + + " if (args == null) {\n" + + " i = null;\n" + + " break outer;\n" + + " }\n" + + " return;\n" + + " }\n" + + " System.out.println(i); \n" + + " System.out.println(\"SUCCESS\"); \n" + + " }\n" + + "}\n", + }, + ""); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 2, Locals: 2\n" + + " public static void main(String[] args);\n" + + " 0 aload_0\n" + + " 1 ifnonnull 9\n" + + " 4 aconst_null\n" + + " 5 astore_1\n" + + " 6 goto 10\n" + + " 9 return\n" + + " 10 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 13 aload_1\n" + + " 14 invokevirtual #27 <Method java/io/PrintStream.println(Ljava/lang/Object;)V>\n" + + " 17 getstatic #21 <Field java/lang/System.out Ljava/io/PrintStream;>\n" + + " 20 ldc #29 <String \"SUCCESS\">\n" + + " 22 invokevirtual #32 <Method java/io/PrintStream.println(Ljava/lang/String;)V>\n" + + " 25 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 5]\n" + + " [pc: 4, line: 6]\n" + + " [pc: 6, line: 7]\n" + + " [pc: 9, line: 9]\n" + + " [pc: 10, line: 11]\n" + + " [pc: 17, line: 12]\n" + + " [pc: 25, line: 13]\n" + + " Local variable table:\n" + + " [pc: 0, pc: 26] local: args index: 0 type: [Ljava/lang/String;\n" + + " [pc: 6, pc: 9] local: i index: 1 type: Ljava/util/ArrayList;\n" + + " [pc: 10, pc: 26] local: i index: 1 type: Ljava/util/ArrayList;\n" + + " Local variable type table:\n" + + " [pc: 6, pc: 9] local: i index: 1 type: Ljava/util/ArrayList<Ljava/lang/Object;>;\n" + + " [pc: 10, pc: 26] local: i index: 1 type: Ljava/util/ArrayList<Ljava/lang/Object;>;\n"; + + try { + File f = new File(OUTPUT_DIR + File.separator + "X.class"); + byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); + ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); + String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); + int index = result.indexOf(expectedOutput); + if (index == -1 || expectedOutput.length() == 0) { + System.out.println(Util.displayString(result, 3)); + } + if (index == -1) { + assertEquals("Wrong contents", expectedOutput, result); + } + } catch (org.eclipse.jdt.core.util.ClassFormatException e) { + assertTrue(false); + } catch (IOException e) { + assertTrue(false); + } + } + +} diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java index 1c6266d6f5..16df670e91 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForClass.java @@ -380,7 +380,7 @@ public class JavadocTestForClass extends JavadocTest { + "5. ERROR in test\\X.java (at line 9)\n" + " * @see Unknown Invalid ref: unknown class \n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n"); } @@ -720,12 +720,12 @@ public class JavadocTestForClass extends JavadocTest { + "4. ERROR in X.java (at line 7)\n" + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^^^^\n" - + "Javadoc: Hashtable cannot be resolved or is not a type\n" + + "Javadoc: Hashtable cannot be resolved to a type\n" + "----------\n" + "5. ERROR in X.java (at line 7)\n" + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^\n" - + "Javadoc: Vector cannot be resolved or is not a type\n" + + "Javadoc: Vector cannot be resolved to a type\n" + "----------\n"); } @@ -830,12 +830,12 @@ public class JavadocTestForClass extends JavadocTest { + "3. ERROR in test\\X.java (at line 7)\n" + " * @see Unknown#vm_public() Invalid ref: non-existent class\n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "4. ERROR in test\\X.java (at line 8)\n" + " * @see Visibility.Unknown#vm_public() Invalid ref: non existent inner class\n" + " ^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: Visibility.Unknown cannot be resolved or is not a type\n" + + "Javadoc: Visibility.Unknown 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/JavadocTestForConstructor.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForConstructor.java index 0f7d963371..4e7fb54bd8 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForConstructor.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForConstructor.java @@ -27,7 +27,7 @@ public class JavadocTestForConstructor extends JavadocTest { public static Test suite() { return buildSuite(javadocTestClass()); } - static { // Use this static to initialize testNames (String[]) , testRange (int[2]), testNumbers (int[]) + static { // Use this static to initialize testsNames (String[]) , testsRange (int[2]), testsNumbers (int[]) } protected Map getCompilerOptions() { @@ -149,7 +149,7 @@ public class JavadocTestForConstructor extends JavadocTest { + "3. ERROR in Z.java (at line 7)\n" + " * @throws Unknown\n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "4. ERROR in Z.java (at line 8)\n" + " * @see \"Invalid\n" @@ -159,7 +159,7 @@ public class JavadocTestForConstructor extends JavadocTest { + "5. ERROR in Z.java (at line 9)\n" + " * @see Unknown\n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "6. ERROR in Z.java (at line 10)\n" + " * @param x\n" @@ -322,7 +322,7 @@ public class JavadocTestForConstructor extends JavadocTest { + "5. ERROR in test\\X.java (at line 10)\n" + " * @see Unknown Invalid ref: unknown class \n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n"); } @@ -670,12 +670,12 @@ public class JavadocTestForConstructor extends JavadocTest { + "4. ERROR in X.java (at line 8)\n" + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^^^^\n" - + "Javadoc: Hashtable cannot be resolved or is not a type\n" + + "Javadoc: Hashtable cannot be resolved to a type\n" + "----------\n" + "5. ERROR in X.java (at line 8)\n" + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^\n" - + "Javadoc: Vector cannot be resolved or is not a type\n" + + "Javadoc: Vector cannot be resolved to a type\n" + "----------\n"); } @@ -786,12 +786,12 @@ public class JavadocTestForConstructor extends JavadocTest { + "3. ERROR in test\\X.java (at line 8)\n" + " * @see Unknown#vm_public() Invalid ref: non-existent class\n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "4. ERROR in test\\X.java (at line 9)\n" + " * @see Visibility.Unknown#vm_public() Invalid ref: non existent inner class\n" + " ^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: Visibility.Unknown cannot be resolved or is not a type\n" + + "Javadoc: Visibility.Unknown 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/JavadocTestForField.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForField.java index 54298d1e75..f56f668db9 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForField.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForField.java @@ -399,7 +399,7 @@ public class JavadocTestForField extends JavadocTest { + "5. ERROR in test\\X.java (at line 10)\n" + " * @see Unknown Invalid ref: unknown class \n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n"); } @@ -744,12 +744,12 @@ public class JavadocTestForField extends JavadocTest { + "4. ERROR in X.java (at line 8)\n" + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^^^^\n" - + "Javadoc: Hashtable cannot be resolved or is not a type\n" + + "Javadoc: Hashtable cannot be resolved to a type\n" + "----------\n" + "5. ERROR in X.java (at line 8)\n" + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^\n" - + "Javadoc: Vector cannot be resolved or is not a type\n" + + "Javadoc: Vector cannot be resolved to a type\n" + "----------\n"); } @@ -858,12 +858,12 @@ public class JavadocTestForField extends JavadocTest { + "3. ERROR in test\\X.java (at line 8)\n" + " * @see Unknown#vm_public() Invalid ref: non-existent class\n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "4. ERROR in test\\X.java (at line 9)\n" + " * @see Visibility.Unknown#vm_public() Invalid ref: non existent inner class\n" + " ^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: Visibility.Unknown cannot be resolved or is not a type\n" + + "Javadoc: Visibility.Unknown 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/JavadocTestForInterface.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForInterface.java index 8c3fee7edf..0fd692b6d2 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForInterface.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForInterface.java @@ -357,7 +357,7 @@ public class JavadocTestForInterface extends JavadocTest { + "5. ERROR in test\\IX.java (at line 9)\n" + " * @see Unknown Invalid ref: unknown class \n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n"); } @@ -694,12 +694,12 @@ public class JavadocTestForInterface extends JavadocTest { + "5. ERROR in IX.java (at line 8)\n" + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^^^^\n" - + "Javadoc: Hashtable cannot be resolved or is not a type\n" + + "Javadoc: Hashtable cannot be resolved to a type\n" + "----------\n" + "6. ERROR in IX.java (at line 8)\n" + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^\n" - + "Javadoc: Vector cannot be resolved or is not a type\n" + + "Javadoc: Vector cannot be resolved to a type\n" + "----------\n"); } @@ -794,12 +794,12 @@ public class JavadocTestForInterface extends JavadocTest { + "3. ERROR in test\\IX.java (at line 7)\n" + " * @see Unknown#vm_public() Invalid ref: non-existent class\n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "4. ERROR in test\\IX.java (at line 8)\n" + " * @see Visibility.Unknown#vm_public() Invalid ref: non existent inner class\n" + " ^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: Visibility.Unknown cannot be resolved or is not a type\n" + + "Javadoc: Visibility.Unknown cannot be resolved to a type\n" + "----------\n"); } @@ -1102,7 +1102,7 @@ public class JavadocTestForInterface extends JavadocTest { + "2. ERROR in IX.java (at line 7)\n" + " * @throws Unknown\n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "3. ERROR in IX.java (at line 8)\n" + " * @see \"Invalid\n" @@ -1112,7 +1112,7 @@ public class JavadocTestForInterface extends JavadocTest { + "4. ERROR in IX.java (at line 9)\n" + " * @see Unknown\n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "5. ERROR in IX.java (at line 10)\n" + " * @param x\n" @@ -1316,12 +1316,12 @@ public class JavadocTestForInterface extends JavadocTest { + "1. ERROR in IX.java (at line 3)\n" + " * @throws java.awt.AWTexception Invalid exception: unknown type\n" + " ^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: java.awt.AWTexception cannot be resolved or is not a type\n" + + "Javadoc: java.awt.AWTexception cannot be resolved to a type\n" + "----------\n" + "2. ERROR in IX.java (at line 4)\n" + " * @throws IOException Invalid exception: unknown type\n" + " ^^^^^^^^^^^\n" - + "Javadoc: IOException cannot be resolved or is not a type\n" + + "Javadoc: IOException cannot be resolved to a type\n" + "----------\n"); } @@ -1376,7 +1376,7 @@ public class JavadocTestForInterface extends JavadocTest { + "1. ERROR in IX.java (at line 13)\n" + " InvalidException, \n" + " ^^^^^^^^^^^^^^^^\n" - + "InvalidException cannot be resolved (or is not an exception type) for the method foo\n" + + "InvalidException cannot be resolved to a type\n" + "----------\n" + "2. ERROR in IX.java (at line 14)\n" + " String, \n" @@ -1396,7 +1396,7 @@ public class JavadocTestForInterface extends JavadocTest { + "5. ERROR in IX.java (at line 17)\n" + " IOException;\n" + " ^^^^^^^^^^^\n" - + "IOException cannot be resolved (or is not an exception type) for the method foo\n" + + "IOException cannot be resolved to a type\n" + "----------\n"); } @@ -1619,7 +1619,7 @@ public class JavadocTestForInterface extends JavadocTest { + "5. ERROR in test\\IX.java (at line 10)\n" + " * @see Unknown Invalid ref: unknown class \n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n"); } @@ -1959,12 +1959,12 @@ public class JavadocTestForInterface extends JavadocTest { + "5. ERROR in IX.java (at line 9)\n" + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^^^^\n" - + "Javadoc: Hashtable cannot be resolved or is not a type\n" + + "Javadoc: Hashtable cannot be resolved to a type\n" + "----------\n" + "6. ERROR in IX.java (at line 9)\n" + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^\n" - + "Javadoc: Vector cannot be resolved or is not a type\n" + + "Javadoc: Vector cannot be resolved to a type\n" + "----------\n"); } @@ -2059,12 +2059,12 @@ public class JavadocTestForInterface extends JavadocTest { + "3. ERROR in test\\IX.java (at line 8)\n" + " * @see Unknown#vm_public() Invalid ref: non-existent class\n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "4. ERROR in test\\IX.java (at line 9)\n" + " * @see Visibility.Unknown#vm_public() Invalid ref: non existent inner class\n" + " ^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: Visibility.Unknown cannot be resolved or is not a type\n" + + "Javadoc: Visibility.Unknown 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/JavadocTestForMethod.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java index fe6b50c249..e919557656 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestForMethod.java @@ -26,7 +26,18 @@ public class JavadocTestForMethod extends JavadocTest { public static Test suite() { return buildSuite(javadocTestClass()); } - static { // Use this static to initialize testNames (String[]) , testRange (int[2]), testNumbers (int[]) + + // Use this static initializer to specify subset for tests + // All specified tests which does not belong to the class are skipped... + static { + // Names of tests to run: can be "testBugXXXX" or "BugXXXX") +// testsNames = new String[] { "Bug51529a", "Bug51529b" }; + // Numbers of tests to run: "test<number>" will be run for each number of this array + testsNumbers = new int[] { 117, 124, 132, 137 }; + // Range numbers of tests to run: all tests between "test<first>" and "test<last>" will be run for { first, last } +// testsRange = new int[] { 21, 50 }; +// testsRange = new int[] { -1, 50 }; // run all tests with a number less or equals to 50 +// testsRange = new int[] { 10, -1 }; // run all tests with a number greater or equals to 10 } protected Map getCompilerOptions() { @@ -207,7 +218,7 @@ public class JavadocTestForMethod extends JavadocTest { "2. ERROR in Z.java (at line 7)\n" + " * @throws Unknown\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "3. ERROR in Z.java (at line 8)\n" + " * @see \"Invalid\n" + @@ -217,7 +228,7 @@ public class JavadocTestForMethod extends JavadocTest { "4. ERROR in Z.java (at line 9)\n" + " * @see Unknown\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "5. ERROR in Z.java (at line 10)\n" + " * @param x\n" + @@ -312,7 +323,7 @@ public class JavadocTestForMethod extends JavadocTest { "2. ERROR in Z.java (at line 8)\n" + " * @throws Unknown\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "3. ERROR in Z.java (at line 10)\n" + " * @see \"Invalid\n" + @@ -322,7 +333,7 @@ public class JavadocTestForMethod extends JavadocTest { "4. ERROR in Z.java (at line 11)\n" + " * @see Unknown\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "5. ERROR in Z.java (at line 12)\n" + " * @param x\n" + @@ -416,7 +427,7 @@ public class JavadocTestForMethod extends JavadocTest { "2. ERROR in Z.java (at line 7)\n" + " * @throws Unknown\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "3. ERROR in Z.java (at line 9)\n" + " * @see \"Invalid\n" + @@ -426,7 +437,7 @@ public class JavadocTestForMethod extends JavadocTest { "4. ERROR in Z.java (at line 11)\n" + " * @see Unknown\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "5. ERROR in Z.java (at line 13)\n" + " public String foo(int x) { \n" + @@ -914,7 +925,7 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in X.java (at line 8)\n" + " public void p_foo(inr a, int b, int c) {\n" + " ^^^\n" - + "inr cannot be resolved (or is not a valid type) for the parameter a of the method p_foo\n" + + "inr cannot be resolved to a type\n" + "----------\n"); } @@ -936,17 +947,17 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in X.java (at line 8)\n" + " public void p_foo(inr a, inx b, inq c) {\n" + " ^^^\n" - + "inr cannot be resolved (or is not a valid type) for the parameter a of the method p_foo\n" + + "inr cannot be resolved to a type\n" + "----------\n" + "2. ERROR in X.java (at line 8)\n" + " public void p_foo(inr a, inx b, inq c) {\n" + " ^^^\n" - + "inx cannot be resolved (or is not a valid type) for the parameter b of the method p_foo\n" + + "inx cannot be resolved to a type\n" + "----------\n" + "3. ERROR in X.java (at line 8)\n" + " public void p_foo(inr a, inx b, inq c) {\n" + " ^^^\n" - + "inq cannot be resolved (or is not a valid type) for the parameter c of the method p_foo\n" + + "inq cannot be resolved to a type\n" + "----------\n"); } @@ -1067,12 +1078,12 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in X.java (at line 3)\n" + " * @throws java.awt.AWTexception Invalid exception: unknown type\n" + " ^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: java.awt.AWTexception cannot be resolved or is not a type\n" + + "Javadoc: java.awt.AWTexception cannot be resolved to a type\n" + "----------\n" + "2. ERROR in X.java (at line 4)\n" + " * @throws IOException Invalid exception: unknown type\n" + " ^^^^^^^^^^^\n" - + "Javadoc: IOException cannot be resolved or is not a type\n" + + "Javadoc: IOException cannot be resolved to a type\n" + "----------\n"); } @@ -1121,7 +1132,7 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in X.java (at line 9)\n" + " public void t_foo() throws InvalidException {\n" + " ^^^^^^^^^^^^^^^^\n" - + "InvalidException cannot be resolved (or is not an exception type) for the method t_foo\n" + + "InvalidException cannot be resolved to a type\n" + "----------\n"); } @@ -1141,7 +1152,7 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in X.java (at line 3)\n" + " * @throws IllegalArgumenException._ Invalid exception: invalid class name\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: IllegalArgumenException cannot be resolved or is not a type\n" + + "Javadoc: IllegalArgumenException cannot be resolved to a type\n" + "----------\n" + "2. ERROR in X.java (at line 4)\n" + " * @exception IllegalArgumen.*.Exception.. Invalid exception: invalid class name\n" @@ -1151,7 +1162,7 @@ public class JavadocTestForMethod extends JavadocTest { + "3. ERROR in X.java (at line 6)\n" + " public void t_foo() throws InvalidException {\n" + " ^^^^^^^^^^^^^^^^\n" - + "InvalidException cannot be resolved (or is not an exception type) for the method t_foo\n" + + "InvalidException cannot be resolved to a type\n" + "----------\n"); } @@ -1171,17 +1182,17 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in X.java (at line 3)\n" + " * @throws java.awt.AWTexception Invalid exception: unknown type\n" + " ^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: java.awt.AWTexception cannot be resolved or is not a type\n" + + "Javadoc: java.awt.AWTexception cannot be resolved to a type\n" + "----------\n" + "2. ERROR in X.java (at line 4)\n" + " * @throws IOException Invalid exception: unknown type\n" + " ^^^^^^^^^^^\n" - + "Javadoc: IOException cannot be resolved or is not a type\n" + + "Javadoc: IOException cannot be resolved to a type\n" + "----------\n" + "3. ERROR in X.java (at line 6)\n" + " public void t_foo() throws InvalidException {\n" + " ^^^^^^^^^^^^^^^^\n" - + "InvalidException cannot be resolved (or is not an exception type) for the method t_foo\n" + + "InvalidException cannot be resolved to a type\n" + "----------\n"); } @@ -1212,7 +1223,7 @@ public class JavadocTestForMethod extends JavadocTest { + "3. ERROR in X.java (at line 7)\n" + " public void t_foo() throws InvalidException {\n" + " ^^^^^^^^^^^^^^^^\n" - + "InvalidException cannot be resolved (or is not an exception type) for the method t_foo\n" + + "InvalidException cannot be resolved to a type\n" + "----------\n"); } @@ -1285,12 +1296,12 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in X.java (at line 3)\n" + " * @throws java.awt.AWTexception Invalid exception: unknown type\n" + " ^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: java.awt.AWTexception cannot be resolved or is not a type\n" + + "Javadoc: java.awt.AWTexception cannot be resolved to a type\n" + "----------\n" + "2. ERROR in X.java (at line 4)\n" + " * @throws IOException Invalid exception: unknown type\n" + " ^^^^^^^^^^^\n" - + "Javadoc: IOException cannot be resolved or is not a type\n" + + "Javadoc: IOException cannot be resolved to a type\n" + "----------\n" + "3. ERROR in X.java (at line 6)\n" + " public void t_foo() throws IllegalAccessException {\n" @@ -1327,7 +1338,7 @@ public class JavadocTestForMethod extends JavadocTest { + "3. ERROR in X.java (at line 6)\n" + " * @throws IOException Invalid exception: unknown type\n" + " ^^^^^^^^^^^\n" - + "Javadoc: IOException cannot be resolved or is not a type\n" + + "Javadoc: IOException cannot be resolved to a type\n" + "----------\n" + "4. ERROR in X.java (at line 8)\n" + " public void t_foo() throws IllegalAccessException {\n" @@ -1360,7 +1371,7 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in X.java (at line 12)\n" + " InvalidException, \n" + " ^^^^^^^^^^^^^^^^\n" - + "InvalidException cannot be resolved (or is not an exception type) for the method t_foo\n" + + "InvalidException cannot be resolved to a type\n" + "----------\n" + "2. ERROR in X.java (at line 13)\n" + " String, \n" @@ -1410,7 +1421,7 @@ public class JavadocTestForMethod extends JavadocTest { + "5. ERROR in X.java (at line 9)\n" + " InvalidException, \n" + " ^^^^^^^^^^^^^^^^\n" - + "InvalidException cannot be resolved (or is not an exception type) for the method t_foo\n" + + "InvalidException cannot be resolved to a type\n" + "----------\n" + "6. ERROR in X.java (at line 10)\n" + " String, \n" @@ -1444,12 +1455,12 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in X.java (at line 3)\n" + " * @throws java.awt.AWTexception Invalid exception: unknown type\n" + " ^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: java.awt.AWTexception cannot be resolved or is not a type\n" + + "Javadoc: java.awt.AWTexception cannot be resolved to a type\n" + "----------\n" + "2. ERROR in X.java (at line 4)\n" + " * @throws IOException Invalid exception: unknown type\n" + " ^^^^^^^^^^^\n" - + "Javadoc: IOException cannot be resolved or is not a type\n" + + "Javadoc: IOException cannot be resolved to a type\n" + "----------\n" + "3. ERROR in X.java (at line 7)\n" + " IllegalAccessException, \n" @@ -1459,7 +1470,7 @@ public class JavadocTestForMethod extends JavadocTest { + "4. ERROR in X.java (at line 8)\n" + " InvalidException, \n" + " ^^^^^^^^^^^^^^^^\n" - + "InvalidException cannot be resolved (or is not an exception type) for the method t_foo\n" + + "InvalidException cannot be resolved to a type\n" + "----------\n" + "5. ERROR in X.java (at line 9)\n" + " String, \n" @@ -1509,7 +1520,7 @@ public class JavadocTestForMethod extends JavadocTest { + "4. ERROR in X.java (at line 9)\n" + " InvalidException, \n" + " ^^^^^^^^^^^^^^^^\n" - + "InvalidException cannot be resolved (or is not an exception type) for the method t_foo\n" + + "InvalidException cannot be resolved to a type\n" + "----------\n" + "5. ERROR in X.java (at line 10)\n" + " String, \n" @@ -1550,7 +1561,7 @@ public class JavadocTestForMethod extends JavadocTest { + "2. ERROR in X.java (at line 7)\n" + " InvalidException, \n" + " ^^^^^^^^^^^^^^^^\n" - + "InvalidException cannot be resolved (or is not an exception type) for the method t_foo\n" + + "InvalidException cannot be resolved to a type\n" + "----------\n" + "3. ERROR in X.java (at line 8)\n" + " String, \n" @@ -1570,7 +1581,7 @@ public class JavadocTestForMethod extends JavadocTest { + "6. ERROR in X.java (at line 11)\n" + " IOException, \n" + " ^^^^^^^^^^^\n" - + "IOException cannot be resolved (or is not an exception type) for the method t_foo\n" + + "IOException cannot be resolved to a type\n" + "----------\n" + "7. ERROR in X.java (at line 12)\n" + " IllegalArgumentException\n" @@ -2000,7 +2011,7 @@ public class JavadocTestForMethod extends JavadocTest { + "5. ERROR in test\\X.java (at line 10)\n" + " * @see Unknown Invalid ref: unknown class \n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n"); } @@ -2427,47 +2438,47 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in test\\X.java (at line 6)\n" + " * @see VisibilityPublic#unknown Invalid ref to non existent field of other package class\n" + " ^^^^^^^^^^^^^^^^\n" - + "Javadoc: VisibilityPublic cannot be resolved or is not a type\n" + + "Javadoc: VisibilityPublic cannot be resolved to a type\n" + "----------\n" + "2. ERROR in test\\X.java (at line 7)\n" + " * @see VisibilityPublic#vf_private Invalid ref to not visible field of other package class\n" + " ^^^^^^^^^^^^^^^^\n" - + "Javadoc: VisibilityPublic cannot be resolved or is not a type\n" + + "Javadoc: VisibilityPublic cannot be resolved to a type\n" + "----------\n" + "3. ERROR in test\\X.java (at line 8)\n" + " * @see VisibilityPublic#vf_public Valid ref to not visible field of other package class\n" + " ^^^^^^^^^^^^^^^^\n" - + "Javadoc: VisibilityPublic cannot be resolved or is not a type\n" + + "Javadoc: VisibilityPublic cannot be resolved to a type\n" + "----------\n" + "4. ERROR in test\\X.java (at line 9)\n" + " * @see VisibilityPublic.VpPrivate#unknown Invalid ref to a non visible other package private inner class (non existent field)\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: VisibilityPublic cannot be resolved or is not a type\n" + + "Javadoc: VisibilityPublic cannot be resolved to a type\n" + "----------\n" + "5. ERROR in test\\X.java (at line 10)\n" + " * @see VisibilityPublic.VpPrivate#vf_private Invalid ref to a non visible other package private inner class (non visible field)\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: VisibilityPublic cannot be resolved or is not a type\n" + + "Javadoc: VisibilityPublic cannot be resolved to a type\n" + "----------\n" + "6. ERROR in test\\X.java (at line 11)\n" + " * @see VisibilityPublic.VpPrivate#vf_public Invalid ref to a non visible other package private inner class (public field)\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: VisibilityPublic cannot be resolved or is not a type\n" + + "Javadoc: VisibilityPublic cannot be resolved to a type\n" + "----------\n" + "7. ERROR in test\\X.java (at line 12)\n" + " * @see VisibilityPublic.VpPublic#unknown Invalid ref to non existent field of other package public inner class\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: VisibilityPublic cannot be resolved or is not a type\n" + + "Javadoc: VisibilityPublic cannot be resolved to a type\n" + "----------\n" + "8. ERROR in test\\X.java (at line 13)\n" + " * @see VisibilityPublic.VpPublic#vf_private Invalid ref to not visible field of other package public inner class\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: VisibilityPublic cannot be resolved or is not a type\n" + + "Javadoc: VisibilityPublic cannot be resolved to a type\n" + "----------\n" + "9. ERROR in test\\X.java (at line 14)\n" + " * @see VisibilityPublic.VpPublic#vf_public Valid ref to not visible field of other package public inner class\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: VisibilityPublic cannot be resolved or is not a type\n" + + "Javadoc: VisibilityPublic cannot be resolved to a type\n" + "----------\n"); } @@ -3318,22 +3329,22 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in X.java (at line 6)\n" + " * @see #smr_foo(Hashtable,java.util.Vector,boolean) Invalid reference: unresolved argument type\n" + " ^^^^^^^^^\n" - + "Javadoc: Hashtable cannot be resolved or is not a type\n" + + "Javadoc: Hashtable cannot be resolved to a type\n" + "----------\n" + "2. ERROR in X.java (at line 7)\n" + " * @see #smr_foo(Hashtable,Vector,boolean) Invalid reference: unresolved argument type\n" + " ^^^^^^^^^\n" - + "Javadoc: Hashtable cannot be resolved or is not a type\n" + + "Javadoc: Hashtable cannot be resolved to a type\n" + "----------\n" + "3. ERROR in X.java (at line 8)\n" + " * @see #smr_foo(Hashtable a, java.util.Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^^^^\n" - + "Javadoc: Hashtable cannot be resolved or is not a type\n" + + "Javadoc: Hashtable cannot be resolved to a type\n" + "----------\n" + "4. ERROR in X.java (at line 9)\n" + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" + " ^^^^^^^^^\n" - + "Javadoc: Hashtable cannot be resolved or is not a type\n" + + "Javadoc: Hashtable cannot be resolved to a type\n" + "----------\n" + "5. ERROR in X.java (at line 10)\n" + " * @see #smr_foo(java.util.Hashtable a, java.util.Vector b, boolean) Invalid reference: mixed argument declaration\n" @@ -3531,7 +3542,7 @@ public class JavadocTestForMethod extends JavadocTest { + "3. ERROR in X.java (at line 8)\n" + " * @see X#smr_foo(Hashtable,Vector,boolean) Invalid reference: unresolved argument type\n" + " ^^^^^^^^^\n" - + "Javadoc: Hashtable cannot be resolved or is not a type\n" + + "Javadoc: Hashtable cannot be resolved to a type\n" + "----------\n" + "4. ERROR in X.java (at line 9)\n" + " * @see X#smr_foo(Hashtable,Vector,boolean b) Invalid reference: mixed argument declaration\n" @@ -3782,12 +3793,12 @@ public class JavadocTestForMethod extends JavadocTest { + "3. ERROR in test\\X.java (at line 8)\n" + " * @see Unknown#vm_public() Invalid ref: non-existent class\n" + " ^^^^^^^\n" - + "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "4. ERROR in test\\X.java (at line 9)\n" + " * @see Visibility.Unknown#vm_public() Invalid ref: non existent inner class\n" + " ^^^^^^^^^^^^^^^^^^\n" - + "Javadoc: Visibility.Unknown cannot be resolved or is not a type\n" + + "Javadoc: Visibility.Unknown cannot be resolved to a type\n" + "----------\n"); } @@ -4246,7 +4257,7 @@ public class JavadocTestForMethod extends JavadocTest { + "1. ERROR in test\\X.java (at line 2)\n" + " import test.copy.VisibilityPackage;\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" - + "The imported type test.copy.VisibilityPackage is not visible\n" + + "The type test.copy.VisibilityPackage is not visible\n" + "----------\n" + "2. ERROR in test\\X.java (at line 7)\n" + " * @see VisibilityPackage#vm_private(boolean-) Invalid ref: invalid argument declaration\n" diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java index abed68d08e..8ece122780 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestMixed.java @@ -1505,7 +1505,7 @@ public class JavadocTestMixed extends JavadocTest { "1. ERROR in Y.java (at line 3)\n" + " * @see X#X(STRING)\n" + " ^^^^^^\n" + - "Javadoc: STRING cannot be resolved or is not a type\n" + + "Javadoc: STRING cannot be resolved to a type\n" + "----------\n" + "2. ERROR in Y.java (at line 5)\n" + " public Y(String str) {super(str);}\n" + @@ -1534,7 +1534,7 @@ public class JavadocTestMixed extends JavadocTest { "1. ERROR in Y.java (at line 3)\n" + " * @see X#foo(STRING)\n" + " ^^^^^^\n" + - "Javadoc: STRING cannot be resolved or is not a type\n" + + "Javadoc: STRING cannot be resolved to a type\n" + "----------\n" + "2. ERROR in Y.java (at line 5)\n" + " public void foo(String str) {super.foo(str);}\n" + @@ -1722,17 +1722,17 @@ public class JavadocTestMixed extends JavadocTest { "1. ERROR in X.java (at line 6)\n" + " * 2) {@link CharOperation Label not empty} tag description not empty\n" + " ^^^^^^^^^^^^^\n" + - "Javadoc: CharOperation cannot be resolved or is not a type\n" + + "Javadoc: CharOperation cannot be resolved to a type\n" + "----------\n" + "2. ERROR in X.java (at line 12)\n" + " * 2) {@linkplain CharOperation Label not empty} tag description not empty\n" + " ^^^^^^^^^^^^^\n" + - "Javadoc: CharOperation cannot be resolved or is not a type\n" + + "Javadoc: CharOperation cannot be resolved to a type\n" + "----------\n" + "3. ERROR in X.java (at line 20)\n" + " * 2) {@link CharOperation Label not empty} tag description not empty\n" + " ^^^^^^^^^^^^^\n" + - "Javadoc: CharOperation cannot be resolved or is not a type\n" + + "Javadoc: CharOperation cannot be resolved to a type\n" + "----------\n" ); } @@ -1781,22 +1781,22 @@ public class JavadocTestMixed extends JavadocTest { "1. ERROR in X.java (at line 8)\n" + " * CharOperation Label not empty} tag description not empty\n" + " ^^^^^^^^^^^^^\n" + - "Javadoc: CharOperation cannot be resolved or is not a type\n" + + "Javadoc: CharOperation cannot be resolved to a type\n" + "----------\n" + "2. ERROR in X.java (at line 15)\n" + " * CharOperation}\n" + " ^^^^^^^^^^^^^\n" + - "Javadoc: CharOperation cannot be resolved or is not a type\n" + + "Javadoc: CharOperation cannot be resolved to a type\n" + "----------\n" + "3. ERROR in X.java (at line 18)\n" + " * 2) {@link CharOperation Label not empty} tag description not empty\n" + " ^^^^^^^^^^^^^\n" + - "Javadoc: CharOperation cannot be resolved or is not a type\n" + + "Javadoc: CharOperation cannot be resolved to a type\n" + "----------\n" + "4. ERROR in X.java (at line 32)\n" + " * 2) {@link CharOperation Label not empty} tag description not empty\n" + " ^^^^^^^^^^^^^\n" + - "Javadoc: CharOperation cannot be resolved or is not a type\n" + + "Javadoc: CharOperation cannot be resolved to a type\n" + "----------\n" ); } @@ -1828,7 +1828,7 @@ public class JavadocTestMixed extends JavadocTest { "2. ERROR in X.java (at line 5)\n" + " * 2) {@link Unknown} Cannot be resolved\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "3. ERROR in X.java (at line 6)\n" + " * 3) {@link *} Missing reference\n" + @@ -1983,7 +1983,7 @@ public class JavadocTestMixed extends JavadocTest { "5. ERROR in X.java (at line 16)\n" + " * @see Unknown\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" ); } @@ -2052,7 +2052,7 @@ public class JavadocTestMixed extends JavadocTest { "1. ERROR in X.java (at line 3)\n" + " * @see java.unknown\n" + " ^^^^^^^^^^^^\n" + - "Javadoc: java.unknown cannot be resolved or is not a type\n" + + "Javadoc: java.unknown cannot be resolved to a type\n" + "----------\n" ); } @@ -3017,7 +3017,7 @@ public class JavadocTestMixed extends JavadocTest { "1. ERROR in Test.java (at line 3)\n" + " * @see Local\n" + " ^^^^^\n" + - "Javadoc: Local cannot be resolved or is not a type\n" + + "Javadoc: Local 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/JavadocTestOptions.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestOptions.java index 4b353fde33..68b66299bf 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestOptions.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JavadocTestOptions.java @@ -265,7 +265,7 @@ public class JavadocTestOptions extends JavadocTest { "3. ERROR in Y.java (at line 5)\n" + " * @see X.Unknown\n" + " ^^^^^^^^^\n" + - "Javadoc: X.Unknown cannot be resolved or is not a type\n" + + "Javadoc: X.Unknown cannot be resolved to a type\n" + "----------\n" + "4. ERROR in Y.java (at line 6)\n" + " * @see X#X(int)\n" + @@ -330,7 +330,7 @@ public class JavadocTestOptions extends JavadocTest { "16. ERROR in Y.java (at line 21)\n" + " * @see X.Unknown\n" + " ^^^^^^^^^\n" + - "Javadoc: X.Unknown cannot be resolved or is not a type\n" + + "Javadoc: X.Unknown cannot be resolved to a type\n" + "----------\n" + "17. ERROR in Y.java (at line 22)\n" + " * @see X#X(int)\n" + @@ -395,7 +395,7 @@ public class JavadocTestOptions extends JavadocTest { "29. ERROR in Y.java (at line 37)\n" + " * @see X.Unknown\n" + " ^^^^^^^^^\n" + - "Javadoc: X.Unknown cannot be resolved or is not a type\n" + + "Javadoc: X.Unknown cannot be resolved to a type\n" + "----------\n" + "30. ERROR in Y.java (at line 38)\n" + " * @see X#X(int)\n" + @@ -460,7 +460,7 @@ public class JavadocTestOptions extends JavadocTest { "42. ERROR in Y.java (at line 53)\n" + " * @see X.Unknown\n" + " ^^^^^^^^^\n" + - "Javadoc: X.Unknown cannot be resolved or is not a type\n" + + "Javadoc: X.Unknown cannot be resolved to a type\n" + "----------\n" + "43. ERROR in Y.java (at line 54)\n" + " * @see X#X(int)\n" + @@ -538,7 +538,7 @@ public class JavadocTestOptions extends JavadocTest { // "5. ERROR in Y.java (at line 9)\n" + // " * @throws Unknown\n" + // " ^^^^^^^\n" + -// "Javadoc: Unknown cannot be resolved or is not a type\n" + +// "Javadoc: Unknown cannot be resolved to a type\n" + // "----------\n" + // "6. ERROR in Y.java (at line 10)\n" + // " * @see X.X_dep\n" + @@ -553,7 +553,7 @@ public class JavadocTestOptions extends JavadocTest { // "8. ERROR in Y.java (at line 12)\n" + // " * @see X.Unknown\n" + // " ^^^^^^^^^\n" + -// "Javadoc: X.Unknown cannot be resolved or is not a type\n" + +// "Javadoc: X.Unknown cannot be resolved to a type\n" + // "----------\n" + // "9. ERROR in Y.java (at line 13)\n" + // " * @see X#X(int)\n" + @@ -628,7 +628,7 @@ public class JavadocTestOptions extends JavadocTest { // "23. ERROR in Y.java (at line 32)\n" + // " * @throws Unknown\n" + // " ^^^^^^^\n" + -// "Javadoc: Unknown cannot be resolved or is not a type\n" + +// "Javadoc: Unknown cannot be resolved to a type\n" + // "----------\n" + // "24. ERROR in Y.java (at line 33)\n" + // " * @see X.X_dep\n" + @@ -643,7 +643,7 @@ public class JavadocTestOptions extends JavadocTest { // "26. ERROR in Y.java (at line 35)\n" + // " * @see X.Unknown\n" + // " ^^^^^^^^^\n" + -// "Javadoc: X.Unknown cannot be resolved or is not a type\n" + +// "Javadoc: X.Unknown cannot be resolved to a type\n" + // "----------\n" + // "27. ERROR in Y.java (at line 36)\n" + // " * @see X#X(int)\n" + @@ -718,7 +718,7 @@ public class JavadocTestOptions extends JavadocTest { // "41. ERROR in Y.java (at line 55)\n" + // " * @throws Unknown\n" + // " ^^^^^^^\n" + -// "Javadoc: Unknown cannot be resolved or is not a type\n" + +// "Javadoc: Unknown cannot be resolved to a type\n" + // "----------\n" + // "42. ERROR in Y.java (at line 56)\n" + // " * @see X.X_dep\n" + @@ -733,7 +733,7 @@ public class JavadocTestOptions extends JavadocTest { // "44. ERROR in Y.java (at line 58)\n" + // " * @see X.Unknown\n" + // " ^^^^^^^^^\n" + -// "Javadoc: X.Unknown cannot be resolved or is not a type\n" + +// "Javadoc: X.Unknown cannot be resolved to a type\n" + // "----------\n" + // "45. ERROR in Y.java (at line 59)\n" + // " * @see X#X(int)\n" + @@ -808,7 +808,7 @@ public class JavadocTestOptions extends JavadocTest { // "59. ERROR in Y.java (at line 78)\n" + // " * @throws Unknown\n" + // " ^^^^^^^\n" + -// "Javadoc: Unknown cannot be resolved or is not a type\n" + +// "Javadoc: Unknown cannot be resolved to a type\n" + // "----------\n" + // "60. ERROR in Y.java (at line 79)\n" + // " * @see X.X_dep\n" + @@ -823,7 +823,7 @@ public class JavadocTestOptions extends JavadocTest { // "62. ERROR in Y.java (at line 81)\n" + // " * @see X.Unknown\n" + // " ^^^^^^^^^\n" + -// "Javadoc: X.Unknown cannot be resolved or is not a type\n" + +// "Javadoc: X.Unknown cannot be resolved to a type\n" + // "----------\n" + // "63. ERROR in Y.java (at line 82)\n" + // " * @see X#X(int)\n" + @@ -893,7 +893,7 @@ public class JavadocTestOptions extends JavadocTest { "4. ERROR in Y.java (at line 9)\n" + " * @throws Unknown\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "5. ERROR in Y.java (at line 10)\n" + " * @see X.X_dep\n" + @@ -908,7 +908,7 @@ public class JavadocTestOptions extends JavadocTest { "7. ERROR in Y.java (at line 12)\n" + " * @see X.Unknown\n" + " ^^^^^^^^^\n" + - "Javadoc: X.Unknown cannot be resolved or is not a type\n" + + "Javadoc: X.Unknown cannot be resolved to a type\n" + "----------\n" + "8. ERROR in Y.java (at line 13)\n" + " * @see X#X(int)\n" + @@ -978,7 +978,7 @@ public class JavadocTestOptions extends JavadocTest { "21. ERROR in Y.java (at line 32)\n" + " * @throws Unknown\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "22. ERROR in Y.java (at line 33)\n" + " * @see X.X_dep\n" + @@ -993,7 +993,7 @@ public class JavadocTestOptions extends JavadocTest { "24. ERROR in Y.java (at line 35)\n" + " * @see X.Unknown\n" + " ^^^^^^^^^\n" + - "Javadoc: X.Unknown cannot be resolved or is not a type\n" + + "Javadoc: X.Unknown cannot be resolved to a type\n" + "----------\n" + "25. ERROR in Y.java (at line 36)\n" + " * @see X#X(int)\n" + @@ -1063,7 +1063,7 @@ public class JavadocTestOptions extends JavadocTest { "38. ERROR in Y.java (at line 55)\n" + " * @throws Unknown\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "39. ERROR in Y.java (at line 56)\n" + " * @see X.X_dep\n" + @@ -1078,7 +1078,7 @@ public class JavadocTestOptions extends JavadocTest { "41. ERROR in Y.java (at line 58)\n" + " * @see X.Unknown\n" + " ^^^^^^^^^\n" + - "Javadoc: X.Unknown cannot be resolved or is not a type\n" + + "Javadoc: X.Unknown cannot be resolved to a type\n" + "----------\n" + "42. ERROR in Y.java (at line 59)\n" + " * @see X#X(int)\n" + @@ -1148,7 +1148,7 @@ public class JavadocTestOptions extends JavadocTest { "55. ERROR in Y.java (at line 78)\n" + " * @throws Unknown\n" + " ^^^^^^^\n" + - "Javadoc: Unknown cannot be resolved or is not a type\n" + + "Javadoc: Unknown cannot be resolved to a type\n" + "----------\n" + "56. ERROR in Y.java (at line 79)\n" + " * @see X.X_dep\n" + @@ -1163,7 +1163,7 @@ public class JavadocTestOptions extends JavadocTest { "58. ERROR in Y.java (at line 81)\n" + " * @see X.Unknown\n" + " ^^^^^^^^^\n" + - "Javadoc: X.Unknown cannot be resolved or is not a type\n" + + "Javadoc: X.Unknown cannot be resolved to a type\n" + "----------\n" + "59. ERROR in Y.java (at line 82)\n" + " * @see X#X(int)\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java index fb55d89da4..457e2d4ab3 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java @@ -999,7 +999,7 @@ public void test029() { "1. ERROR in p1\\X.java (at line 4)\n" + " Member field; \n" + " ^^^^^^\n" + - "The type Member is not visible for the field X.field\n" + + "The type Member is not visible\n" + "----------\n"); } /* @@ -1568,6 +1568,42 @@ public void test045() { false, null); } +public void test046() { + this.runNegativeTest( + new String[] { + "X.java", //================================ + "public class X {\n" + + " private XY foo(XY t) {\n" + + " System.out.println(t);\n" + + " return t;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " new X() {\n" + + " void run() {\n" + + " foo(new XY());\n" + + " }\n" + + " }.run();\n" + + " }\n" + + "}\n" + + "class XY {\n" + + " public String toString() {\n" + + " return \"SUCCESS\";\n" + + " }\n" + + "}\n" + }, // TODO (philippe) should eliminate first problem if still used incorrectly + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " private XY foo(XY t) {\n" + + " ^^^^^^^^^\n" + + "The private method foo(XY) from the type X is never used locally\n" + + "----------\n" + + "2. ERROR in X.java (at line 9)\n" + + " foo(new XY());\n" + + " ^^^\n" + + "Cannot make a static reference to the non-static method foo(XY) from the type X\n" + + "----------\n"); +} + public static Class testClass() { return LookupTest.class; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java index 4f83106365..fae5eaf3a8 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java @@ -72,6 +72,11 @@ public static Test suite() { } if ((possibleComplianceLevels & AbstractCompilerTest.F_1_5) != 0) { ArrayList tests_1_5 = (ArrayList)standardTests.clone(); + tests_1_5.add(AssertionTest.class); + tests_1_5.add(Compliance_1_5.class); + tests_1_5.add(GenericTypeTest.class); + tests_1_5.add(ForeachStatementTest.class); + tests_1_5.add(GenericTypeSignatureTest.class); // Reset forgotten subsets tests AbstractRegressionTest.testsNames = null; AbstractRegressionTest.testsNumbers= null; diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java index 458ceec3d0..86648bca50 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java @@ -77,7 +77,7 @@ public static Class testClass() { * in one of its methods. */ public void testExpressionInInnerClass() { - //TODO Syntax error diagnose should be improved in this case. + //TODO (david) Syntax error diagnose should be improved in this case. evaluateWithExpectedProblem(buildCharArray(new String[] { "class X {", " int foo() {", @@ -91,7 +91,7 @@ public void testExpressionInInnerClass() { * Test extra closing curly bracket. */ public void testExtraClosingCurlyBracket() { - //TODO Syntax error diagnose should be improved in this case. + //TODO (david) Syntax error diagnose should be improved in this case. // just an expression with an extra curly bracket evaluateWithExpectedProblem( "1 + 2}".toCharArray(), @@ -212,7 +212,7 @@ public void testProblemInExpression() { public void testProblemInExpression2() { evaluateWithExpectedProblem( "new UnknownClass()".toCharArray(), - newProblem(IProblem.UndefinedType, Error, 4, 15, 1)); // UnknownClass cannot be resolved or is not a type + newProblem(IProblem.UndefinedType, Error, 4, 15, 1)); // UnknownClass cannot be resolved to a type } /** * Test a code snippet which declares a class that has a problem. @@ -224,7 +224,7 @@ public void testProblemInInnerClass() { " Y foo = new Y();", "}", "return new X().foo;"}), - newProblem(IProblem.FieldTypeNotFound, Error, 11, 11, 2)); // The type Y is undefined for the field X.foo + newProblem(IProblem.UndefinedType, Error, 11, 11, 2)); // The type Y is undefined // class declared as part of the last expression evaluateWithExpectedWarningAndDisplayString(buildCharArray(new String[] { @@ -243,7 +243,7 @@ public void testProblemInInnerClass() { * Test a problem in the statement before the returned expression. */ public void testProblemInPreviousStatement() { - //TODO Syntax error diagnose should be improved in this case. + //TODO (david) Syntax error diagnose should be improved in this case. evaluateWithExpectedProblem(buildCharArray(new String[] { "return foo(a a);", "1 + 3"}), diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeVariableTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeVariableTest.java index 11923d0129..be912bc1f8 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeVariableTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeVariableTest.java @@ -118,7 +118,7 @@ public void testUnknownType() { var = context.newVariable("foo.Bar".toCharArray(), "var".toCharArray(), null); evaluateWithExpectedProblem( var, - newProblem(IProblem.FieldTypeNotFound, Error, 0, 6, -1)); // The type foo is undefined for the field GlobalVariables_1.var + newProblem(IProblem.UndefinedType, Error, 0, 2, -1)); // The type foo is undefined } finally { if (var != null) { context.deleteVariable(var); @@ -133,7 +133,7 @@ public void testUnknownType() { var2 = context.newVariable("foo.Bar".toCharArray(), "var".toCharArray(), null); evaluateWithExpectedProblem( var2, - newProblem(IProblem.FieldTypeNotFound, Error, 0, 6, -1)); // The type foo is undefined for the field GlobalVariables_1.var + newProblem(IProblem.UndefinedType, Error, 0, 2, -1)); // The type foo is undefined } finally { if (var1 != null) { context.deleteVariable(var1); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java index 68f12ca15d..b61a183e9a 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/AbstractCompilerTest.java @@ -37,6 +37,21 @@ public class AbstractCompilerTest extends TestCase { protected String docCommentSupport; /* + * Returns the highest compliance level this VM instance can run. + */ + public static String highestComplianceLevels() { + int complianceLevels = AbstractCompilerTest.getPossibleComplianceLevels(); + if ((complianceLevels & AbstractCompilerTest.F_1_5) != 0) { + return COMPLIANCE_1_5; + } + if ((complianceLevels & AbstractCompilerTest.F_1_3) != 0) { + return COMPLIANCE_1_3; + } + // default + return COMPLIANCE_1_4; + } + + /* * Returns the possible compliance levels this VM instance can run. */ public static int getPossibleComplianceLevels() { diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java index 9536b07793..e9ae72147a 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java @@ -12,6 +12,7 @@ package org.eclipse.jdt.core.tests.util; import java.io.*; import java.net.ServerSocket; +import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.zip.ZipEntry; @@ -24,6 +25,7 @@ import org.eclipse.jdt.internal.compiler.IProblemFactory; import org.eclipse.jdt.internal.compiler.batch.CompilationUnit; import org.eclipse.jdt.internal.compiler.batch.FileSystem; import org.eclipse.jdt.internal.compiler.env.INameEnvironment; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; public class Util { public static String OUTPUT_DIRECTORY = "comptest"; @@ -162,6 +164,33 @@ public static void createJar(String[] pathsAndContents, Map options, String jarP compile(pathsAndContents, options, classesPath); zip(classesDir, jarPath); } +public static void create1_5Jar(String[] pathsAndContents, String jarPath) throws IOException { + Map options = new HashMap(); + options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); + options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); + createJar(pathsAndContents, options, jarPath); +} +public static void createFile(String path, String contents) throws IOException { + FileOutputStream output = new FileOutputStream(path); + try { + output.write(contents.getBytes()); + } finally { + output.close(); + } +} +public static void createSourceZip(String[] pathsAndContents, String zipPath) throws IOException { + String sourcesPath = getOutputDirectory() + File.separator + "sources"; + File sourcesDir = new File(sourcesPath); + flushDirectoryContent(sourcesDir); + for (int i = 0, length = pathsAndContents.length; i < length; i+=2) { + String sourcePath = sourcesPath + File.separator + pathsAndContents[i]; + File sourceFile = new File(sourcePath); + sourceFile.getParentFile().mkdirs(); + createFile(sourcePath, pathsAndContents[i+1]); + } + zip(sourcesDir, zipPath); +} /** * Generate a display string from the given String. * @param indent number of tabs are added at the begining of each line. @@ -297,11 +326,12 @@ public static String displayString(String inputString, int indent) { return buffer.toString(); } /** - * Reads the content of the given source file and converts it to a display string. + * Reads the content of the given source file. + * Returns null if enable to read given source file. * - * Example of use: [org.eclipse.jdt.core.tests.util.Util.fileContentToDisplayString("c:/temp/X.java", 0)] + * Example of use: [org.eclipse.jdt.core.tests.util.Util.fileContent("c:/temp/X.java")] */ -public static String fileContentToDisplayString(String sourceFilePath, int indent, boolean independantLineDelimiter) { +public static String fileContent(String sourceFilePath) { File sourceFile = new File(sourceFilePath); if (!sourceFile.exists()) { System.out.println("File " + sourceFilePath + " does not exists."); @@ -336,7 +366,16 @@ public static String fileContentToDisplayString(String sourceFilePath, int inden } catch (IOException e2) { } } - String sourceString = sourceContentBuffer.toString(); + return sourceContentBuffer.toString(); +} + +/** + * Reads the content of the given source file and converts it to a display string. + * + * Example of use: [org.eclipse.jdt.core.tests.util.Util.fileContentToDisplayString("c:/temp/X.java", 0)] +*/ +public static String fileContentToDisplayString(String sourceFilePath, int indent, boolean independantLineDelimiter) { + String sourceString = fileContent(sourceFilePath); if (independantLineDelimiter) { sourceString = convertToIndependantLineDelimiter(sourceString); } |