Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2010-09-26 12:11:55 -0400
committerStephan Herrmann2010-09-26 12:11:55 -0400
commit89968e682e3cf97a09a3ccb9ed7d788d35a41999 (patch)
treeb43a4d46a48f76ed9aae01a32bf5ef9fb12721e9 /org.eclipse.jdt.core.tests.compiler
parentde4efa920bf9ffca77ff1f5855020b496dfe1ea1 (diff)
downloadorg.eclipse.objectteams-89968e682e3cf97a09a3ccb9ed7d788d35a41999.tar.gz
org.eclipse.objectteams-89968e682e3cf97a09a3ccb9ed7d788d35a41999.tar.xz
org.eclipse.objectteams-89968e682e3cf97a09a3ccb9ed7d788d35a41999.zip
Basic merge with v_B14a for 3.7M2
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler')
-rw-r--r--org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java56
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java12
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java60
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumSelectionTest.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/FieldAccessCompletionTest.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java6
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest.java7
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java70
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java4
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java24
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java379
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CharOperationTest.java12
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java48
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java26
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java109
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java310
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java17
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java89
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java59
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java54
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java703
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java382
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InitializationTests.java399
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java429
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java324
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java361
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java202
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java52
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java15
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTransformations.java2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java1939
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java552
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java65
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RunComparableTests.java1
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java28
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuperTypeTest.java175
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java103
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java2
41 files changed, 6416 insertions, 672 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
index 562d95dea..5beb4af8b 100644
--- a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.tests.compiler
-Bundle-Version: 3.3.100
+Bundle-Version: 3.4.0.qualifier
Bundle-ClassPath: jdtcoretestscompiler.jar
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -15,7 +15,7 @@ Export-Package: org.eclipse.jdt.core.tests.compiler.parser,
org.eclipse.jdt.core.tests.util
Require-Bundle: org.junit;bundle-version="3.8.1",
org.eclipse.jdt.debug;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.3.0,4.0.0)",
+ org.eclipse.jdt.core;bundle-version="[3.7.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.test.performance;bundle-version="[3.1.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java
index fcd6a2c09..bb98b0c9a 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java
@@ -12,7 +12,7 @@ package org.eclipse.jdt.core.tests.compiler.parser;
import junit.framework.Test;
-import org.eclipse.jdt.internal.codeassist.complete.*;
+import org.eclipse.jdt.internal.codeassist.complete.InvalidCursorLocation;
public class CompletionParserTest extends AbstractCompletionTest {
public CompletionParserTest(String testName) {
@@ -8634,4 +8634,58 @@ public void test017(){
expectedReplacedSource,
testName);
}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310423
+// To verify that assist node parent is set to the the type declaration
+// when completion is requested after implements in a type declaration.
+public void testBug310423(){
+ String str =
+ "import java.lang.annotation.Annotation;\n" +
+ "interface In {}\n" +
+ "interface Inn {\n" +
+ " interface Inn2 {}\n" +
+ " @interface InAnnot {}\n" +
+ "}\n" +
+ "@interface InnAnnot {}\n"+
+ "public class Test implements In{\n" +
+ "}\n";
+
+ String testName = "";
+ String completeBehind = "In";
+ String expectedCompletionNodeToString = "<CompleteOnInterface:In>";
+ String expectedParentNodeToString =
+ "public class Test implements <CompleteOnInterface:In> {\n" +
+ " public Test() {\n" +
+ " }\n" +
+ "}";
+ String completionIdentifier = "In";
+ String expectedReplacedSource = "In";
+ int cursorLocation = str.lastIndexOf("In") + completeBehind.length() - 1;
+ String expectedUnitDisplayString =
+ "import java.lang.annotation.Annotation;\n" +
+ "interface In {\n" +
+ "}\n" +
+ "interface Inn {\n" +
+ " interface Inn2 {\n" +
+ " }\n" +
+ " @interface InAnnot {\n" +
+ " }\n" +
+ "}\n" +
+ "@interface InnAnnot {\n" +
+ "}\n" +
+ "public class Test implements <CompleteOnInterface:In> {\n" +
+ " public Test() {\n" +
+ " }\n" +
+ "}\n";
+
+ checkDietParse(
+ str.toCharArray(),
+ cursorLocation,
+ expectedCompletionNodeToString,
+ expectedParentNodeToString,
+ expectedUnitDisplayString,
+ completionIdentifier,
+ expectedReplacedSource,
+ testName);
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java
index 781cdd541..5d1a92bc7 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest2.java
@@ -7863,7 +7863,7 @@ public void test0119_Method(){
String expectedCompletionNodeToString = "<CompleteOnName:zzz>";
String expectedParentNodeToString =
"switch (1) {\n" +
- "case <CompleteOnName:zzz> : ;\n" +
+ "case <CompleteOnName:zzz> :\n" +
"}";
String completionIdentifier = "zzz";
String expectedReplacedSource = "zzz";
@@ -7874,7 +7874,7 @@ public void test0119_Method(){
" void foo() {\n" +
" {\n" +
" switch (1) {\n" +
- " case <CompleteOnName:zzz> : ;\n" +
+ " case <CompleteOnName:zzz> :\n" +
" }\n" +
" }\n" +
" }\n" +
@@ -7943,8 +7943,8 @@ public void test0120_Method(){
String expectedCompletionNodeToString = "<CompleteOnName:zzz>";
String expectedParentNodeToString =
"switch (1) {\n" +
- "case Something : ;\n" +
- "case <CompleteOnName:zzz> : ;\n" +
+ "case Something :\n" +
+ "case <CompleteOnName:zzz> :\n" +
"}";
String completionIdentifier = "zzz";
String expectedReplacedSource = "zzz";
@@ -7955,8 +7955,8 @@ public void test0120_Method(){
" void foo() {\n" +
" {\n" +
" switch (1) {\n" +
- " case Something : ;\n" +
- " case <CompleteOnName:zzz> : ;\n" +
+ " case Something :\n" +
+ " case <CompleteOnName:zzz> :\n" +
" }\n" +
" }\n" +
" }\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java
index 70d6dd034..8475e5312 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumCompletionParserTest.java
@@ -116,7 +116,7 @@ public void test0002(){
expectedCompletionNodeToString = "<CompleteOnName:FOO>";
expectedParentNodeToString =
"switch (c) {\n" +
- "case <CompleteOnName:FOO> : ;\n" +
+ "case <CompleteOnName:FOO> :\n" +
"}";
completionIdentifier = "FOO";
expectedReplacedSource = "FOO";
@@ -127,7 +127,7 @@ public void test0002(){
" void foo() {\n" +
" {\n" +
" switch (c) {\n" +
- " case <CompleteOnName:FOO> : ;\n" +
+ " case <CompleteOnName:FOO> :\n" +
" }\n" +
" }\n" +
" }\n" +
@@ -183,8 +183,8 @@ public void test0003(){
expectedCompletionNodeToString = "<CompleteOnName:FOO>";
expectedParentNodeToString =
"switch (c) {\n" +
- "case BAR : ;\n" +
- "case <CompleteOnName:FOO> : ;\n" +
+ "case BAR :\n" +
+ "case <CompleteOnName:FOO> :\n" +
"}";
completionIdentifier = "FOO";
expectedReplacedSource = "FOO";
@@ -195,8 +195,8 @@ public void test0003(){
" void foo() {\n" +
" {\n" +
" switch (c) {\n" +
- " case BAR : ;\n" +
- " case <CompleteOnName:FOO> : ;\n" +
+ " case BAR :\n" +
+ " case <CompleteOnName:FOO> :\n" +
" }\n" +
" }\n" +
" }\n" +
@@ -253,9 +253,9 @@ public void test0004(){
expectedCompletionNodeToString = "<CompleteOnName:FOO>";
expectedParentNodeToString =
"switch (c) {\n" +
- "case BAR : ;\n" +
- " break ;\n" +
- "case <CompleteOnName:FOO> : ;\n" +
+ "case BAR :\n" +
+ " break;\n" +
+ "case <CompleteOnName:FOO> :\n" +
"}";
completionIdentifier = "FOO";
expectedReplacedSource = "FOO";
@@ -266,9 +266,9 @@ public void test0004(){
" void foo() {\n" +
" {\n" +
" switch (c) {\n" +
- " case BAR : ;\n" +
- " break ;\n" +
- " case <CompleteOnName:FOO> : ;\n" +
+ " case BAR :\n" +
+ " break;\n" +
+ " case <CompleteOnName:FOO> :\n" +
" }\n" +
" }\n" +
" }\n" +
@@ -324,9 +324,9 @@ public void test0005(){
expectedCompletionNodeToString = "<CompleteOnName:FOO>";
expectedParentNodeToString =
"switch (c) {\n" +
- "case BAR : ;\n" +
- " break ;\n" +
- "case <CompleteOnName:FOO> : ;\n" +
+ "case BAR :\n" +
+ " break;\n" +
+ "case <CompleteOnName:FOO> :\n" +
"}";
completionIdentifier = "FOO";
expectedReplacedSource = "FOO";
@@ -337,9 +337,9 @@ public void test0005(){
" void foo() {\n" +
" {\n" +
" switch (c) {\n" +
- " case BAR : ;\n" +
- " break ;\n" +
- " case <CompleteOnName:FOO> : ;\n" +
+ " case BAR :\n" +
+ " break;\n" +
+ " case <CompleteOnName:FOO> :\n" +
" }\n" +
" }\n" +
" }\n" +
@@ -395,9 +395,9 @@ public void test0006(){
expectedCompletionNodeToString = "<CompleteOnName:FOO>";
expectedParentNodeToString =
"switch (c) {\n" +
- "case BAR : ;\n" +
- " break ;\n" +
- "case <CompleteOnName:FOO> : ;\n" +
+ "case BAR :\n" +
+ " break;\n" +
+ "case <CompleteOnName:FOO> :\n" +
"}";
completionIdentifier = "FOO";
expectedReplacedSource = "FOO";
@@ -408,9 +408,9 @@ public void test0006(){
" void foo() {\n" +
" {\n" +
" switch (c) {\n" +
- " case BAR : ;\n" +
- " break ;\n" +
- " case <CompleteOnName:FOO> : ;\n" +
+ " case BAR :\n" +
+ " break;\n" +
+ " case <CompleteOnName:FOO> :\n" +
" }\n" +
" }\n" +
" }\n" +
@@ -472,9 +472,9 @@ public void test0007(){
expectedCompletionNodeToString = "<CompleteOnName:FOO>";
expectedParentNodeToString =
"switch (c) {\n" +
- "case BAR : ;\n" +
- " break ;\n" +
- "case <CompleteOnName:FOO> : ;\n" +
+ "case BAR :\n" +
+ " break;\n" +
+ "case <CompleteOnName:FOO> :\n" +
"}";
completionIdentifier = "FOO";
expectedReplacedSource = "FOO";
@@ -486,9 +486,9 @@ public void test0007(){
" {\n" +
" {\n" +
" switch (c) {\n" +
- " case BAR : ;\n" +
- " break ;\n" +
- " case <CompleteOnName:FOO> : ;\n" +
+ " case BAR :\n" +
+ " break;\n" +
+ " case <CompleteOnName:FOO> :\n" +
" }\n" +
" }\n" +
" }\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumSelectionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumSelectionTest.java
index e681a7778..dff77ed6f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumSelectionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/EnumSelectionTest.java
@@ -39,7 +39,7 @@ public void test0001() {
" void foo() {\n" +
" {\n" +
" switch (e) {\n" +
- " case <SelectOnName:A> : ;\n" +
+ " case <SelectOnName:A> :\n" +
" }\n" +
" }\n" +
" }\n" +
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/FieldAccessCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/FieldAccessCompletionTest.java
index 3ecbc9871..d67024592 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/FieldAccessCompletionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/FieldAccessCompletionTest.java
@@ -2095,7 +2095,7 @@ public void testSwitchLabel() {
" int i;\n" +
" {\n" +
" switch (i) {\n" +
- " case <CompleteOnMemberAccess:fred().x> : ;\n" +
+ " case <CompleteOnMemberAccess:fred().x> :\n" +
" }\n" +
" }\n" +
" }\n" +
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
index 080374c8a..f96308332 100644
--- 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
@@ -461,7 +461,11 @@ public void test0015(){
String completeBehind = "Y<Z>.";
int cursorLocation = str.indexOf("Y<Z>.") + completeBehind.length() - 1;
String expectedCompletionNodeToString = "<CompleteOnInterface:Y<Z>.>";
- String expectedParentNodeToString = "<NONE>";
+ String expectedParentNodeToString =
+ "public class X implements I1, <CompleteOnInterface:Y<Z>.> {\n" +
+ " public X() {\n" +
+ " }\n" +
+ "}";
String completionIdentifier = "";
String expectedReplacedSource = "Y<Z>.";
String expectedUnitDisplayString =
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 a9fb59d26..593d08b62 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
@@ -688,12 +688,7 @@ public void test026() {
" ^^\n" +
"Empty block should be documented\n" +
"----------\n" +
- "2. ERROR in X.java (at line 8)\n" +
- " A() {}\n" +
- " ^^\n" +
- "Empty block should be documented\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 9)\n" +
+ "2. ERROR in X.java (at line 9)\n" +
" public void bar() {}\n" +
" ^^\n" +
"Empty block should be documented\n" +
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 1b7e8dc30..34f0a5354 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
@@ -94,6 +94,8 @@ public void acceptFieldReference(char[] fieldName, int sourcePosition) {}
public void acceptImport(
int declarationStart,
int declarationEnd,
+ int nameStart,
+ int nameEnd,
char[][] tokens,
boolean onDemand,
int modifiers) {
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
index 263385a41..760f0ad87 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
@@ -454,4 +454,74 @@ public void test13() {
expectedSyntaxErrorDiagnosis,
testName);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=212713
+public void test14() {
+
+ String s =
+ "public interface Test {\n"+
+ " static { }\n"+
+ " { }\n"+
+ "}\n";
+
+ String expectedSyntaxErrorDiagnosis =
+ "----------\n" +
+ "1. ERROR in <test> (at line 2)\n" +
+ " static { }\n" +
+ " ^^^^\n" +
+ "The interface Test cannot define an initializer\n" +
+ "----------\n" +
+ "2. ERROR in <test> (at line 3)\n" +
+ " { }\n" +
+ " ^^^^^^^^^^^\n" +
+ "The interface Test cannot define an initializer\n" +
+ "----------\n";
+
+ String testName = "<test>";
+ checkParse(
+ s.toCharArray(),
+ expectedSyntaxErrorDiagnosis,
+ testName);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=210419
+public void test15() {
+
+ String s =
+ "package bug;\n" +
+ "public class Test {\n" +
+ " static int X;\n" +
+ " String field = { String str;\n" +
+ " switch (X) {\n" +
+ " case 0:\n" +
+ " str = \"zero\";\n" +
+ " break;\n" +
+ " default:\n" +
+ " str = \"other\";\n" +
+ " break;\n" +
+ " }\n" +
+ " this.field = str;\n" +
+ " };\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(new Test().field);\n" +
+ " }\n" +
+ "}\n";
+
+ String expectedSyntaxErrorDiagnosis =
+ "----------\n" +
+ "1. ERROR in <test> (at line 4)\n" +
+ " String field = { String str;\n" +
+ " ^^^^^^^^\n" +
+ "Syntax error on token(s), misplaced construct(s)\n" +
+ "----------\n" +
+ "2. ERROR in <test> (at line 4)\n" +
+ " String field = { String str;\n" +
+ " ^\n" +
+ "Syntax error on token \";\", { expected after this token\n" +
+ "----------\n";
+
+ String testName = "<test>";
+ checkParse(
+ s.toCharArray(),
+ expectedSyntaxErrorDiagnosis,
+ testName);
+}
}
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 a738f7ed9..c0083f77c 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -42,7 +42,7 @@ public void acceptFieldReference(char[] fieldName, int sourcePosition) {}
/**
* acceptImport method comment.
*/
-public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers) {}
+public void acceptImport(int declarationStart, int declarationEnd, int nameStart, int nameEnd, char[][] tokens, boolean onDemand, int modifiers) {}
/**
* acceptLineSeparatorPositions method comment.
*/
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
index 44a135a1e..321d8309f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java
@@ -44,7 +44,7 @@ public class AnnotationTest extends AbstractComparableTest {
// Static initializer to specify tests subset using TESTS_* static variables
// All specified tests which do not belong to the class are skipped...
static {
-// TESTS_NAMES = new String[] { "test127" };
+// TESTS_NAMES = new String[] { "test293" };
// TESTS_NUMBERS = new int[] { 290, 291 };
// TESTS_RANGE = new int[] { 249, -1 };
}
@@ -9688,4 +9688,26 @@ public void test292() {
options,
null);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316456
+public void test293() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "@A(name = X.QUERY_NAME, query = X.QUERY)\n" +
+ "public class X {\n" +
+ " public static final String QUERY_NAME = \"client.query.name\";\n" +
+ " private static final String QUERY = \"from Client\";\n" +
+ "}\n" +
+ "@interface A{\n" +
+ " String name();\n" +
+ " String query();\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 1)\n" +
+ " @A(name = X.QUERY_NAME, query = X.QUERY)\n" +
+ " ^^^^^\n" +
+ "The field X.QUERY is not visible\n" +
+ "----------\n");
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
index 6aa6070e4..d762c6cb5 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
@@ -3174,6 +3174,7 @@ public void test035(){
this.runConformTest(
new String[] {
"p/Y.java",
+ "package p;\n" +
"public class Y { public static final String S = \"\"; }",
},
"\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "Y.java\""
@@ -11475,4 +11476,382 @@ public void test306(){
"",
true);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
+public void test0307(){
+ String os= System.getProperty("os.name");
+ if (!os.startsWith("Windows")) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=323558
+ return;
+
+ final String javaClassspath = System.getProperty("java.class.path");
+ final String javaUserDir = System.getProperty("user.dir");
+ try {
+ System.setProperty("user.dir", OUTPUT_DIR);
+ this.runConformTest(
+ new String[] {
+ "p/Y.java",
+ "package p;\n" +
+ "public class Y { public class I {}; }",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "Y.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",
+ "",
+ true);
+ System.setProperty("java.class.path", "");
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import p.Y.I;\n" +
+ "public class X {\n" +
+ " I i;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(\"\");\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",// this is not the runtime output
+ "no classpath defined, using default directory instead\n",
+ false);
+ final String userDir = System.getProperty("user.dir");
+ File f = new File(userDir, "X.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete X");
+ }
+ f = new File(userDir, "p" + File.separator + "Y.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete Y");
+ }
+
+ } finally {
+ System.setProperty("java.class.path", javaClassspath);
+ System.setProperty("user.dir", javaUserDir);
+ }
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
+public void test0307a(){
+ String os= System.getProperty("os.name");
+ if (!os.startsWith("Windows")) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=323558
+ return;
+
+ final String javaClassspath = System.getProperty("java.class.path");
+ final String javaUserDir = System.getProperty("user.dir");
+ try {
+ System.setProperty("user.dir", OUTPUT_DIR);
+ this.runConformTest(
+ new String[] {
+ "P/Y.java",
+ "package P;\n" +
+ "public class Y { public class I {}; }",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "P" + File.separator + "Y.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",
+ "",
+ true);
+ System.setProperty("java.class.path", "");
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import p.Y.I;\n" +
+ "public class X {\n" +
+ " I i;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(\"\");\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",// this is not the runtime output
+ "no classpath defined, using default directory instead\n" +
+ "----------\n" +
+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 1)\n" +
+ " import p.Y.I;\n" +
+ " ^^^\n" +
+ "The import p.Y cannot be resolved\n" +
+ "----------\n" +
+ "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
+ " I i;\n" +
+ " ^\n" +
+ "I cannot be resolved to a type\n" +
+ "----------\n" +
+ "2 problems (2 errors)",
+ false);
+ final String userDir = System.getProperty("user.dir");
+ File f = new File(userDir, "X.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete X");
+ }
+ f = new File(userDir, "p" + File.separator + "Y.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete Y");
+ }
+
+ } finally {
+ System.setProperty("java.class.path", javaClassspath);
+ System.setProperty("user.dir", javaUserDir);
+ }
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
+public void test0307b(){
+ String os= System.getProperty("os.name");
+ if (!os.startsWith("Windows")) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=323558
+ return;
+
+ final String javaClassspath = System.getProperty("java.class.path");
+ final String javaUserDir = System.getProperty("user.dir");
+ try {
+ System.setProperty("user.dir", OUTPUT_DIR);
+ this.runConformTest(
+ new String[] {
+ "p/y.java",
+ "package p;\n" +
+ "public class y { public class I {}; }",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "y.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",
+ "",
+ true);
+ System.setProperty("java.class.path", "");
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import p.Y.I;\n" +
+ "public class X {\n" +
+ " I i;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(\"\");\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",// this is not the runtime output
+ "no classpath defined, using default directory instead\n" +
+ "----------\n" +
+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 1)\n" +
+ " import p.Y.I;\n" +
+ " ^^^\n" +
+ "The import p.Y cannot be resolved\n" +
+ "----------\n" +
+ "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
+ " I i;\n" +
+ " ^\n" +
+ "I cannot be resolved to a type\n" +
+ "----------\n" +
+ "2 problems (2 errors)",
+ false);
+ final String userDir = System.getProperty("user.dir");
+ File f = new File(userDir, "X.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete X");
+ }
+ f = new File(userDir, "p" + File.separator + "Y.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete Y");
+ }
+
+ } finally {
+ System.setProperty("java.class.path", javaClassspath);
+ System.setProperty("user.dir", javaUserDir);
+ }
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
+public void test0307c(){
+ String os= System.getProperty("os.name");
+ if (!os.startsWith("Windows")) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=323558
+ return;
+
+ final String javaClassspath = System.getProperty("java.class.path");
+ final String javaUserDir = System.getProperty("user.dir");
+ try {
+ System.setProperty("user.dir", OUTPUT_DIR);
+ this.runConformTest(
+ new String[] {
+ "p/Y.java",
+ "package p;\n" +
+ "public class Y { public class i {}; }",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "Y.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",
+ "",
+ true);
+ System.setProperty("java.class.path", "");
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import p.Y.I;\n" +
+ "public class X {\n" +
+ " I i;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(\"\");\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",// this is not the runtime output
+ "no classpath defined, using default directory instead\n" +
+ "----------\n" +
+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 1)\n" +
+ " import p.Y.I;\n" +
+ " ^^^^^\n" +
+ "The import p.Y.I cannot be resolved\n" +
+ "----------\n" +
+ "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
+ " I i;\n" +
+ " ^\n" +
+ "I cannot be resolved to a type\n" +
+ "----------\n" +
+ "2 problems (2 errors)",
+ false);
+ final String userDir = System.getProperty("user.dir");
+ File f = new File(userDir, "X.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete X");
+ }
+ f = new File(userDir, "p" + File.separator + "Y.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete Y");
+ }
+
+ } finally {
+ System.setProperty("java.class.path", javaClassspath);
+ System.setProperty("user.dir", javaUserDir);
+ }
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
+public void test0307d(){
+ String os= System.getProperty("os.name");
+ if (!os.startsWith("Windows")) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=323558
+ return;
+
+ final String javaClassspath = System.getProperty("java.class.path");
+ final String javaUserDir = System.getProperty("user.dir");
+ try {
+ System.setProperty("user.dir", OUTPUT_DIR);
+ this.runConformTest(
+ new String[] {
+ "p/Y.java",
+ "package P;\n" +
+ "public class Y { public class I {}; }",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "Y.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",
+ "",
+ true);
+ System.setProperty("java.class.path", "");
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import p.Y.I;\n" +
+ "public class X {\n" +
+ " I i;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(\"\");\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",// this is not the runtime output
+ "no classpath defined, using default directory instead\n" +
+ "----------\n" +
+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 1)\n" +
+ " import p.Y.I;\n" +
+ " ^^^\n" +
+ "The import p.Y cannot be resolved\n" +
+ "----------\n" +
+ "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
+ " I i;\n" +
+ " ^\n" +
+ "I cannot be resolved to a type\n" +
+ "----------\n" +
+ "2 problems (2 errors)",
+ false);
+ final String userDir = System.getProperty("user.dir");
+ File f = new File(userDir, "X.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete X");
+ }
+ f = new File(userDir, "p" + File.separator + "Y.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete Y");
+ }
+
+ } finally {
+ System.setProperty("java.class.path", javaClassspath);
+ System.setProperty("user.dir", javaUserDir);
+ }
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115
+public void test0307e(){
+ String os= System.getProperty("os.name");
+ if (!os.startsWith("Windows")) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=323558
+ return;
+
+ final String javaClassspath = System.getProperty("java.class.path");
+ final String javaUserDir = System.getProperty("user.dir");
+ try {
+ System.setProperty("user.dir", OUTPUT_DIR);
+ this.runConformTest(
+ new String[] {
+ "p/Y.java",
+ "package P;\n" +
+ "public class Y { public class I {}; }",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "P" + File.separator + "Y.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",
+ "",
+ true);
+ System.setProperty("java.class.path", "");
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import p.Y.I;\n" +
+ "public class X {\n" +
+ " I i;\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(\"\");\n" +
+ " }\n" +
+ "}",
+ },
+ "\"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -1.5 -g -preserveAllLocals -proceedOnError -referenceInfo ",
+ "",// this is not the runtime output
+ "no classpath defined, using default directory instead\n" +
+ "----------\n" +
+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 1)\n" +
+ " import p.Y.I;\n" +
+ " ^^^\n" +
+ "The import p.Y cannot be resolved\n" +
+ "----------\n" +
+ "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 3)\n" +
+ " I i;\n" +
+ " ^\n" +
+ "I cannot be resolved to a type\n" +
+ "----------\n" +
+ "2 problems (2 errors)",
+ false);
+ final String userDir = System.getProperty("user.dir");
+ File f = new File(userDir, "X.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete X");
+ }
+ f = new File(userDir, "p" + File.separator + "Y.java");
+ if (!Util.delete(f)) {
+ System.out.println("Could not delete Y");
+ }
+
+ } finally {
+ System.setProperty("java.class.path", javaClassspath);
+ System.setProperty("user.dir", javaUserDir);
+ }
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CharOperationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CharOperationTest.java
index ed9f0d215..19e70dfe0 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CharOperationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CharOperationTest.java
@@ -108,6 +108,18 @@ public void test007() {
array2 = new char[] { 'a' , 'b', 'd'};
assertTrue(CharOperation.compareTo(array, array2) < 0);
}
+// test indexOf case sensitive
+public void test008() {
+ char[] array = new char[] { 'a' , 'b', 'c' };
+ char[] array2 = new char[] { 'a' , 'b', 'c', 'a', 'a'};
+ assertTrue(CharOperation.indexOf(array, array2, true, -1) < 0);
+}
+// test indexOf case insensitive
+public void test009() {
+ char[] array = new char[] { 'a' , 'b', 'c' };
+ char[] array2 = new char[] { 'a' , 'b', 'c', 'a', 'a'};
+ assertTrue(CharOperation.indexOf(array, array2, false, -1) < 0);
+}
public static Class testClass() {
return CharOperationTest.class;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
index fae4a8113..2c2c15a5d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
@@ -792,6 +792,7 @@ public void _test011_problem_categories() {
expectedProblemAttributes.put("TooManyFields", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("TooManyLocalVariableSlots", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("TooManyMethods", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
+ expectedProblemAttributes.put("TooManyParametersForSyntheticMethod", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("TooManySyntheticArgumentSlots", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL));
expectedProblemAttributes.put("TypeArgumentMismatch", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
expectedProblemAttributes.put("TypeArgumentsForRawGenericConstructor", new ProblemAttributes(CategorizedProblem.CAT_TYPE));
@@ -1503,6 +1504,7 @@ public void test012_compiler_problems_tuning() {
expectedProblemAttributes.put("TooManyFields", SKIP);
expectedProblemAttributes.put("TooManyLocalVariableSlots", SKIP);
expectedProblemAttributes.put("TooManyMethods", SKIP);
+ expectedProblemAttributes.put("TooManyParametersForSyntheticMethod", SKIP);
expectedProblemAttributes.put("TooManySyntheticArgumentSlots", SKIP);
expectedProblemAttributes.put("TypeArgumentMismatch", SKIP);
expectedProblemAttributes.put("TypeArgumentsForRawGenericConstructor", SKIP);
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 896383b6e..3d490fbd4 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
@@ -38,6 +38,10 @@ protected Map getCompilerOptions() {
options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.ERROR);
options.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED);
}
+ options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE);
return options;
}
public static Test suite() {
@@ -1028,16 +1032,22 @@ public void test032() {
" 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 X2.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 X2.bar is not visible\n" +
+ "----------\n" +
+ "1. ERROR in p\\X.java (at line 4)\n" +
+ " System.out.println(new q.X2().foo); \n" +
+ " ^^^\n" +
+ "The field X2.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 X2.bar is not visible\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. WARNING in q\\X2.java (at line 3)\n" +
+ " protected String foo = \"X2.foo\"; \n" +
+ " ^^^\n" +
+ "The field X2.foo is hiding a field from type X1\n" +
"----------\n");
}
/*
@@ -1670,12 +1680,7 @@ public void test052() {
"}"
},
"----------\n" +
- "1. WARNING in p\\A.java (at line 6)\n" +
- " private int i;\n" +
- " ^\n" +
- "The field A.i is never read locally\n" +
- "----------\n" +
- "2. ERROR in p\\A.java (at line 8)\n" +
+ "1. 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" +
@@ -1993,12 +1998,6 @@ public void test061() {
" Z someField; \n" +
" ^\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" +
- " private static class X {} \n" +
- " ^\n" +
- "The type Y.X is never used locally\n" +
"----------\n");
}
@@ -2868,11 +2867,6 @@ public void test088() {
" this.super();\n" +
" ^^^^\n" +
"Illegal enclosing instance specification for type Object\n" +
- "----------\n" +
- "3. WARNING in p\\X.java (at line 25)\n" +
- " private void a() { System.out.println(\"A\");} \n" +
- " ^^^\n" +
- "The method a() from the type X is never used locally\n" +
"----------\n");
}
/*
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 5edd701db..76d67abf8 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
@@ -1015,16 +1015,22 @@ public void test032() {
" 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 X2.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 X2.bar is not visible\n" +
+ "----------\n" +
+ "1. ERROR in p\\X.java (at line 4)\n" +
+ " System.out.println(new q.X2().foo); \n" +
+ " ^^^\n" +
+ "The field X2.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 X2.bar is not visible\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. WARNING in q\\X2.java (at line 3)\n" +
+ " protected String foo = \"X2.foo\"; \n" +
+ " ^^^\n" +
+ "The field X2.foo is hiding a field from type X1\n" +
"----------\n");
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java
index d2f1c7bee..9bb37974b 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java
@@ -40,6 +40,10 @@ protected Map getCompilerOptions() {
options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.ERROR);
options.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED);
}
+ options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE);
return options;
}
public static Test suite() {
@@ -1032,16 +1036,22 @@ public void test032() {
" 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 X2.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 X2.bar is not visible\n" +
+ "----------\n" +
+ "1. ERROR in p\\X.java (at line 4)\n" +
+ " System.out.println(new q.X2().foo); \n" +
+ " ^^^\n" +
+ "The field X2.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 X2.bar is not visible\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. WARNING in q\\X2.java (at line 3)\n" +
+ " protected String foo = \"X2.foo\"; \n" +
+ " ^^^\n" +
+ "The field X2.foo is hiding a field from type X1\n" +
"----------\n");
}
@@ -1746,12 +1756,7 @@ public void test052() {
"}"
},
"----------\n" +
- "1. WARNING in p\\A.java (at line 6)\n" +
- " private int i;\n" +
- " ^\n" +
- "The field A.i is never read locally\n" +
- "----------\n" +
- "2. ERROR in p\\A.java (at line 8)\n" +
+ "1. 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" +
@@ -1978,26 +1983,11 @@ public void test059() {
"}",
},
// compiler results
- "----------\n" + /* expected compiler log */
- "1. WARNING in p\\FieldQualification.java (at line 5)\n" +
- " class Local {\n" +
- " ^^^^^\n" +
- "The type Local is never used locally\n" +
"----------\n" +
- "2. WARNING in p\\FieldQualification.java (at line 6)\n" +
+ "1. WARNING in p\\FieldQualification.java (at line 6)\n" +
" String field = \"Enclosing field for anonymous type\";\n" +
" ^^^^^\n" +
"The field Local.field is hiding a field from type FieldQualification\n" +
- "----------\n" +
- "3. WARNING in p\\FieldQualification.java (at line 6)\n" +
- " String field = \"Enclosing field for anonymous type\";\n" +
- " ^^^^^\n" +
- "The field Local.field is never read locally\n" +
- "----------\n" +
- "4. WARNING in p\\FieldQualification.java (at line 7)\n" +
- " void foo() {\n" +
- " ^^^^^\n" +
- "The method foo() from the type Local is never used locally\n" +
"----------\n",
// runtime results
null /* do not check output string */,
@@ -2060,17 +2050,12 @@ public void test061() {
"} \n"
},
// compiler results
- "----------\n" + /* expected compiler log */
- "1. WARNING in q\\Y.java (at line 3)\n" +
- " private static class X {} \n" +
- " ^\n" +
- "The type Y.X is never used locally\n" +
- "----------\n",
+ "",
// runtime results
null /* do not check output string */,
null /* do not check error string */,
// javac options
- JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings /* javac test options */);
+ JavacTestOptions.DEFAULT /* javac test options */);
}
/*
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=11435
@@ -2942,27 +2927,7 @@ public void test088() {
" ^^^^\n" +
"Illegal enclosing instance specification for type Object\n" +
"----------\n" +
- "3. WARNING in p\\X.java (at line 25)\n" +
- " private void a() { System.out.println(\"A\");} \n" +
- " ^^^\n" +
- "The method a() from the type X is never used locally\n" +
- "----------\n" +
- "4. WARNING in p\\X.java (at line 31)\n" +
- " Class c = b.getClass();\n" +
- " ^^^^^\n" +
- "Class is a raw type. References to generic type Class<T> should be parameterized\n" +
- "----------\n" +
- "5. WARNING in p\\X.java (at line 32)\n" +
- " Class _getClasses [] = X.class.getClasses(); \n" +
- " ^^^^^\n" +
- "Class is a raw type. References to generic type Class<T> should be parameterized\n" +
- "----------\n" +
- "6. WARNING in p\\X.java (at line 36)\n" +
- " Constructor _getConstructors[] = c.getConstructors(); \n" +
- " ^^^^^^^^^^^\n" +
- "Constructor is a raw type. References to generic type Constructor<T> should be parameterized\n" +
- "----------\n" +
- "7. WARNING in p\\X.java (at line 39)\n" +
+ "3. WARNING in p\\X.java (at line 39)\n" +
" Method _getMethod = c.getMethod(\"d\",null);\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
"The argument of type null should explicitly be cast to Class[] for the invocation of the varargs method getMethod(String, Class...) from type Class. It could alternatively be cast to Class for a varargs invocation\n" +
@@ -2980,32 +2945,12 @@ public void test088() {
" ^^^^\n" +
"Illegal enclosing instance specification for type Object\n" +
"----------\n" +
- "3. WARNING in p\\X.java (at line 25)\n" +
- " private void a() { System.out.println(\"A\");} \n" +
- " ^^^\n" +
- "The method a() from the type X is never used locally\n" +
- "----------\n" +
- "4. WARNING in p\\X.java (at line 31)\n" +
- " Class c = b.getClass();\n" +
- " ^^^^^\n" +
- "Class is a raw type. References to generic type Class<T> should be parameterized\n" +
- "----------\n" +
- "5. WARNING in p\\X.java (at line 32)\n" +
- " Class _getClasses [] = X.class.getClasses(); \n" +
- " ^^^^^\n" +
- "Class is a raw type. References to generic type Class<T> should be parameterized\n" +
- "----------\n" +
- "6. WARNING in p\\X.java (at line 36)\n" +
- " Constructor _getConstructors[] = c.getConstructors(); \n" +
- " ^^^^^^^^^^^\n" +
- "Constructor is a raw type. References to generic type Constructor<T> should be parameterized\n" +
- "----------\n" +
- "7. WARNING in p\\X.java (at line 39)\n" +
+ "3. WARNING in p\\X.java (at line 39)\n" +
" Method _getMethod = c.getMethod(\"d\",null);\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
"The argument of type null should explicitly be cast to Class[] for the invocation of the varargs method getMethod(String, Class...) from type Class. It could alternatively be cast to Class for a varargs invocation\n" +
"----------\n" +
- "8. WARNING in p\\X.java (at line 39)\n" +
+ "4. WARNING in p\\X.java (at line 39)\n" +
" Method _getMethod = c.getMethod(\"d\",null);\n" +
" ^^^^^^^^^^^^^^^^^^^^^\n" +
"Type safety: The method getMethod(String, Class...) belongs to the raw type Class. References to generic type Class<T> should be parameterized\n" +
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 e7878be57..d961b5463 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
@@ -18,6 +18,19 @@ import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.internal.compiler.env.ClassSignature;
+import org.eclipse.jdt.internal.compiler.env.EnumConstantSignature;
+import org.eclipse.jdt.internal.compiler.impl.BooleanConstant;
+import org.eclipse.jdt.internal.compiler.impl.ByteConstant;
+import org.eclipse.jdt.internal.compiler.impl.CharConstant;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.impl.DoubleConstant;
+import org.eclipse.jdt.internal.compiler.impl.FloatConstant;
+import org.eclipse.jdt.internal.compiler.impl.IntConstant;
+import org.eclipse.jdt.internal.compiler.impl.LongConstant;
+import org.eclipse.jdt.internal.compiler.impl.ShortConstant;
+import org.eclipse.jdt.internal.compiler.impl.StringConstant;
+import org.eclipse.jdt.internal.compiler.problem.ShouldNotImplement;
public class ConstantTest extends AbstractRegressionTest {
@@ -1101,6 +1114,303 @@ public void test020() {
"The field notAConstant cannot be declared static; static fields can only be declared in static or top level types\n" +
"----------\n");
}
+public void testAllConstants() {
+ Constant byteConstant = ByteConstant.fromValue((byte) 1);
+ Constant byteConstant2 = ByteConstant.fromValue((byte) 2);
+ Constant byteConstant3 = ByteConstant.fromValue((byte) 1);
+ Constant charConstant = CharConstant.fromValue('c');
+ Constant charConstant2 = CharConstant.fromValue('d');
+ Constant charConstant3 = CharConstant.fromValue('c');
+ Constant booleanConstant = BooleanConstant.fromValue(true);
+ Constant booleanConstant2 = BooleanConstant.fromValue(false);
+ Constant booleanConstant3 = BooleanConstant.fromValue(true);
+ Constant doubleConstant = DoubleConstant.fromValue(1.0);
+ Constant doubleConstant2 = DoubleConstant.fromValue(2.0);
+ Constant doubleConstant3 = DoubleConstant.fromValue(1.0);
+ Constant floatConstant = FloatConstant.fromValue(1.0f);
+ Constant floatConstant2 = FloatConstant.fromValue(2.0f);
+ Constant floatConstant3 = FloatConstant.fromValue(1.0f);
+ Constant intConstant = IntConstant.fromValue(20);
+ Constant intConstant2 = IntConstant.fromValue(30);
+ Constant intConstant3 = IntConstant.fromValue(20);
+ Constant longConstant = LongConstant.fromValue(3L);
+ Constant longConstant2 = LongConstant.fromValue(4L);
+ Constant longConstant3 = LongConstant.fromValue(3L);
+ Constant shortConstant = ShortConstant.fromValue((short) 4);
+ Constant shortConstant2 = ShortConstant.fromValue((short) 3);
+ Constant shortConstant3 = ShortConstant.fromValue((short) 4);
+ Constant stringConstant = StringConstant.fromValue("test");
+ Constant stringConstant2 = StringConstant.fromValue("test2");
+ Constant stringConstant3 = StringConstant.fromValue("test");
+ Constant stringConstant4 = StringConstant.fromValue(null);
+ Constant stringConstant5 = StringConstant.fromValue(null);
+ ClassSignature classSignature = new ClassSignature("java.lang.Object".toCharArray());
+ ClassSignature classSignature2 = new ClassSignature("java.lang.String".toCharArray());
+ ClassSignature classSignature3 = new ClassSignature("java.lang.Object".toCharArray());
+ EnumConstantSignature enumConstantSignature = new EnumConstantSignature("myEnum".toCharArray(), "C".toCharArray());
+ EnumConstantSignature enumConstantSignature2 = new EnumConstantSignature("myEnum".toCharArray(), "A".toCharArray());
+ EnumConstantSignature enumConstantSignature3 = new EnumConstantSignature("myEnum".toCharArray(), "C".toCharArray());
+ EnumConstantSignature enumConstantSignature4 = new EnumConstantSignature("myEnum2".toCharArray(), "A".toCharArray());
+
+ verifyConstantEqualsAndHashcode(byteConstant, byteConstant2, byteConstant3, intConstant);
+ verifyConstantEqualsAndHashcode(charConstant, charConstant2, charConstant3, byteConstant);
+ verifyConstantEqualsAndHashcode(booleanConstant, booleanConstant2, booleanConstant3, byteConstant);
+ verifyConstantEqualsAndHashcode(doubleConstant, doubleConstant2, doubleConstant3, byteConstant);
+ verifyConstantEqualsAndHashcode(floatConstant, floatConstant2, floatConstant3, byteConstant);
+ verifyConstantEqualsAndHashcode(intConstant, intConstant2, intConstant3, stringConstant);
+ verifyConstantEqualsAndHashcode(longConstant, longConstant2, longConstant3, byteConstant);
+ verifyConstantEqualsAndHashcode(shortConstant, shortConstant2, shortConstant3, byteConstant);
+ verifyConstantEqualsAndHashcode(stringConstant, stringConstant2, stringConstant3, byteConstant);
+ verifyConstantEqualsAndHashcode(stringConstant, stringConstant4, stringConstant3, byteConstant);
+ verifyConstantEqualsAndHashcode(stringConstant4, stringConstant3, stringConstant5, byteConstant);
+ verifyConstantEqualsAndHashcode(classSignature, classSignature2, classSignature3, byteConstant);
+ verifyConstantEqualsAndHashcode(enumConstantSignature, enumConstantSignature2, enumConstantSignature3, byteConstant);
+ verifyConstantEqualsAndHashcode(enumConstantSignature, enumConstantSignature4, enumConstantSignature3, byteConstant);
+ assertNotNull(Constant.NotAConstant.toString());
+
+ verifyValues(byteConstant, charConstant, booleanConstant, doubleConstant, floatConstant, intConstant, longConstant, shortConstant, stringConstant);
+ // check equals between to null string constants
+ assertTrue(stringConstant4.equals(stringConstant5));
+}
+private void verifyValues(
+ Constant byteConstant,
+ Constant charConstant,
+ Constant booleanConstant,
+ Constant doubleConstant,
+ Constant floatConstant,
+ Constant intConstant,
+ Constant longConstant,
+ Constant shortConstant,
+ Constant stringConstant) {
+
+ // byteValue()
+ byteConstant.byteValue();
+ charConstant.byteValue();
+ try {
+ booleanConstant.byteValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ doubleConstant.byteValue();
+ floatConstant.byteValue();
+ intConstant.byteValue();
+ longConstant.byteValue();
+ shortConstant.byteValue();
+ try {
+ stringConstant.byteValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+
+ // booleanValue()
+ try {
+ byteConstant.booleanValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ try {
+ charConstant.booleanValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ booleanConstant.booleanValue();
+ try {
+ doubleConstant.booleanValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ try {
+ floatConstant.booleanValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ try {
+ intConstant.booleanValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ try {
+ longConstant.booleanValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ try {
+ shortConstant.booleanValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ try {
+ stringConstant.booleanValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+
+ // charValue()
+ byteConstant.charValue();
+ charConstant.charValue();
+ try {
+ booleanConstant.charValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ doubleConstant.charValue();
+ floatConstant.charValue();
+ intConstant.charValue();
+ longConstant.charValue();
+ shortConstant.charValue();
+ try {
+ stringConstant.charValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+
+ // doubleValue()
+ byteConstant.doubleValue();
+ charConstant.doubleValue();
+ try {
+ booleanConstant.doubleValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ doubleConstant.doubleValue();
+ floatConstant.doubleValue();
+ intConstant.doubleValue();
+ longConstant.doubleValue();
+ shortConstant.doubleValue();
+ try {
+ stringConstant.doubleValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+
+ // floatValue()
+ byteConstant.floatValue();
+ charConstant.floatValue();
+ try {
+ booleanConstant.floatValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ doubleConstant.floatValue();
+ floatConstant.floatValue();
+ intConstant.floatValue();
+ longConstant.floatValue();
+ shortConstant.floatValue();
+ try {
+ stringConstant.floatValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+
+ // intValue()
+ byteConstant.intValue();
+ charConstant.intValue();
+ try {
+ booleanConstant.intValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ doubleConstant.intValue();
+ floatConstant.intValue();
+ intConstant.intValue();
+ longConstant.intValue();
+ shortConstant.intValue();
+ try {
+ stringConstant.intValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+
+ // longValue()
+ byteConstant.longValue();
+ charConstant.longValue();
+ try {
+ booleanConstant.longValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ doubleConstant.longValue();
+ floatConstant.longValue();
+ intConstant.longValue();
+ longConstant.longValue();
+ shortConstant.longValue();
+ try {
+ stringConstant.longValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+
+ // shortValue()
+ byteConstant.shortValue();
+ charConstant.shortValue();
+ try {
+ booleanConstant.shortValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+ doubleConstant.shortValue();
+ floatConstant.shortValue();
+ intConstant.shortValue();
+ longConstant.shortValue();
+ shortConstant.shortValue();
+ try {
+ stringConstant.shortValue();
+ assertTrue(false);
+ } catch(ShouldNotImplement e) {
+ // ignore
+ }
+
+ // stringValue()
+ byteConstant.stringValue();
+ charConstant.stringValue();
+ booleanConstant.stringValue();
+ doubleConstant.stringValue();
+ floatConstant.stringValue();
+ intConstant.stringValue();
+ longConstant.stringValue();
+ shortConstant.stringValue();
+ stringConstant.stringValue();
+}
+private void verifyConstantEqualsAndHashcode(
+ Object o,
+ Object o2,
+ Object o3,
+ Object o4) {
+ assertTrue(o.equals(o));
+ assertTrue(o.equals(o3));
+ assertFalse(o.equals(o2));
+ assertFalse(o.equals(o4));
+ assertFalse(o.equals(null));
+ assertFalse(o.hashCode() == o2.hashCode());
+ assertNotNull(o.toString());
+
+ if (o instanceof Constant) {
+ assertTrue("Not the same values", ((Constant) o).hasSameValue((Constant) o3));
+ assertFalse("Have same values", ((Constant) o).hasSameValue((Constant) o2));
+ assertFalse("Have same values", ((Constant) o).hasSameValue((Constant) o4));
+ }
+}
public static Class testClass() {
return ConstantTest.class;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
index 6ab7f7a44..c53e2dc91 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java
@@ -53,6 +53,9 @@ public class EnumTest extends AbstractComparableTest {
options.put(CompilerOptions.OPTION_ReportMissingJavadocTags, CompilerOptions.ERROR);
options.put(CompilerOptions.OPTION_ReportMissingJavadocTagsVisibility, CompilerOptions.PRIVATE);
options.put(CompilerOptions.OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation, CompilerOptions.DISABLED);
+ options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE);
if (this.reportMissingJavadocComments != null)
options.put(CompilerOptions.OPTION_ReportMissingJavadocComments, this.reportMissingJavadocComments);
return options;
@@ -3755,12 +3758,7 @@ public void test113() {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
- " static int bar;\n" +
- " ^^^\n" +
- "The field new BugDemo(){}.bar is never read locally\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 3)\n" +
+ "1. ERROR in X.java (at line 3)\n" +
" static int bar;\n" +
" ^^^\n" +
"The field bar cannot be declared static; static fields can only be declared in static or top level types\n" +
@@ -6193,12 +6191,7 @@ public void test172() {
"}\n"
},
null, customOptions,
- "----------\n" +
- "1. WARNING in X.java (at line 8)\n" +
- " private enum Complaint { WARNING, ERROR, FATAL_ERROR, PANIC;\n" +
- " ^^^^^^^^^\n" +
- "The type X.Complaint is never used locally\n" +
- "----------\n",
+ "",
"HELLORED", null,
JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings);
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java
index b223f96b9..16aa32234 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FieldAccessTest.java
@@ -679,6 +679,95 @@ public void test022() {
"OLD_FIELD cannot be resolved or is not a field\n" +
"----------\n");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318171
+public void test023() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/A.java",
+ "package p1;\n" +
+ "public abstract class A {\n" +
+ " protected int field;\n" +
+ "}\n",
+ "p2/B.java",
+ "package p2;\n" +
+ "import p1.A;\n" +
+ "public abstract class B extends A {\n" +
+ " protected int field;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in p2\\B.java (at line 4)\n" +
+ " protected int field;\n" +
+ " ^^^^^\n" +
+ "The field B.field is hiding a field from type A\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318171
+public void test024() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/A.java",
+ "package p1;\n" +
+ "public abstract class A extends Super {\n" +
+ "}\n",
+ "p1/Super.java",
+ "package p1;\n" +
+ "public abstract class Super extends SuperSuper {\n" +
+ "}\n",
+ "p1/SuperSuper.java",
+ "package p1;\n" +
+ "public abstract class SuperSuper {\n" +
+ " protected int field;\n" +
+ "}\n",
+ "p2/B.java",
+ "package p2;\n" +
+ "import p1.A;\n" +
+ "public abstract class B extends A {\n" +
+ " protected int field;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in p2\\B.java (at line 4)\n" +
+ " protected int field;\n" +
+ " ^^^^^\n" +
+ "The field B.field is hiding a field from type SuperSuper\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318171
+public void test025() {
+ this.runNegativeTest(
+ new String[] {
+ "p1/A.java",
+ "package p1;\n" +
+ "public abstract class A extends Super {\n" +
+ "}\n",
+ "p1/Super.java",
+ "package p1;\n" +
+ "public abstract class Super extends SuperSuper {\n" +
+ "}\n",
+ "p1/SuperSuper.java",
+ "package p1;\n" +
+ "public abstract class SuperSuper implements Interface{\n" +
+ "}\n",
+ "p1/Interface.java",
+ "package p1;\n" +
+ "public interface Interface{\n" +
+ " int field = 123;\n" +
+ "}\n",
+ "p2/B.java",
+ "package p2;\n" +
+ "import p1.A;\n" +
+ "public abstract class B extends A {\n" +
+ " protected int field;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in p2\\B.java (at line 4)\n" +
+ " protected int field;\n" +
+ " ^^^^^\n" +
+ "The field B.field is hiding a field from type Interface\n" +
+ "----------\n");
+}
public static Class testClass() {
return FieldAccessTest.class;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java
index 12707e9a4..d67fb4670 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java
@@ -2187,6 +2187,65 @@ public void test069() {
true /* shouldFlushOutputDirectory */,
compilerOptions);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322154
+public void test070() {
+ Map compilerOptions = getCompilerOptions();
+ compilerOptions.put(CompilerOptions.OPTION_ReportUnusedObjectAllocation, CompilerOptions.ERROR);
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public final class X {\n" +
+ " private X (){\n" +
+ " boolean flagSet = true;\n" +
+ " Object first = true ? null : \"\"; \n" +
+ " Object second = flagSet || first == null ? null :\n" +
+ " new Object() {};\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 4)\n" +
+ " Object first = true ? null : \"\"; \n" +
+ " ^^\n" +
+ "Dead code\n" +
+ "----------\n",
+ null /* classLibraries */,
+ true /* shouldFlushOutputDirectory */,
+ compilerOptions);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=324154
+public void test071() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.io.*;\n" +
+ "public class X {\n" +
+ " static {\n" +
+ " try {\n" +
+ " while(true) {\n" +
+ " if (true)\n" +
+ " throw new NumberFormatException();\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch(IOException e ) {\n" +
+ " // empty\n" +
+ " } \n" +
+ " } \n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 9)\n" +
+ " throw new IOException();\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Statement unnecessarily nested within else clause. The corresponding then clause does not complete normally\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 9)\n" +
+ " throw new IOException();\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Dead code\n" +
+ "----------\n");
+}
public static Class testClass() {
return FlowAnalysisTest.class;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
index 6f807b2df..13f6920da 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
@@ -2779,6 +2779,60 @@ public void test053() throws Exception {
},
"12345");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321085
+public void test054() throws Exception {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.HashSet;\n" +
+ "import java.util.Set;\n" +
+ "public class X {\n" +
+ " void foo() {\n" +
+ " HashSet<String> x = new HashSet<String>();\n" +
+ " x.add(\"a\");\n" +
+ " HashSet<Integer> y = new HashSet<Integer>();\n" +
+ " y.add(1);\n" +
+ " Set<String> [] OK= new Set[] { x, y };\n" +
+ " for (Set<String> BUG : new Set[] { x, y }) {\n" +
+ " for (String str : BUG)\n" +
+ " System.out.println(str);\n" +
+ " }\n" +
+ " Set [] set = new Set[] { x, y };\n" +
+ " for (Set<String> BUG : set) {\n" +
+ " for (String str : BUG)\n" +
+ " System.out.println(str);\n" +
+ " }\n" +
+ " }\n" +
+ " Zork z;\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 9)\n" +
+ " Set<String> [] OK= new Set[] { x, y };\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Type safety: The expression of type Set[] needs unchecked conversion to conform to Set<String>[]\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 10)\n" +
+ " for (Set<String> BUG : new Set[] { x, y }) {\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Type safety: The expression of type Set[] needs unchecked conversion to conform to Set<String>[]\n" +
+ "----------\n" +
+ "3. WARNING in X.java (at line 14)\n" +
+ " Set [] set = new Set[] { x, y };\n" +
+ " ^^^\n" +
+ "Set is a raw type. References to generic type Set<E> should be parameterized\n" +
+ "----------\n" +
+ "4. WARNING in X.java (at line 15)\n" +
+ " for (Set<String> BUG : set) {\n" +
+ " ^^^\n" +
+ "Type safety: The expression of type Set[] needs unchecked conversion to conform to Set<String>[]\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 20)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
public static Class testClass() {
return ForeachStatementTest.class;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
index 8c3d179cd..80524e3e6 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
@@ -31,8 +31,8 @@ public class GenericTypeTest extends AbstractComparableTest {
// Static initializer to specify tests subset using TESTS_* static variables
// All specified tests which does not belong to the class are skipped...
static {
-// TESTS_NAMES = new String[] { "test1245" };
-// TESTS_NUMBERS = new int[] { 1460 };
+// TESTS_NAMES = new String[] { "test1203c", "test1203d" };
+// TESTS_NUMBERS = new int[] { 1465 };
// TESTS_RANGE = new int[] { 1097, -1 };
}
public static Test suite() {
@@ -44,9 +44,12 @@ public class GenericTypeTest extends AbstractComparableTest {
}
protected Map getCompilerOptions() {
- Map compilerOptions = super.getCompilerOptions();
- compilerOptions.put(CompilerOptions.OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation, CompilerOptions.DISABLED);
- return compilerOptions;
+ Map options = super.getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation, CompilerOptions.DISABLED);
+ options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE);
+ return options;
}
public void test0001() {
@@ -14394,17 +14397,6 @@ public class GenericTypeTest extends AbstractComparableTest {
"}\n"
},
"----------\n" +
- "1. WARNING in test\\Foo.java (at line 4)\n" +
- " private R dosomething(){ return s; } \n" +
- " ^^^^^^^^^^^^^\n" +
- "The method dosomething() from the type Foo<R> is never used locally\n" +
- "----------\n" +
- "2. WARNING in test\\Foo.java (at line 5)\n" +
- " private class Bar {} \n" +
- " ^^^\n" +
- "The type Foo<R>.Bar is never used locally\n" +
- "----------\n" +
- "----------\n" +
"1. ERROR in test02\\FooBar.java (at line 6)\n" +
" f.s = \"foo\"; \n" +
" ^\n" +
@@ -19119,12 +19111,7 @@ X.java:6: name clash: <T#1>foo(Object) and <T#2>foo(Object) have the same erasur
" private static class Bucket extends LinkedList<MPair<K,V>> {}\n" +
" ^\n" +
"Cannot make a static reference to the non-static type V\n" +
- "----------\n" +
- "3. WARNING in X.java (at line 7)\n" +
- " private Bucket[] buckets = new X.Bucket[100];\n" +
- " ^^^^^^^\n" +
- "The field X<K,V>.buckets is never read locally\n" +
- "----------\n");
+ "----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=84973
public void test0613() {
@@ -25833,27 +25820,12 @@ public void test0812() {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 2)\n" +
- " private T t;\n" +
- " ^\n" +
- "The field X<T>.t is never read locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 3)\n" +
- " private X<?>.Inner inner;\n" +
- " ^^^^^\n" +
- "The field X<T>.inner is never read locally\n" +
- "----------\n" +
- "3. WARNING in X.java (at line 4)\n" +
- " private X<?>.Inner[] inners;\n" +
- " ^^^^^^\n" +
- "The field X<T>.inners is never read locally\n" +
- "----------\n" +
- "4. WARNING in X.java (at line 7)\n" +
+ "1. WARNING in X.java (at line 7)\n" +
" this.inner = new X.Inner();\n" +
" ^^^^^^^\n" +
"X.Inner is a raw type. References to generic type X<T>.Inner should be parameterized\n" +
"----------\n" +
- "5. ERROR in X.java (at line 9)\n" +
+ "2. ERROR in X.java (at line 9)\n" +
" Zork z;\n" +
" ^^^^\n" +
"Zork cannot be resolved to a type\n" +
@@ -26021,47 +25993,42 @@ public void test0817() {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 4)\n" +
- " private T t;\n" +
- " ^\n" +
- "The field X<T>.t is never read locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 9)\n" +
+ "1. WARNING in X.java (at line 9)\n" +
" if (this.inner instanceof X<?>.Inner) {}\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"The expression of type X<?>.Inner is already an instance of type X<?>.Inner\n" +
"----------\n" +
- "3. WARNING in X.java (at line 10)\n" +
+ "2. WARNING in X.java (at line 10)\n" +
" if (this.inners instanceof X<?>.Inner[]) {}\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"The expression of type X<?>.Inner[] is already an instance of type X<?>.Inner[]\n" +
"----------\n" +
- "4. WARNING in X.java (at line 14)\n" +
+ "3. WARNING in X.java (at line 14)\n" +
" void foo(List l) {\n" +
" ^^^^\n" +
"List is a raw type. References to generic type List<E> should be parameterized\n" +
"----------\n" +
- "5. WARNING in X.java (at line 15)\n" +
+ "4. WARNING in X.java (at line 15)\n" +
" if (l instanceof List<?>) {}\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"The expression of type List is already an instance of type List<?>\n" +
"----------\n" +
- "6. ERROR in X.java (at line 16)\n" +
+ "5. ERROR in X.java (at line 16)\n" +
" if (l instanceof List<? extends String>) {}\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Cannot perform instanceof check against parameterized type List<? extends String>. Use the form List<?> instead since further generic type information will be erased at runtime\n" +
"----------\n" +
- "7. WARNING in X.java (at line 18)\n" +
+ "6. WARNING in X.java (at line 18)\n" +
" void foo(List[] ls) {\n" +
" ^^^^\n" +
"List is a raw type. References to generic type List<E> should be parameterized\n" +
"----------\n" +
- "8. WARNING in X.java (at line 19)\n" +
+ "7. WARNING in X.java (at line 19)\n" +
" if (ls instanceof List<?>[]) {}\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^\n" +
"The expression of type List[] is already an instance of type List<?>\n" +
"----------\n" +
- "9. ERROR in X.java (at line 20)\n" +
+ "8. ERROR in X.java (at line 20)\n" +
" if (ls instanceof List<? extends String>[]) {}\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Cannot perform instanceof check against parameterized type List<? extends String>[]. Use the form List<?>[] instead since further generic type information will be erased at runtime\n" +
@@ -32553,27 +32520,22 @@ public void test0996() {
"}\n", // =================
},
"----------\n" +
- "1. WARNING in X.java (at line 5)\n" +
- " private T aObject = null;\n" +
- " ^^^^^^^\n" +
- "The field X<T>.aObject is never read locally\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 20)\n" +
+ "1. ERROR in X.java (at line 20)\n" +
" final List<X<?>> l2 = castList(l1, List.class);\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Type mismatch: cannot convert from List<List> to List<X<?>>\n" +
"----------\n" +
- "3. WARNING in X.java (at line 22)\n" +
+ "2. WARNING in X.java (at line 22)\n" +
" List<X> l3 = l2;\n" +
" ^\n" +
"X is a raw type. References to generic type X<T> should be parameterized\n" +
"----------\n" +
- "4. ERROR in X.java (at line 22)\n" +
+ "3. ERROR in X.java (at line 22)\n" +
" List<X> l3 = l2;\n" +
" ^^\n" +
"Type mismatch: cannot convert from List<X<?>> to List<X>\n" +
"----------\n" +
- "5. ERROR in X.java (at line 24)\n" +
+ "4. ERROR in X.java (at line 24)\n" +
" l3 = l4;\n" +
" ^^\n" +
"Type mismatch: cannot convert from List<X<String>> to List<X>\n" +
@@ -36768,30 +36730,10 @@ public void test1088() {
" ^\n" +
"The nested type T is hiding the type parameter T of type Y<T>\n" +
"----------\n" +
- "4. WARNING in X.java (at line 11)\n" +
- " class T {}; // hiding warning\n" +
- " ^\n" +
- "The type T is never used locally\n" +
- "----------\n" +
- "5. WARNING in X.java (at line 12)\n" +
+ "4. WARNING in X.java (at line 12)\n" +
" class Local {};\n" +
" ^^^^^\n" +
"The type Local is hiding the type Y<T>.Local\n" +
- "----------\n" +
- "6. WARNING in X.java (at line 12)\n" +
- " class Local {};\n" +
- " ^^^^^\n" +
- "The type Local is never used locally\n" +
- "----------\n" +
- "7. WARNING in X.java (at line 15)\n" +
- " class T {}; // no hiding warning\n" +
- " ^\n" +
- "The type T is never used locally\n" +
- "----------\n" +
- "8. WARNING in X.java (at line 16)\n" +
- " class Local {}; // no hiding warning\n" +
- " ^^^^^\n" +
- "The type Local is never used locally\n" +
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=165679 - variation
@@ -38112,27 +38054,22 @@ public void test1124() {
"}", // =================
},
"----------\n" +
- "1. WARNING in X.java (at line 7)\n" +
- " private final T theGenericThing;\n" +
- " ^^^^^^^^^^^^^^^\n" +
- "The field X<T>.theGenericThing is never read locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 13)\n" +
+ "1. WARNING in X.java (at line 13)\n" +
" public static class InnerClassThatShowsBug extends X {\n" +
" ^\n" +
"X is a raw type. References to generic type X<T> should be parameterized\n" +
"----------\n" +
- "3. WARNING in X.java (at line 15)\n" +
+ "2. WARNING in X.java (at line 15)\n" +
" super(null);\n" +
" ^^^^^^^^^^^^\n" +
"Type safety: The constructor X(Object) belongs to the raw type X. References to generic type X<T> should be parameterized\n" +
"----------\n" +
- "4. WARNING in X.java (at line 15)\n" +
+ "3. WARNING in X.java (at line 15)\n" +
" super(null);\n" +
" ^^^^^^^^^^^^\n" +
"Access to enclosing constructor X<T>(T) is emulated by a synthetic accessor method\n" +
"----------\n" +
- "5. ERROR in X.java (at line 19)\n" +
+ "4. ERROR in X.java (at line 19)\n" +
" for (Map.Entry<String, String> entry : myMap().entrySet()) {\n" +
" ^^^^^^^^^^^^^^^^^^\n" +
"Type mismatch: cannot convert from element type Object to Map.Entry<String,String>\n" +
@@ -39572,42 +39509,27 @@ public void test1163() {
"}\n", // =================
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
- " private final Object mDependent = new Object() {\n" +
- " ^^^^^^^^^^\n" +
- "The field X<T>.mDependent is never read locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 5)\n" +
+ "1. WARNING in X.java (at line 5)\n" +
" Object o1 = mObj;\n" +
" ^^^^\n" +
"Read access to enclosing field X<T>.mObj is emulated by a synthetic accessor method\n" +
"----------\n" +
- "3. ERROR in X.java (at line 5)\n" +
+ "2. ERROR in X.java (at line 5)\n" +
" Object o1 = mObj;\n" +
" ^^^^\n" +
"The blank final field mObj may not have been initialized\n" +
"----------\n" +
- "4. WARNING in X.java (at line 7)\n" +
- " Object o2 = mObj;\n" +
- " ^^\n" +
- "The field new Object(){}.o2 is never read locally\n" +
- "----------\n" +
- "5. WARNING in X.java (at line 7)\n" +
+ "3. WARNING in X.java (at line 7)\n" +
" Object o2 = mObj;\n" +
" ^^^^\n" +
"Read access to enclosing field X<T>.mObj is emulated by a synthetic accessor method\n" +
"----------\n" +
- "6. ERROR in X.java (at line 7)\n" +
+ "4. ERROR in X.java (at line 7)\n" +
" Object o2 = mObj;\n" +
" ^^^^\n" +
"The blank final field mObj may not have been initialized\n" +
"----------\n" +
- "7. WARNING in X.java (at line 8)\n" +
- " void foo() {\n" +
- " ^^^^^\n" +
- "The method foo() from the type new Object(){} is never used locally\n" +
- "----------\n" +
- "8. WARNING in X.java (at line 9)\n" +
+ "5. WARNING in X.java (at line 9)\n" +
" Object o3 = mObj;\n" +
" ^^^^\n" +
"Read access to enclosing field X<T>.mObj is emulated by a synthetic accessor method\n" +
@@ -39637,62 +39559,47 @@ public void test1164() {
"}\n"
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
- " private final Object mDependent = new Object() {\n" +
- " ^^^^^^^^^^\n" +
- "The field X<T>.mDependent is never read locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 5)\n" +
+ "1. WARNING in X.java (at line 5)\n" +
" Object o1 = mObj;\n" +
" ^^^^\n" +
"Read access to enclosing field X<T>.mObj is emulated by a synthetic accessor method\n" +
"----------\n" +
- "3. ERROR in X.java (at line 5)\n" +
+ "2. ERROR in X.java (at line 5)\n" +
" Object o1 = mObj;\n" +
" ^^^^\n" +
"The blank final field mObj may not have been initialized\n" +
"----------\n" +
- "4. WARNING in X.java (at line 6)\n" +
+ "3. WARNING in X.java (at line 6)\n" +
" mObj = \"1\";\n" +
" ^^^^\n" +
"Write access to enclosing field X<T>.mObj is emulated by a synthetic accessor method\n" +
"----------\n" +
- "5. ERROR in X.java (at line 6)\n" +
+ "4. ERROR in X.java (at line 6)\n" +
" mObj = \"1\";\n" +
" ^^^^\n" +
"The final field X<T>.mObj cannot be assigned\n" +
"----------\n" +
- "6. WARNING in X.java (at line 8)\n" +
- " Object o2 = mObj = \"2\";\n" +
- " ^^\n" +
- "The field new Object(){}.o2 is never read locally\n" +
- "----------\n" +
- "7. WARNING in X.java (at line 8)\n" +
+ "5. WARNING in X.java (at line 8)\n" +
" Object o2 = mObj = \"2\";\n" +
" ^^^^\n" +
"Write access to enclosing field X<T>.mObj is emulated by a synthetic accessor method\n" +
"----------\n" +
- "8. ERROR in X.java (at line 8)\n" +
+ "6. ERROR in X.java (at line 8)\n" +
" Object o2 = mObj = \"2\";\n" +
" ^^^^\n" +
"The final field X<T>.mObj cannot be assigned\n" +
"----------\n" +
- "9. WARNING in X.java (at line 9)\n" +
- " void foo() {\n" +
- " ^^^^^\n" +
- "The method foo() from the type new Object(){} is never used locally\n" +
- "----------\n" +
- "10. WARNING in X.java (at line 10)\n" +
+ "7. WARNING in X.java (at line 10)\n" +
" Object o3 = mObj;\n" +
" ^^^^\n" +
"Read access to enclosing field X<T>.mObj is emulated by a synthetic accessor method\n" +
"----------\n" +
- "11. WARNING in X.java (at line 11)\n" +
+ "8. WARNING in X.java (at line 11)\n" +
" mObj = \"3\";\n" +
" ^^^^\n" +
"Write access to enclosing field X<T>.mObj is emulated by a synthetic accessor method\n" +
"----------\n" +
- "12. ERROR in X.java (at line 11)\n" +
+ "9. ERROR in X.java (at line 11)\n" +
" mObj = \"3\";\n" +
" ^^^^\n" +
"The final field X<T>.mObj cannot be assigned\n" +
@@ -41032,7 +40939,7 @@ public void test1203c() {
String[] sources =
new String[] {
"X.java",
- "class X extends Y {\n" +
+ "public class X extends Y {\n" +
" public static void main(String[] args) {\n" +
" String s = \"\";\n" +
" new X().<String> a(s);\n" + // fails before 7
@@ -41114,7 +41021,7 @@ public void test1203d() {
String[] sources =
new String[] {
"X.java",
- "class X implements I {\n" +
+ "public class X implements I {\n" +
" public static void main(String[] args) {\n" +
" String s = \"\";\n" +
" new X().<String> a(s);\n" + // fails before 7
@@ -41581,12 +41488,7 @@ public void test1216() {
"The type A.P is not visible\n" +
"----------\n" +
"----------\n" +
- "1. WARNING in p\\A.java (at line 9)\n" +
- " public int pval;\n" +
- " ^^^^\n" +
- "The field A.P.pval is never read locally\n" +
- "----------\n" +
- "2. WARNING in p\\A.java (at line 18)\n" +
+ "1. WARNING in p\\A.java (at line 18)\n" +
" this.box.set(new P());\n" +
" ^^^^^^^\n" +
"Access to enclosing constructor A.P() is emulated by a synthetic accessor method\n" +
@@ -42619,11 +42521,6 @@ public void test1245() {
" public class X<T extends Secondary.Private> {\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"The type Secondary.Private is not visible\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 4)\n" +
- " static private class Private {}\n" +
- " ^^^^^^^\n" +
- "The type Secondary.Private is never used locally\n" +
"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=216100 - variation
@@ -46337,7 +46234,7 @@ public void test1356() {
"done");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=185422
-public void _test1357() {
+public void test1357() {
this.runNegativeTest(
new String[] {
"X.java", // =================
@@ -46359,10 +46256,20 @@ public void _test1357() {
" private static interface SecondaryPrivate {}\n" +
"}\n", // =================
},
- "done");
+ "----------\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " public abstract class X implements Map<X.Private,Secondary.SecondaryPrivate> {\n" +
+ " ^^^^^^^^^\n" +
+ "The type X.Private is not visible\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " public abstract class X implements Map<X.Private,Secondary.SecondaryPrivate> {\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The type Secondary.SecondaryPrivate is not visible\n" +
+ "----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=185422 - variation
-public void _test1358() {
+public void test1358() {
this.runNegativeTest(
new String[] {
"X.java", // =================
@@ -46377,7 +46284,12 @@ public void _test1358() {
" Inter.Private field;\n" +
"}\n", // =================
},
- "done");
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " public abstract class X implements List<X.Inter.Private> {\n" +
+ " ^^^^^^^^^^^^^^^\n" +
+ "The type X.Inter.Private is not visible\n" +
+ "----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=185422 - variation
public void test1359() {
@@ -49903,9 +49815,7 @@ public void test1458() {
" getClass().newInstance().protectedInt = 10;\n" +
" }\n" +
" }\n"
- },
- null,
- null); // no specific success output string
+ });
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=295698
public void test1459() {
@@ -50172,4 +50082,487 @@ public void test1460() {
"Cannot perform instanceof check against parameterized type Test<A>.MyEntry. Use the form Test.MyEntry instead since further generic type information will be erased at runtime\n" +
"----------\n");
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=306464
+public void test1461() {
+ this.runNegativeTest(
+ new String[] {
+ "JoinImpl.java",
+ "import javax.persistence.criteria.Expression;\n" +
+ "import javax.persistence.criteria.Fetch;\n" +
+ "import javax.persistence.criteria.From;\n" +
+ "import javax.persistence.criteria.Join;\n" +
+ "import javax.persistence.criteria.JoinType;\n" +
+ "import javax.persistence.criteria.Path;\n" +
+ "import javax.persistence.metamodel.Attribute;\n" +
+ "import javax.persistence.metamodel.Bindable;\n" +
+ "import javax.persistence.metamodel.ManagedType;\n" +
+ "import javax.persistence.metamodel.Metamodel;\n" +
+ "public class JoinImpl<Z, X> extends FromImpl<Z, X> implements Join<Z, X>, Fetch<Z, X> {\n" +
+ "}",
+ "FromImpl.java",
+ "import java.util.ArrayList;\n" +
+ "import java.util.HashSet;\n" +
+ "import java.util.List;\n" +
+ "import java.util.Set;\n" +
+ "import java.util.Stack;\n" +
+ "\n" +
+ "import javax.persistence.criteria.CollectionJoin;\n" +
+ "import javax.persistence.criteria.Expression;\n" +
+ "import javax.persistence.criteria.Fetch;\n" +
+ "import javax.persistence.criteria.From;\n" +
+ "import javax.persistence.criteria.Join;\n" +
+ "import javax.persistence.criteria.JoinType;\n" +
+ "import javax.persistence.criteria.ListJoin;\n" +
+ "import javax.persistence.criteria.MapJoin;\n" +
+ "import javax.persistence.criteria.Path;\n" +
+ "import javax.persistence.criteria.SetJoin;\n" +
+ "import javax.persistence.metamodel.Attribute;\n" +
+ "import javax.persistence.metamodel.Bindable;\n" +
+ "import javax.persistence.metamodel.CollectionAttribute;\n" +
+ "import javax.persistence.metamodel.ListAttribute;\n" +
+ "import javax.persistence.metamodel.ManagedType;\n" +
+ "import javax.persistence.metamodel.MapAttribute;\n" +
+ "import javax.persistence.metamodel.Metamodel;\n" +
+ "import javax.persistence.metamodel.PluralAttribute;\n" +
+ "import javax.persistence.metamodel.SingularAttribute;\n" +
+ "import javax.persistence.metamodel.Attribute.PersistentAttributeType;\n" +
+ "import javax.persistence.metamodel.PluralAttribute.CollectionType;\n" +
+ "import javax.persistence.metamodel.Type.PersistenceType;\n" +
+ "\n" +
+ "import org.eclipse.persistence.internal.helper.ClassConstants;\n" +
+ "import org.eclipse.persistence.internal.localization.ExceptionLocalization;\n" +
+ "\n" +
+ "public class FromImpl<Z, X> extends PathImpl<X> implements javax.persistence.criteria.From<Z, X> {\n" +
+ "\n" +
+ " protected Set<Join<X, ?>> joins;\n" +
+ " \n" +
+ " public Set<Join<X, ?>> getJoins() {\n" +
+ " return joins;\n" +
+ " }\n" +
+ "\n" +
+ " public void findJoins(AbstractQueryImpl query){\n" +
+ " Stack stack = new Stack();\n" +
+ " stack.push(this);\n" +
+ " while(!stack.isEmpty()){\n" +
+ " FromImpl currentJoin = (FromImpl) stack.pop();\n" +
+ " stack.addAll(currentJoin.getJoins());\n" +
+ " if (currentJoin.isLeaf){\n" +
+ " query.addJoin(currentJoin);\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in JoinImpl.java (at line 1)\n" +
+ " import javax.persistence.criteria.Expression;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "2. ERROR in JoinImpl.java (at line 2)\n" +
+ " import javax.persistence.criteria.Fetch;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "3. ERROR in JoinImpl.java (at line 3)\n" +
+ " import javax.persistence.criteria.From;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "4. ERROR in JoinImpl.java (at line 4)\n" +
+ " import javax.persistence.criteria.Join;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "5. ERROR in JoinImpl.java (at line 5)\n" +
+ " import javax.persistence.criteria.JoinType;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "6. ERROR in JoinImpl.java (at line 6)\n" +
+ " import javax.persistence.criteria.Path;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "7. ERROR in JoinImpl.java (at line 7)\n" +
+ " import javax.persistence.metamodel.Attribute;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "8. ERROR in JoinImpl.java (at line 8)\n" +
+ " import javax.persistence.metamodel.Bindable;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "9. ERROR in JoinImpl.java (at line 9)\n" +
+ " import javax.persistence.metamodel.ManagedType;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "10. ERROR in JoinImpl.java (at line 10)\n" +
+ " import javax.persistence.metamodel.Metamodel;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "11. ERROR in JoinImpl.java (at line 11)\n" +
+ " public class JoinImpl<Z, X> extends FromImpl<Z, X> implements Join<Z, X>, Fetch<Z, X> {\n" +
+ " ^^^^\n" +
+ "Join cannot be resolved to a type\n" +
+ "----------\n" +
+ "12. ERROR in JoinImpl.java (at line 11)\n" +
+ " public class JoinImpl<Z, X> extends FromImpl<Z, X> implements Join<Z, X>, Fetch<Z, X> {\n" +
+ " ^^^^^\n" +
+ "Fetch cannot be resolved to a type\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. ERROR in FromImpl.java (at line 7)\n" +
+ " import javax.persistence.criteria.CollectionJoin;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "2. ERROR in FromImpl.java (at line 8)\n" +
+ " import javax.persistence.criteria.Expression;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "3. ERROR in FromImpl.java (at line 9)\n" +
+ " import javax.persistence.criteria.Fetch;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "4. ERROR in FromImpl.java (at line 10)\n" +
+ " import javax.persistence.criteria.From;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "5. ERROR in FromImpl.java (at line 11)\n" +
+ " import javax.persistence.criteria.Join;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "6. ERROR in FromImpl.java (at line 12)\n" +
+ " import javax.persistence.criteria.JoinType;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "7. ERROR in FromImpl.java (at line 13)\n" +
+ " import javax.persistence.criteria.ListJoin;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "8. ERROR in FromImpl.java (at line 14)\n" +
+ " import javax.persistence.criteria.MapJoin;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "9. ERROR in FromImpl.java (at line 15)\n" +
+ " import javax.persistence.criteria.Path;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "10. ERROR in FromImpl.java (at line 16)\n" +
+ " import javax.persistence.criteria.SetJoin;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "11. ERROR in FromImpl.java (at line 17)\n" +
+ " import javax.persistence.metamodel.Attribute;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "12. ERROR in FromImpl.java (at line 18)\n" +
+ " import javax.persistence.metamodel.Bindable;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "13. ERROR in FromImpl.java (at line 19)\n" +
+ " import javax.persistence.metamodel.CollectionAttribute;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "14. ERROR in FromImpl.java (at line 20)\n" +
+ " import javax.persistence.metamodel.ListAttribute;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "15. ERROR in FromImpl.java (at line 21)\n" +
+ " import javax.persistence.metamodel.ManagedType;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "16. ERROR in FromImpl.java (at line 22)\n" +
+ " import javax.persistence.metamodel.MapAttribute;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "17. ERROR in FromImpl.java (at line 23)\n" +
+ " import javax.persistence.metamodel.Metamodel;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "18. ERROR in FromImpl.java (at line 24)\n" +
+ " import javax.persistence.metamodel.PluralAttribute;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "19. ERROR in FromImpl.java (at line 25)\n" +
+ " import javax.persistence.metamodel.SingularAttribute;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "20. ERROR in FromImpl.java (at line 26)\n" +
+ " import javax.persistence.metamodel.Attribute.PersistentAttributeType;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "21. ERROR in FromImpl.java (at line 27)\n" +
+ " import javax.persistence.metamodel.PluralAttribute.CollectionType;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "22. ERROR in FromImpl.java (at line 28)\n" +
+ " import javax.persistence.metamodel.Type.PersistenceType;\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The import javax.persistence cannot be resolved\n" +
+ "----------\n" +
+ "23. ERROR in FromImpl.java (at line 30)\n" +
+ " import org.eclipse.persistence.internal.helper.ClassConstants;\n" +
+ " ^^^^^^^^^^^\n" +
+ "The import org.eclipse cannot be resolved\n" +
+ "----------\n" +
+ "24. ERROR in FromImpl.java (at line 31)\n" +
+ " import org.eclipse.persistence.internal.localization.ExceptionLocalization;\n" +
+ " ^^^^^^^^^^^\n" +
+ "The import org.eclipse cannot be resolved\n" +
+ "----------\n" +
+ "25. ERROR in FromImpl.java (at line 33)\n" +
+ " public class FromImpl<Z, X> extends PathImpl<X> implements javax.persistence.criteria.From<Z, X> {\n" +
+ " ^^^^^^^^\n" +
+ "PathImpl cannot be resolved to a type\n" +
+ "----------\n" +
+ "26. ERROR in FromImpl.java (at line 33)\n" +
+ " public class FromImpl<Z, X> extends PathImpl<X> implements javax.persistence.criteria.From<Z, X> {\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "javax.persistence cannot be resolved to a type\n" +
+ "----------\n" +
+ "27. ERROR in FromImpl.java (at line 35)\n" +
+ " protected Set<Join<X, ?>> joins;\n" +
+ " ^^^^\n" +
+ "Join cannot be resolved to a type\n" +
+ "----------\n" +
+ "28. ERROR in FromImpl.java (at line 37)\n" +
+ " public Set<Join<X, ?>> getJoins() {\n" +
+ " ^^^^\n" +
+ "Join cannot be resolved to a type\n" +
+ "----------\n" +
+ "29. ERROR in FromImpl.java (at line 38)\n" +
+ " return joins;\n" +
+ " ^^^^^\n" +
+ "Join cannot be resolved to a type\n" +
+ "----------\n" +
+ "30. ERROR in FromImpl.java (at line 41)\n" +
+ " public void findJoins(AbstractQueryImpl query){\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "AbstractQueryImpl cannot be resolved to a type\n" +
+ "----------\n" +
+ "31. WARNING in FromImpl.java (at line 42)\n" +
+ " Stack stack = new Stack();\n" +
+ " ^^^^^\n" +
+ "Stack is a raw type. References to generic type Stack<E> should be parameterized\n" +
+ "----------\n" +
+ "32. WARNING in FromImpl.java (at line 42)\n" +
+ " Stack stack = new Stack();\n" +
+ " ^^^^^\n" +
+ "Stack is a raw type. References to generic type Stack<E> should be parameterized\n" +
+ "----------\n" +
+ "33. WARNING in FromImpl.java (at line 43)\n" +
+ " stack.push(this);\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Type safety: The method push(Object) belongs to the raw type Stack. References to generic type Stack<E> should be parameterized\n" +
+ "----------\n" +
+ "34. WARNING in FromImpl.java (at line 45)\n" +
+ " FromImpl currentJoin = (FromImpl) stack.pop();\n" +
+ " ^^^^^^^^\n" +
+ "FromImpl is a raw type. References to generic type FromImpl<Z,X> should be parameterized\n" +
+ "----------\n" +
+ "35. WARNING in FromImpl.java (at line 45)\n" +
+ " FromImpl currentJoin = (FromImpl) stack.pop();\n" +
+ " ^^^^^^^^\n" +
+ "FromImpl is a raw type. References to generic type FromImpl<Z,X> should be parameterized\n" +
+ "----------\n" +
+ "36. WARNING in FromImpl.java (at line 46)\n" +
+ " stack.addAll(currentJoin.getJoins());\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Type safety: The method addAll(Collection) belongs to the raw type Vector. References to generic type Vector<E> should be parameterized\n" +
+ "----------\n" +
+ "37. ERROR in FromImpl.java (at line 47)\n" +
+ " if (currentJoin.isLeaf){\n" +
+ " ^^^^^^\n" +
+ "isLeaf cannot be resolved or is not a field\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316889
+public void test1462() {
+ this.runNegativeTest(
+ new String[] {
+ "AnotherClass.java",
+ "public class AnotherClass<I extends IRecursiveInterface<? super I>> {}\n" +
+ "class ImplementingClass implements IRecursiveInterface<IReferencedInterface>, IReferencedInterface {\n" +
+ " private AnotherClass<IReferencedInterface> m_var;\n" +
+ " public void setAnother(final AnotherClass<? extends IReferencedInterface> a) {\n" +
+ " m_var = a;\n" +
+ " }\n" +
+ "}\n" +
+ "interface IRecursiveInterface<I extends IRecursiveInterface<? super I>> {\n" +
+ " void setAnother(final AnotherClass<? extends I> a);\n" +
+ "}\n" +
+ "interface IReferencedInterface extends IRecursiveInterface<IReferencedInterface> {}\n"
+ },
+ "----------\n" +
+ "1. ERROR in AnotherClass.java (at line 5)\n" +
+ " m_var = a;\n" +
+ " ^\n" +
+ "Type mismatch: cannot convert from AnotherClass<capture#1-of ? extends IReferencedInterface> to AnotherClass<IReferencedInterface>\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=314556
+public void test1463() {
+ this.runNegativeTest(
+ new String[] {
+ "BaseType.java",
+ "public interface BaseType {\n" +
+ " BaseType clone() throws CloneNotSupportedException;\n" +
+ "}\n" +
+ "interface SubType<T extends BaseType & java.io.Closeable> extends BaseType {\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in BaseType.java (at line 4)\n" +
+ " interface SubType<T extends BaseType & java.io.Closeable> extends BaseType {\n" +
+ " ^\n" +
+ "The inherited method Object.clone() cannot hide the public abstract method in BaseType\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319603
+public void test1464() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.util.Collection;\n" +
+ "import java.util.Set;\n" +
+ "\n" +
+ "public class X {\n" +
+ "\n" +
+ " public <T> Collection<T> m(Collection<T> a) {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public <T> Set<T> m(Set<T> a) {\n" +
+ " return m(a); \n" +
+ " }\n" +
+ " Zork z;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 12)\n" +
+ " Zork z;\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=320275
+public void _test1465() {
+ this.runConformTest(
+ new String[] {
+ "AbstractSubClass.java",
+ "public abstract class AbstractSubClass extends AbstractClass {}",
+ },
+ new String[] {
+ "AbstractClass.java",
+ "public abstract class AbstractClass implements BaseInterface {}",
+ "AbstractSubClass.java",
+ "public abstract class AbstractSubClass extends AbstractClass {}",
+ "BaseInterface.java",
+ "public interface BaseInterface extends GenericInterface<ConcreteClass> {}",
+ "ConcreteClass.java",
+ "public class ConcreteClass extends AbstractSubClass {}",
+ "GenericInterface.java",
+ "public interface GenericInterface<T> {}",
+ },
+ "");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=320463
+public void test1466() {
+ this.runNegativeTest(
+ new String[] {
+ "Outer.java",
+ "public class Outer<T> {\n"+
+ " class Cell {\n"+
+ " final T value;\n"+
+ " Cell(T value) {\n"+
+ " this.value = value;\n"+
+ " }\n"+
+ " }\n"+
+ " Class<Outer<T>.Cell> cellClass = Cell.class;\n"+
+ " {\n"+
+ " this.cellClass = Cell.class;\n"+
+ " this.cellClass = Outer.Cell.class;\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " Outer<Integer>.Cell intCell = new Outer<Integer>().new Cell(314);\n"+
+ " Outer<String>.Cell strCell = new Outer<String>().cellClass.cast(intCell);\n"+
+ " String val = strCell.value; // ClassCastException\n"+
+ " System.out.println(val);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in Outer.java (at line 8)\n" +
+ " Class<Outer<T>.Cell> cellClass = Cell.class;\n" +
+ " ^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from Class<Outer.Cell> to Class<Outer<T>.Cell>\n" +
+ "----------\n" +
+ "2. ERROR in Outer.java (at line 10)\n" +
+ " this.cellClass = Cell.class;\n" +
+ " ^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from Class<Outer.Cell> to Class<Outer<T>.Cell>\n" +
+ "----------\n" +
+ "3. ERROR in Outer.java (at line 11)\n" +
+ " this.cellClass = Outer.Cell.class;\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from Class<Outer.Cell> to Class<Outer<T>.Cell>\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312076
+public void test1467() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X<T> { \n" +
+ " public abstract static class Base<S extends Base<S>> {\n" +
+ " public Base(Class<S> sClass) {\n" +
+ " Class<S> theClass = sClass;\n" +
+ " System.out.println(theClass);\n" +
+ " System.out.println(sClass);\n" +
+ " }\n" +
+ " }\n" +
+ " public class Arr extends Base<Arr> {\n" +
+ " public Arr() { \n" +
+ " super(Arr.class);\n" +
+ " System.out.println(Arr.class);\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X<Integer> x = new X<Integer>();\n" +
+ " X<Integer>.Arr a = x.new Arr();\n" +
+ " System.out.println(a);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 11)\n" +
+ " super(Arr.class);\n" +
+ " ^^^^^^^^^^^^^^^^^\n" +
+ "The constructor X.Base<X<T>.Arr>(Class<X.Arr>) is undefined\n" +
+ "----------\n");
+}
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
new file mode 100644
index 000000000..155374a27
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest.java
@@ -0,0 +1,382 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+public class GenericsRegressionTest extends AbstractComparableTest {
+
+ public GenericsRegressionTest(String name) {
+ super(name);
+ }
+
+ // Static initializer to specify tests subset using TESTS_* static variables
+ // All specified tests which does not belong to the class are skipped...
+ static {
+// TESTS_NAMES = new String[] { "test322531j" };
+// TESTS_NAMES = new String[] { "test1464" };
+// TESTS_NUMBERS = new int[] { 1465 };
+// TESTS_RANGE = new int[] { 1097, -1 };
+ }
+ public static Test suite() {
+ return buildComparableTestSuite(testClass());
+ }
+
+ public static Class testClass() {
+ return GenericsRegressionTest.class;
+ }
+
+ protected Map getCompilerOptions() {
+ Map compilerOptions = super.getCompilerOptions();
+ compilerOptions.put(CompilerOptions.OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation, CompilerOptions.DISABLED);
+ return compilerOptions;
+ }
+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=322531
+ public void test322531a() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {}\n" +
+ "public class X {\n" +
+ " <T extends I> void main(Class<T> clazz) {\n" +
+ " boolean b = \n" +
+ " clazz == clazz || \n" +
+ " X.class == X.class || \n" +
+ " I.class == I.class || \n" +
+ " clazz == X.class || \n" +
+ " X.class == clazz || \n" +
+ " clazz == I.class || \n" +
+ " I.class == clazz || \n" +
+ " I.class == X.class ||\n" +
+ " X.class == I.class;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 5)\n" +
+ " clazz == clazz || \n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "Comparing identical expressions\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " clazz == X.class || \n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<T> and Class<X>\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 9)\n" +
+ " X.class == clazz || \n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<X> and Class<T>\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 12)\n" +
+ " I.class == X.class ||\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<I> and Class<X>\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 13)\n" +
+ " X.class == I.class;\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<X> and Class<I>\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322531
+ public void test322531b() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {}\n" +
+ "public class X implements I {\n" +
+ " <T extends I> void main(Class<T> clazz) {\n" +
+ " boolean b = \n" +
+ " clazz == clazz || \n" +
+ " X.class == X.class || \n" +
+ " I.class == I.class || \n" +
+ " clazz == X.class || \n" +
+ " X.class == clazz || \n" +
+ " clazz == I.class || \n" +
+ " I.class == clazz || \n" +
+ " I.class == X.class ||\n" +
+ " X.class == I.class;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 5)\n" +
+ " clazz == clazz || \n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "Comparing identical expressions\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 12)\n" +
+ " I.class == X.class ||\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<I> and Class<X>\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 13)\n" +
+ " X.class == I.class;\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<X> and Class<I>\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322531
+ public void test322531c() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {}\n" +
+ "public class X {\n" +
+ " <T extends I> void main(Class<T> clazz, X x) {\n" +
+ " boolean b = \n" +
+ " x.getClass() == clazz || \n" +
+ " clazz == x.getClass(); \n" +
+ " }\n" +
+ "}\n"
+ },
+ "");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322531
+ public void test322531d() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {}\n" +
+ "public final class X {\n" +
+ " <T extends I> void main(Class<T> clazz, X x) {\n" +
+ " boolean b = \n" +
+ " x.getClass() == clazz || \n" +
+ " clazz == x.getClass(); \n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " x.getClass() == clazz || \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<capture#1-of ? extends X> and Class<T>\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " clazz == x.getClass(); \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<T> and Class<capture#2-of ? extends X>\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322531
+ public void test322531e() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {}\n" +
+ "public final class X implements I {\n" +
+ " <T extends I> void main(Class<T> clazz, X x) {\n" +
+ " boolean b = \n" +
+ " x.getClass() == clazz || \n" +
+ " clazz == x.getClass(); \n" +
+ " }\n" +
+ "}\n"
+ },
+ "");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322531
+ public void test322531f() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class I {}\n" +
+ "public class X {\n" +
+ " <T extends I> void main(Class<T> clazz, X x) {\n" +
+ " boolean b = \n" +
+ " x.getClass() == clazz || \n" +
+ " clazz == x.getClass(); \n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " x.getClass() == clazz || \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<capture#1-of ? extends X> and Class<T>\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " clazz == x.getClass(); \n" +
+ " ^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<T> and Class<capture#2-of ? extends X>\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322531
+ public void test322531g() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface List<E> {}\n" +
+ "interface I {}\n" +
+ "public class X implements I {\n" +
+ " void main(List<I> li, X t) {\n" +
+ " boolean b = I.class == t.getClass();\n" +
+ " b = li == t.getList();\n" +
+ " }\n" +
+ " \n" +
+ " List<? extends Object> getList() {\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " boolean b = I.class == t.getClass();\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<I> and Class<capture#1-of ? extends X>\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322531
+ public void test322531h() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {}\n" +
+ "public class X implements I {\n" +
+ " <T extends I> void main(Class<T> clazz, X t) {\n" +
+ " boolean b = \n" +
+ " clazz == t.getClass() || \n" +
+ " t.getClass() == clazz || \n" +
+ " I.class == t.getClass() ||\n" +
+ " t.getClass() == I.class;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " I.class == t.getClass() ||\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<I> and Class<capture#3-of ? extends X>\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " t.getClass() == I.class;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<capture#4-of ? extends X> and Class<I>\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322531
+ public void test322531i() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {};\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " public <T extends I> void test(Class<T> clazz) {\n" +
+ " Class<I> ci = I.class;\n" +
+ " Class<X> ti = X.class;\n" +
+ " boolean b = ci == X.class ||\n" +
+ " X.class == ci ||\n" +
+ " I.class == X.class ||\n" +
+ " X.class == I.class ||\n" +
+ " ti == I.class ||\n" +
+ " I.class == ti ||\n" +
+ " ti == ci ||\n" +
+ " ci == ti;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " boolean b = ci == X.class ||\n" +
+ " ^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<I> and Class<X>\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " X.class == ci ||\n" +
+ " ^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<X> and Class<I>\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 10)\n" +
+ " I.class == X.class ||\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<I> and Class<X>\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 11)\n" +
+ " X.class == I.class ||\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<X> and Class<I>\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 12)\n" +
+ " ti == I.class ||\n" +
+ " ^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<X> and Class<I>\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 13)\n" +
+ " I.class == ti ||\n" +
+ " ^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<I> and Class<X>\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 14)\n" +
+ " ti == ci ||\n" +
+ " ^^^^^^^^\n" +
+ "Incompatible operand types Class<X> and Class<I>\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 15)\n" +
+ " ci == ti;\n" +
+ " ^^^^^^^^\n" +
+ "Incompatible operand types Class<I> and Class<X>\n" +
+ "----------\n");
+ }
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322531
+ public void test322531j() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "interface I {}\n" +
+ "public class X {\n" +
+ " <T extends I> void main(Class<T> clazz) {\n" +
+ " boolean b = \n" +
+ " clazz != clazz || \n" +
+ " X.class != X.class || \n" +
+ " I.class != I.class || \n" +
+ " clazz != X.class || \n" +
+ " X.class != clazz || \n" +
+ " clazz != I.class || \n" +
+ " I.class != clazz || \n" +
+ " I.class != X.class ||\n" +
+ " X.class != I.class;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 5)\n" +
+ " clazz != clazz || \n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "Comparing identical expressions\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " clazz != X.class || \n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<T> and Class<X>\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 9)\n" +
+ " X.class != clazz || \n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<X> and Class<T>\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 12)\n" +
+ " I.class != X.class ||\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<I> and Class<X>\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 13)\n" +
+ " X.class != I.class;\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Incompatible operand types Class<X> and Class<I>\n" +
+ "----------\n");
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InitializationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InitializationTests.java
new file mode 100644
index 000000000..fefb207f5
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InitializationTests.java
@@ -0,0 +1,399 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+public class InitializationTests extends AbstractRegressionTest {
+
+public InitializationTests(String name) {
+ super(name);
+}
+
+public static Test suite() {
+ Test suite = buildAllCompliancesTestSuite(testClass());
+ return suite;
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318020
+public void test318020a() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " public void foo() throws Exception{\n" +
+ " String temp;\n" +
+ " Object temp2= new String(\"test\");\n" +
+ " if(temp2 instanceof String) {\n" +
+ " temp = (String) temp2;\n" +
+ " } else {\n" +
+ " if (true) {\n" +
+ " throw new Exception(\"not a string\");\n" +
+ " }\n" +
+ " }\n" +
+ " temp.trim();\n" +
+ " }\n" +
+ "}"
+ },
+ "");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318020
+public void test318020b() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " {\n" +
+ " if (true)\n" +
+ " throw new NullPointerException();\n" +
+ " }\n" +
+ " public X(){}\n" +
+ "}"
+ },
+ "");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318020
+public void test318020c() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public int a;" +
+ " public X (int a) {\n" +
+ " this.a = a;\n" +
+ " }\n" +
+ " public int returnA () {\n" +
+ " return a;\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " final X abc;" +
+ " if (true || (abc = new X(2)).returnA() == 2) {\n" +
+ " System.out.println(\"Hello\");\n" +
+ " } else { \n" +
+ " abc = new X(1);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 12)\n" +
+ " abc = new X(1);\n" +
+ " ^^^\n" +
+ "The final local variable abc may already have been assigned\n" +
+ "----------\n",
+ null, false, options);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318020
+public void test318020d() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " private int a;" +
+ " public X (int a) {\n" +
+ " this.a = a;\n" +
+ " }\n" +
+ " public int returnA () {\n" +
+ " return a;\n" +
+ " }\n" +
+ " public static boolean comparison (X x, int val) {\n" +
+ " return (x.returnA() == val);\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " final X abc;\n" +
+ " boolean comp = X.comparison((abc = new X(2)), (abc = new X(1)).returnA());\n" +
+ " }\n" +
+ "}\n"
+
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 13)\n" +
+ " boolean comp = X.comparison((abc = new X(2)), (abc = new X(1)).returnA());\n" +
+ " ^^^\n" +
+ "The final local variable abc may already have been assigned\n" +
+ "----------\n",
+ null, false, options);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318020
+public void test318020e() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " private int a;" +
+ " public X (int a) {\n" +
+ " this.a = a;\n" +
+ " }\n" +
+ " public int returnA () {\n" +
+ " return a;\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " final X abc;\n" +
+ " boolean comp = ((abc = new X(2)).returnA() == 1 || (abc = new X(1)).returnA() == 1);\n" +
+ " }\n" +
+ "}\n"
+
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " boolean comp = ((abc = new X(2)).returnA() == 1 || (abc = new X(1)).returnA() == 1);\n" +
+ " ^^^\n" +
+ "The final local variable abc may already have been assigned\n" +
+ "----------\n",
+ null, false, options);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318020
+public void test318020f() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " private int a;" +
+ " public X (int a) {\n" +
+ " this.a = a;\n" +
+ " }\n" +
+ " public int returnA () {\n" +
+ " return a;\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " final X abc;\n" +
+ " int val;\n" +
+ " if (true || (abc = new X(1)).returnA() == 1)\n" +
+ " val = (abc = new X(2)).returnA();\n" +
+ " }\n" +
+ "}\n"
+
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 12)\n" +
+ " val = (abc = new X(2)).returnA();\n" +
+ " ^^^\n" +
+ "The final local variable abc may already have been assigned\n" +
+ "----------\n",
+ null, false, options);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318020
+public void test318020g() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " private int a;" +
+ " public X (int a) {\n" +
+ " this.a = a;\n" +
+ " }\n" +
+ " public int returnA () {\n" +
+ " return a;\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " final X abc;\n" +
+ " int val;\n" +
+ " if (true) {\n" +
+ " val = 0;\n" +
+ " } else {\n" +
+ " val = (abc = new X(1)).returnA();\n" +
+ " }\n" +
+ " abc = new X(2);\n" +
+ " }\n" +
+ "}\n"
+
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 16)\n" +
+ " abc = new X(2);\n" +
+ " ^^^\n" +
+ "The final local variable abc may already have been assigned\n" +
+ "----------\n",
+ null, false, options);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318020
+public void test318020h() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " final static X[] abc;\n" +
+ " static {\n" +
+ " for (Object[] j = new Object[1]; !(((abc = new X[10]).length) == 10); ){\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ " //Zork z;\n" +
+ "}\n"
+
+ },
+ "");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318020
+public void test318020i() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " private int a;" +
+ " class Inner {\n" +
+ " public int aInner;\n" +
+ " public Inner(int a){\n" +
+ " this.aInner = a;\n" +
+ " }\n" +
+ " }\n" +
+ " public X (int a) {\n" +
+ " this.a = a;\n" +
+ " }\n" +
+ " public int returnA () {\n" +
+ " return a;\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " int val;" +
+ " final int int1;\n" +
+ " final int int2;\n" +
+ " val = new X(int1 = 1).new Inner(int2 = int1).aInner;\n" +
+ " System.out.println(int1 + int2);\n" +
+ " }\n" +
+ "}\n"
+
+ },
+ "");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318020
+public void test318020j() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " private int a;" +
+ " public X (int a) {\n" +
+ " this.a = a;\n" +
+ " }\n" +
+ " public int returnA () {\n" +
+ " return a;\n" +
+ " }\n" +
+ " public void foo() {\n" +
+ " final int abc;\n" +
+ " abc = new X(abc = 2).returnA();\n" +
+ " }\n" +
+ "}\n"
+
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " abc = new X(abc = 2).returnA();\n" +
+ " ^^^\n" +
+ "The final local variable abc may already have been assigned\n" +
+ "----------\n",
+ null, false, options);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318020
+public void test318020k() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " private int a;\n" +
+ " final int x;\n" +
+ " {\n" +
+ " x = new X(x = 2).returnA();" +
+ " }\n" +
+ " public X (int a) {\n" +
+ " this.a = a;\n" +
+ " }\n" +
+ " public int returnA () {\n" +
+ " return a;\n" +
+ " }\n" +
+ "}\n"
+
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " x = new X(x = 2).returnA(); }\n" +
+ " ^\n" +
+ "The final field x may already have been assigned\n" +
+ "----------\n",
+ null, false, options);
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=325567
+public void test325567() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " bar(3);\n" +
+ " }\n" +
+ " public static void bar(int i) {\n" +
+ " final String before;\n" +
+ " try {\n" +
+ " before = foo();\n" +
+ " } catch (IOException e) {\n" +
+ " // ignore\n" +
+ " }\n" +
+ " B b = new B(new I() {\n" +
+ " public String bar() {\n" +
+ " return new String(before);\n" +
+ " }\n" +
+ " });\n" +
+ " try {\n" +
+ " b.i.bar();\n" +
+ " } catch(Exception e) {\n" +
+ " // ignore\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ " private static String foo() throws IOException {\n" +
+ " return null;\n" +
+ " }\n" +
+ " \n" +
+ " static class B {\n" +
+ " I i;\n" +
+ " B(I i) {\n" +
+ " this.i = i;\n" +
+ " }\n" +
+ " }\n" +
+ " static interface I {\n" +
+ " String bar();\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 16)\n" +
+ " return new String(before);\n" +
+ " ^^^^^^\n" +
+ "The local variable before may not have been initialized\n" +
+ "----------\n",
+ null, false, options);
+}
+public static Class testClass() {
+ return InitializationTests.class;
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java
new file mode 100644
index 000000000..6f71e7075
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java
@@ -0,0 +1,429 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+public class InnerClass15Test extends AbstractRegressionTest {
+public InnerClass15Test(String name) {
+ super(name);
+}
+static {
+// TESTS_NUMBERS = new int[] { 2 };
+}
+public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_1_5);
+}
+protected Map getCompilerOptions() {
+ Map options = super.getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
+ return options;
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312989
+public void test001() {
+ this.runNegativeTest(new String[] {
+ "X.java",
+ "class X {\n" +
+ " <X> void foo() {\n" +
+ " class X {}\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " <X> void foo() {\n" +
+ " ^\n" +
+ "The type parameter X is hiding the type X\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 3)\n" +
+ " class X {}\n" +
+ " ^\n" +
+ "The nested type X is hiding the type parameter X of the generic method foo() of type X\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " class X {}\n" +
+ " ^\n" +
+ "The nested type X cannot hide an enclosing type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312989
+public void test002() {
+ this.runNegativeTest(new String[] {
+ "X.java",
+ "class X<X> {\n" +
+ " void foo() {\n" +
+ " class X {}\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 1)\n" +
+ " class X<X> {\n" +
+ " ^\n" +
+ "The type parameter X is hiding the type X<X>\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 3)\n" +
+ " class X {}\n" +
+ " ^\n" +
+ "The nested type X is hiding the type parameter X of type X<X>\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 3)\n" +
+ " class X {}\n" +
+ " ^\n" +
+ "The nested type X cannot hide an enclosing type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312989
+// note javac reports an error for this test, but that is
+// incorrect, compare and contrast javac behavior with
+// test004.
+public void test003() {
+ this.runNegativeTest(new String[] {
+ "Y.java",
+ "class Y {\n" +
+ "class X {}\n" +
+ " <X> void foo() {\n" +
+ " class X {}\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING in Y.java (at line 3)\n" +
+ " <X> void foo() {\n" +
+ " ^\n" +
+ "The type parameter X is hiding the type Y.X\n" +
+ "----------\n" +
+ "2. WARNING in Y.java (at line 4)\n" +
+ " class X {}\n" +
+ " ^\n" +
+ "The nested type X is hiding the type parameter X of the generic method foo() of type Y\n" +
+ "----------\n" +
+ "3. WARNING in Y.java (at line 4)\n" +
+ " class X {}\n" +
+ " ^\n" +
+ "The type X is never used locally\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=312989
+public void test004() {
+ this.runNegativeTest(new String[] {
+ "Y.java",
+ "class Y {\n" +
+ "class X {}\n" +
+ " void foo() {\n" +
+ " class X {}\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. WARNING in Y.java (at line 4)\n" +
+ " class X {}\n" +
+ " ^\n" +
+ "The type X is hiding the type Y.X\n" +
+ "----------\n" +
+ "2. WARNING in Y.java (at line 4)\n" +
+ " class X {}\n" +
+ " ^\n" +
+ "The type X is never used locally\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
+public void test005() {
+ this.runNegativeTest(new String[] {
+ "p1/GreenBox.java",
+ "package p1;\n" +
+ "import static p1.BrownBox.*;\n" +
+ "public interface GreenBox {\n" +
+ " public static class Cat extends Object {}\n" +
+ "}\n",
+ "p1/BrownBox.java",
+ "package p1;\n" +
+ "import static p1.GreenBox.*;\n" +
+ "public interface BrownBox {\n" +
+ " public static class BlackCat extends Cat {}\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in p1\\GreenBox.java (at line 2)\n" +
+ " import static p1.BrownBox.*;\n" +
+ " ^^^^^^^^^^^\n" +
+ "The import p1.BrownBox is never used\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
+public void test006() {
+ this.runNegativeTest(new String[] {
+ "p1/BrownBox.java",
+ "package p1;\n" +
+ "import static p1.GreenBox.*;\n" +
+ "public interface BrownBox {\n" +
+ " public static class BlackCat extends Cat {}\n" +
+ "}\n",
+ "p1/GreenBox.java",
+ "package p1;\n" +
+ "import static p1.BrownBox.*;\n" +
+ "public interface GreenBox {\n" +
+ " public static class Cat extends Object {}\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in p1\\GreenBox.java (at line 2)\n" +
+ " import static p1.BrownBox.*;\n" +
+ " ^^^^^^^^^^^\n" +
+ "The import p1.BrownBox is never used\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
+public void test007() {
+ this.runNegativeTest(new String[] {
+ "p1/BrownBox.java",
+ "package p1;\n" +
+ "import static p1.GreenBox.*;\n" +
+ "public interface BrownBox {\n" +
+ " public static class BlackCat extends Cat {}\n" +
+ "}\n",
+ "p1/GreenBox.java",
+ "package p1;\n" +
+ "import static p1.BrownBox.*;\n" +
+ "public interface GreenBox {\n" +
+ " public static class Cat extends java.lang.Object {}\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in p1\\GreenBox.java (at line 2)\n" +
+ " import static p1.BrownBox.*;\n" +
+ " ^^^^^^^^^^^\n" +
+ "The import p1.BrownBox is never used\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
+public void test008() {
+ this.runNegativeTest(new String[] {
+ "p1/BrownBox.java",
+ "package p1;\n" +
+ "import static p1.GreenBox.*;\n" +
+ "public interface BrownBox {\n" +
+ " public static class BlackCat extends Cat {}\n" +
+ "}\n",
+ "p1/GreenBox.java",
+ "package p1;\n" +
+ "import static p1.BrownBox.*;\n" +
+ "public interface GreenBox {\n" +
+ " public static class Cat extends BlackCat {}\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\BrownBox.java (at line 4)\n" +
+ " public static class BlackCat extends Cat {}\n" +
+ " ^^^^^^^^\n" +
+ "The hierarchy of the type BlackCat is inconsistent\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. ERROR in p1\\GreenBox.java (at line 4)\n" +
+ " public static class Cat extends BlackCat {}\n" +
+ " ^^^^^^^^\n" +
+ "Cycle detected: a cycle exists in the type hierarchy between GreenBox.Cat and BrownBox.BlackCat\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
+public void test009() {
+ this.runNegativeTest(new String[] {
+ "p1/GreenBox.java",
+ "package p1;\n" +
+ "import static p1.BrownBox.*;\n" +
+ "public interface GreenBox {\n" +
+ " public static class Cat extends BlackCat {}\n" +
+ "}\n",
+ "p1/BrownBox.java",
+ "package p1;\n" +
+ "import static p1.GreenBox.*;\n" +
+ "public interface BrownBox {\n" +
+ " public static class BlackCat extends Cat {}\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\GreenBox.java (at line 4)\n" +
+ " public static class Cat extends BlackCat {}\n" +
+ " ^^^\n" +
+ "The hierarchy of the type Cat is inconsistent\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. ERROR in p1\\BrownBox.java (at line 4)\n" +
+ " public static class BlackCat extends Cat {}\n" +
+ " ^^^\n" +
+ "Cycle detected: a cycle exists in the type hierarchy between BrownBox.BlackCat and GreenBox.Cat\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
+public void test0010() {
+ this.runNegativeTest(new String[] {
+ "p1/GreenBox.java",
+ "package p1;\n" +
+ "import static p1.BrownBox.*;\n" +
+ "interface SuperInterface {\n" +
+ " public static class Cat extends BlackCat {}\n" +
+ "}\n" +
+ "public interface GreenBox {\n" +
+ "}\n",
+ "p1/BrownBox.java",
+ "package p1;\n" +
+ "import static p1.GreenBox.*;\n" +
+ "public interface BrownBox {\n" +
+ " public static class BlackCat extends Cat {}\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\GreenBox.java (at line 4)\n" +
+ " public static class Cat extends BlackCat {}\n" +
+ " ^^^\n" +
+ "The hierarchy of the type Cat is inconsistent\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. ERROR in p1\\BrownBox.java (at line 4)\n" +
+ " public static class BlackCat extends Cat {}\n" +
+ " ^^^\n" +
+ "Cat cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
+public void test0011() {
+ this.runNegativeTest(new String[] {
+ "p1/GreenBox.java",
+ "package p1;\n" +
+ "import static p1.BrownBox.*;\n" +
+ "interface SuperInterface {\n" +
+ " public static class Cat extends BlackCat {}\n" +
+ "}\n" +
+ "public interface GreenBox extends SuperInterface {\n" +
+ "}\n",
+ "p1/BrownBox.java",
+ "package p1;\n" +
+ "import static p1.GreenBox.*;\n" +
+ "public interface BrownBox {\n" +
+ " public static class BlackCat extends Cat {}\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\GreenBox.java (at line 4)\n" +
+ " public static class Cat extends BlackCat {}\n" +
+ " ^^^\n" +
+ "The hierarchy of the type Cat is inconsistent\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. ERROR in p1\\BrownBox.java (at line 4)\n" +
+ " public static class BlackCat extends Cat {}\n" +
+ " ^^^\n" +
+ "Cycle detected: a cycle exists in the type hierarchy between BrownBox.BlackCat and SuperInterface.Cat\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
+public void test0012() {
+ this.runNegativeTest(new String[] {
+ "p1/GreenBox.java",
+ "package p1;\n" +
+ "import static p1.BrownBox.*;\n" +
+ "interface SuperInterface {\n" +
+ " public static class Cat extends BlackCat {}\n" +
+ "}\n" +
+ "public interface GreenBox extends SuperInterface {\n" +
+ "}\n",
+ "p1/BrownBox.java",
+ "package p1;\n" +
+ "import static p1.GreenBox.*;\n" +
+ "public interface BrownBox {\n" +
+ " public static class BlackCat extends GreenBox.Cat {}\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\GreenBox.java (at line 4)\n" +
+ " public static class Cat extends BlackCat {}\n" +
+ " ^^^\n" +
+ "The hierarchy of the type Cat is inconsistent\n" +
+ "----------\n" +
+ "----------\n" +
+ "1. ERROR in p1\\BrownBox.java (at line 4)\n" +
+ " public static class BlackCat extends GreenBox.Cat {}\n" +
+ " ^^^^^^^^^^^^\n" +
+ "Cycle detected: a cycle exists in the type hierarchy between BrownBox.BlackCat and SuperInterface.Cat\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
+public void test0013() {
+ this.runNegativeTest(new String[] {
+ "cycle/X.java",
+ "package cycle;\n" +
+ "class X extends Y {}\n" +
+ "class Y extends X {}\n",
+ },
+ "----------\n" +
+ "1. ERROR in cycle\\X.java (at line 2)\n" +
+ " class X extends Y {}\n" +
+ " ^\n" +
+ "The hierarchy of the type X is inconsistent\n" +
+ "----------\n" +
+ "2. ERROR in cycle\\X.java (at line 3)\n" +
+ " class Y extends X {}\n" +
+ " ^\n" +
+ "Cycle detected: a cycle exists in the type hierarchy between Y and X\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
+public void test0014() {
+ this.runNegativeTest(new String[] {
+ "cycle/X.java",
+ "package cycle;\n" +
+ "class X extends Y {}\n" +
+ "class Y extends Z {}\n" +
+ "class Z extends A {}\n" +
+ "class A extends B {}\n" +
+ "class B extends C {}\n" +
+ "class C extends X {}\n"
+ },
+ "----------\n" +
+ "1. ERROR in cycle\\X.java (at line 2)\n" +
+ " class X extends Y {}\n" +
+ " ^\n" +
+ "The hierarchy of the type X is inconsistent\n" +
+ "----------\n" +
+ "2. ERROR in cycle\\X.java (at line 3)\n" +
+ " class Y extends Z {}\n" +
+ " ^\n" +
+ "The hierarchy of the type Y is inconsistent\n" +
+ "----------\n" +
+ "3. ERROR in cycle\\X.java (at line 4)\n" +
+ " class Z extends A {}\n" +
+ " ^\n" +
+ "The hierarchy of the type Z is inconsistent\n" +
+ "----------\n" +
+ "4. ERROR in cycle\\X.java (at line 5)\n" +
+ " class A extends B {}\n" +
+ " ^\n" +
+ "The hierarchy of the type A is inconsistent\n" +
+ "----------\n" +
+ "5. ERROR in cycle\\X.java (at line 6)\n" +
+ " class B extends C {}\n" +
+ " ^\n" +
+ "The hierarchy of the type B is inconsistent\n" +
+ "----------\n" +
+ "6. ERROR in cycle\\X.java (at line 7)\n" +
+ " class C extends X {}\n" +
+ " ^\n" +
+ "Cycle detected: a cycle exists in the type hierarchy between C and X\n" +
+ "----------\n");
+}
+public static Class testClass() {
+ return InnerClass15Test.class;
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java
index 2569b3ef7..7e127d424 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java
@@ -11,6 +11,7 @@
package org.eclipse.jdt.core.tests.compiler.regression;
import java.io.File;
+import java.util.Map;
import junit.framework.Test;
@@ -25,12 +26,20 @@ import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class InnerEmulationTest extends AbstractRegressionTest {
static {
// TESTS_NAMES = new String[] { "Bug58069" };
- TESTS_NUMBERS = new int[] { 173, 174 };
+// TESTS_NUMBERS = new int[] { 173, 174 };
// TESTS_RANGE = new int[] { 144, -1 };
}
public InnerEmulationTest(String name) {
super(name);
}
+protected Map getCompilerOptions() {
+ Map options = super.getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.IGNORE);
+ options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE);
+ return options;
+}
public static Test suite() {
return buildAllCompliancesTestSuite(testClass());
}
@@ -169,9 +178,7 @@ public void test004() {
"class A3 { \n"+
" class B {} \n"+
"} \n"
- },
- null,
- null); // no specific success output string
+ }); // no specific success output string
/* then compile with previous input */
@@ -1462,19 +1469,9 @@ public void test033() {
"1. WARNING in p1\\A2.java (at line 18)\n" +
" private class C extends B { \n" +
" ^\n" +
- "The type A2.C is never used locally\n" +
- "----------\n" +
- "2. WARNING in p1\\A2.java (at line 18)\n" +
- " private class C extends B { \n" +
- " ^\n" +
"Access to enclosing constructor A2.B() is emulated by a synthetic accessor method\n" +
"----------\n" +
- "3. WARNING in p1\\A2.java (at line 19)\n" +
- " public void foo() { \n" +
- " ^^^^^\n" +
- "The method foo() from the type A2.C is never used locally\n" +
- "----------\n" +
- "4. ERROR in p1\\A2.java (at line 20)\n" +
+ "2. ERROR in p1\\A2.java (at line 20)\n" +
" (new D.E(null, null, null, new F(get()) {}) {}).execute(); \n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"No enclosing instance of type D is accessible. Must qualify the allocation with an enclosing instance of type D (e.g. x.new A() where x is an instance of D).\n" +
@@ -1555,19 +1552,9 @@ public void test035() {
"1. WARNING in p1\\A2.java (at line 18)\n" +
" private class C extends B { \n" +
" ^\n" +
- "The type A2.C is never used locally\n" +
- "----------\n" +
- "2. WARNING in p1\\A2.java (at line 18)\n" +
- " private class C extends B { \n" +
- " ^\n" +
"Access to enclosing constructor A2.B() is emulated by a synthetic accessor method\n" +
"----------\n" +
- "3. WARNING in p1\\A2.java (at line 19)\n" +
- " public void foo() { \n" +
- " ^^^^^\n" +
- "The method foo() from the type A2.C is never used locally\n" +
- "----------\n" +
- "4. ERROR in p1\\A2.java (at line 20)\n" +
+ "2. ERROR in p1\\A2.java (at line 20)\n" +
" (new D.E(null, null, null, new F(get()) {})).execute(); \n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"No enclosing instance of type D is accessible. Must qualify the allocation with an enclosing instance of type D (e.g. x.new A() where x is an instance of D).\n" +
@@ -2992,18 +2979,13 @@ public void test076() {
"} \n"
},
"----------\n" +
- "1. WARNING in X.java (at line 7)\n" +
- " class B extends X { \n" +
- " ^\n" +
- "The type B is never used locally\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 9)\n" +
+ "1. ERROR in X.java (at line 9)\n" +
" super(new A(){ \n" +
" }); \n" +
" ^^^^^^^^^^^^^^^\n" +
"No enclosing instance of type X is available due to some intermediate constructor invocation\n" +
"----------\n" +
- "3. WARNING in X.java (at line 9)\n" +
+ "2. WARNING in X.java (at line 9)\n" +
" super(new A(){ \n" +
" ^^^\n" +
"Access to enclosing constructor A() is emulated by a synthetic accessor method\n" +
@@ -3030,12 +3012,7 @@ public void test076() {
"} \n"
},
"----------\n" +
- "1. WARNING in X.java (at line 7)\n" +
- " class B extends X { \n" +
- " ^\n" +
- "The type B is never used locally\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 9)\n" +
+ "1. ERROR in X.java (at line 9)\n" +
" super(new A(){ \n" +
" }); \n" +
" ^^^^^^^^^^^^^^^\n" +
@@ -3122,29 +3099,19 @@ public void test078() {
"} \n"
},
"----------\n" +
- "1. WARNING in X.java (at line 7)\n" +
- " class B extends X { \n" +
- " ^\n" +
- "The type B is never used locally\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 9)\n" +
+ "1. ERROR in X.java (at line 9)\n" +
" super(new A(){ \n" +
" void foo() { System.out.println(X.this); } \n" +
" }); \n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"No enclosing instance of type X is available due to some intermediate constructor invocation\n" +
"----------\n" +
- "3. WARNING in X.java (at line 9)\n" +
+ "2. WARNING in X.java (at line 9)\n" +
" super(new A(){ \n" +
" ^^^\n" +
"Access to enclosing constructor A() is emulated by a synthetic accessor method\n" +
"----------\n" +
- "4. WARNING in X.java (at line 10)\n" +
- " void foo() { System.out.println(X.this); } \n" +
- " ^^^^^\n" +
- "The method foo() from the type new A(){} is never used locally\n" +
- "----------\n" +
- "5. ERROR in X.java (at line 10)\n" +
+ "3. ERROR in X.java (at line 10)\n" +
" void foo() { System.out.println(X.this); } \n" +
" ^^^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
@@ -3172,24 +3139,14 @@ public void test078() {
"} \n"
},
"----------\n" +
- "1. WARNING in X.java (at line 7)\n" +
- " class B extends X { \n" +
- " ^\n" +
- "The type B is never used locally\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 9)\n" +
+ "1. ERROR in X.java (at line 9)\n" +
" super(new A(){ \n" +
" void foo() { System.out.println(X.this); } \n" +
" }); \n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"No enclosing instance of type X is available due to some intermediate constructor invocation\n" +
"----------\n" +
- "3. WARNING in X.java (at line 10)\n" +
- " void foo() { System.out.println(X.this); } \n" +
- " ^^^^^\n" +
- "The method foo() from the type new A(){} is never used locally\n" +
- "----------\n" +
- "4. ERROR in X.java (at line 10)\n" +
+ "2. ERROR in X.java (at line 10)\n" +
" void foo() { System.out.println(X.this); } \n" +
" ^^^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
@@ -3387,12 +3344,7 @@ public void test085() {
"} \n"
},
"----------\n" +
- "1. WARNING in X.java (at line 10)\n" +
- " X x = X.this; \n" +
- " ^\n" +
- "The field new B(){}.x is never read locally\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 10)\n" +
+ "1. ERROR in X.java (at line 10)\n" +
" X x = X.this; \n" +
" ^^^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
@@ -3940,12 +3892,7 @@ public void test107() {
"} ",
},
"----------\n" +
- "1. WARNING in X.java (at line 9)\n" +
- " private static class B extends X.Y implements X.Z { \n" +
- " ^\n" +
- "The type A.B is never used locally\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 11)\n" +
+ "1. ERROR in X.java (at line 11)\n" +
" super(B.this); \n" +
" ^^^^^^\n" +
"Cannot refer to \'this\' nor \'super\' while explicitly invoking a constructor\n" +
@@ -3969,12 +3916,7 @@ public void test108() {
"}",
},
"----------\n" +
- "1. WARNING in X.java (at line 5)\n" +
- " class Local2 extends Local1 {\n" +
- " ^^^^^^\n" +
- "The type Local2 is never used locally\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 5)\n" +
+ "1. ERROR in X.java (at line 5)\n" +
" class Local2 extends Local1 {\n" +
" ^^^^^^\n" +
"No enclosing instance of type X is available due to some intermediate constructor invocation\n" +
@@ -4022,22 +3964,7 @@ public void test109() {
"}"
},
"----------\n" +
- "1. WARNING in X.java (at line 4)\n" +
- " public void foo() {\n" +
- " ^^^^^\n" +
- "The method foo() from the type C is never used locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 9)\n" +
- " public void foo() {\n" +
- " ^^^^^\n" +
- "The method foo() from the type new X(){} is never used locally\n" +
- "----------\n" +
- "3. WARNING in X.java (at line 13)\n" +
- " class D extends C {\n" +
- " ^\n" +
- "The type D is never used locally\n" +
- "----------\n" +
- "4. ERROR in X.java (at line 13)\n" +
+ "1. ERROR in X.java (at line 13)\n" +
" class D extends C {\n" +
" ^\n" +
"No enclosing instance of type X is available due to some intermediate constructor invocation\n" +
@@ -4321,11 +4248,6 @@ public void test118() {
" bar();\n" +
" ^^^\n" +
"Cannot refer to an instance method while explicitly invoking a constructor\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 22)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type new Object(){} is never used locally\n" +
"----------\n");
}
public void test119() {
@@ -4382,21 +4304,6 @@ public void test119() {
" foo(\"0\");\n" +
" ^^^^^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 13)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type new Object(){} is never used locally\n" +
- "----------\n" +
- "3. WARNING in X.java (at line 18)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type Local is never used locally\n" +
- "----------\n" +
- "4. WARNING in X.java (at line 35)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type new Object(){} is never used locally\n" +
"----------\n");
return;
}
@@ -4495,45 +4402,20 @@ public void test120() {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 7)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type new Object(){} is never used locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 9)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type new Object(){} is never used locally\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 10)\n" +
+ "1. ERROR in X.java (at line 10)\n" +
" foo(); //0\n" +
" ^^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
"----------\n" +
- "4. WARNING in X.java (at line 14)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type Local is never used locally\n" +
- "----------\n" +
- "5. ERROR in X.java (at line 15)\n" +
+ "2. ERROR in X.java (at line 15)\n" +
" foo(); //1\n" +
" ^^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
"----------\n" +
- "6. ERROR in X.java (at line 19)\n" +
+ "3. ERROR in X.java (at line 19)\n" +
" foo();//2\n" +
" ^^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
- "----------\n" +
- "7. WARNING in X.java (at line 23)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type new Object(){} is never used locally\n" +
- "----------\n" +
- "8. WARNING in X.java (at line 32)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type new Object(){} is never used locally\n" +
"----------\n");
return;
}
@@ -4576,30 +4458,10 @@ public void test120() {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 7)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type new Object(){} is never used locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 9)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type Local is never used locally\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 10)\n" +
+ "1. ERROR in X.java (at line 10)\n" +
" foo(); //1\n" +
" ^^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
- "----------\n" +
- "4. WARNING in X.java (at line 18)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type new Object(){} is never used locally\n" +
- "----------\n" +
- "5. WARNING in X.java (at line 27)\n" +
- " void baz() {\n" +
- " ^^^^^\n" +
- "The method baz() from the type new Object(){} is never used locally\n" +
"----------\n");
}
public void test121() {
@@ -5340,30 +5202,10 @@ public void test132() {
"}", // =================
},
"----------\n" +
- "1. WARNING in X.java (at line 3)\n" +
- " class Local {}\n" +
- " ^^^^^\n" +
- "The type Local is never used locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 4)\n" +
- " class Foo {\n" +
- " ^^^\n" +
- "The type Foo is never used locally\n" +
- "----------\n" +
- "3. WARNING in X.java (at line 5)\n" +
- " void foo() {\n" +
- " ^^^^^\n" +
- "The method foo() from the type Foo is never used locally\n" +
- "----------\n" +
- "4. WARNING in X.java (at line 6)\n" +
+ "1. WARNING in X.java (at line 6)\n" +
" class Local {}\n" +
" ^^^^^\n" +
"The type Local is hiding the type Local\n" +
- "----------\n" +
- "5. WARNING in X.java (at line 6)\n" +
- " class Local {}\n" +
- " ^^^^^\n" +
- "The type Local is never used locally\n" +
"----------\n",
"",
"",
@@ -5570,12 +5412,7 @@ public void test136() {
"}", // =================,
},
"----------\n" +
- "1. WARNING in p\\X.java (at line 5)\n" +
- " String variable = \"my testing\";\n" +
- " ^^^^^^^^\n" +
- "The field X.Outer.Inner.variable is never read locally\n" +
- "----------\n" +
- "2. ERROR in p\\X.java (at line 11)\n" +
+ "1. ERROR in p\\X.java (at line 11)\n" +
" Zork z;\n" +
" ^^^^\n" +
"Zork cannot be resolved to a type\n" +
@@ -5629,12 +5466,7 @@ public void test138() {
"}", // =================,
},
"----------\n" +
- "1. WARNING in p\\X.java (at line 4)\n" +
- " String variable = \"my testing\";\n" +
- " ^^^^^^^^\n" +
- "The field X.Outer.Inner.variable is never read locally\n" +
- "----------\n" +
- "2. ERROR in p\\X.java (at line 12)\n" +
+ "1. ERROR in p\\X.java (at line 12)\n" +
" Zork z;\n" +
" ^^^^\n" +
"Zork cannot be resolved to a type\n" +
@@ -6079,42 +5911,12 @@ public void test151() {
"}", // =================
},
"----------\n" +
- "1. WARNING in X.java (at line 6)\n" +
- " private static class B2F extends X { }\n" +
- " ^^^\n" +
- "The type X.B2F is never used locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 7)\n" +
- " private static class F2B extends X { }\n" +
- " ^^^\n" +
- "The type X.F2B is never used locally\n" +
- "----------\n" +
- "3. WARNING in X.java (at line 13)\n" +
- " private static class B2F extends Key {\n" +
- " ^^^\n" +
- "The type X.Key.B2F is never used locally\n" +
- "----------\n" +
- "4. WARNING in X.java (at line 14)\n" +
- " private static B2F create() { return new B2F(); }\n" +
- " ^^^^^^^^\n" +
- "The method create() from the type X.Key.B2F is never used locally\n" +
- "----------\n" +
- "5. ERROR in X.java (at line 15)\n" +
+ "1. ERROR in X.java (at line 15)\n" +
" public Key flip() { return F2B.create(); }\n" +
" ^^^\n" +
"The type F2B is defined in an inherited type and an enclosing scope\n" +
"----------\n" +
- "6. WARNING in X.java (at line 18)\n" +
- " private static class F2B extends Key {\n" +
- " ^^^\n" +
- "The type X.Key.F2B is never used locally\n" +
- "----------\n" +
- "7. WARNING in X.java (at line 19)\n" +
- " private static F2B create() { return new F2B(); }\n" +
- " ^^^^^^^^\n" +
- "The method create() from the type X.Key.F2B is never used locally\n" +
- "----------\n" +
- "8. ERROR in X.java (at line 20)\n" +
+ "2. ERROR in X.java (at line 20)\n" +
" public Key flip() { return B2F.create(); }\n" +
" ^^^\n" +
"The type B2F is defined in an inherited type and an enclosing scope\n" +
@@ -6213,22 +6015,12 @@ public void test152() {
"}", // =================
},
"----------\n" +
- "1. WARNING in X.java (at line 14)\n" +
- " private static B2F create() { return new B2F(); }\n" +
- " ^^^^^^^^\n" +
- "The method create() from the type X.Key.B2F is never used locally\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 15)\n" +
+ "1. ERROR in X.java (at line 15)\n" +
" public Key flip() { return F2B.create(); }\n" +
" ^^^\n" +
"The type F2B is defined in an inherited type and an enclosing scope\n" +
"----------\n" +
- "3. WARNING in X.java (at line 19)\n" +
- " private static F2B create() { return new F2B(); }\n" +
- " ^^^^^^^^\n" +
- "The method create() from the type X.Key.F2B is never used locally\n" +
- "----------\n" +
- "4. ERROR in X.java (at line 20)\n" +
+ "2. ERROR in X.java (at line 20)\n" +
" public Key flip() { return B2F.create(); }\n" +
" ^^^\n" +
"The type B2F is defined in an inherited type and an enclosing scope\n" +
@@ -6326,32 +6118,22 @@ public void _test153() {
"}", // =================
},
"----------\n" +
- "1. WARNING in X.java (at line 11)\n" +
- " private class Test5 {\n" +
- " ^^^^^\n" +
- "The type X.Test5 is never used locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 12)\n" +
- " private class Test4 extends Test2 {\n" +
- " ^^^^^\n" +
- "The type X.Test5.Test4 is never used locally\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 16)\n" +
+ "1. ERROR in X.java (at line 16)\n" +
" System.out.println(X.this.var1.trim());\n" +
" ^^^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
"----------\n" +
- "4. WARNING in X.java (at line 16)\n" +
+ "2. WARNING in X.java (at line 16)\n" +
" System.out.println(X.this.var1.trim());\n" +
" ^^^^\n" +
"Read access to enclosing field X.var1 is emulated by a synthetic accessor method\n" +
"----------\n" +
- "5. WARNING in X.java (at line 17)\n" +
+ "3. WARNING in X.java (at line 17)\n" +
" System.out.println(var1.trim());\n" +
" ^^^^\n" +
"Read access to enclosing field X.var1 is emulated by a synthetic accessor method\n" +
"----------\n" +
- "6. ERROR in X.java (at line 17)\n" +
+ "4. ERROR in X.java (at line 17)\n" +
" System.out.println(var1.trim());\n" +
" ^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
@@ -6419,27 +6201,22 @@ public void test154() {
"}", // =================
},
"----------\n" +
- "1. WARNING in X.java (at line 12)\n" +
- " private class Test4 extends Test2 {\n" +
- " ^^^^^\n" +
- "The type X.Test4 is never used locally\n" +
- "----------\n" +
- "2. ERROR in X.java (at line 16)\n" +
+ "1. ERROR in X.java (at line 16)\n" +
" System.out.println(X.this.var1.trim());\n" +
" ^^^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
"----------\n" +
- "3. WARNING in X.java (at line 16)\n" +
+ "2. WARNING in X.java (at line 16)\n" +
" System.out.println(X.this.var1.trim());\n" +
" ^^^^\n" +
"Read access to enclosing field X.var1 is emulated by a synthetic accessor method\n" +
"----------\n" +
- "4. WARNING in X.java (at line 17)\n" +
+ "3. WARNING in X.java (at line 17)\n" +
" System.out.println(var1.trim());\n" +
" ^^^^\n" +
"Read access to enclosing field X.var1 is emulated by a synthetic accessor method\n" +
"----------\n" +
- "5. ERROR in X.java (at line 17)\n" +
+ "4. ERROR in X.java (at line 17)\n" +
" System.out.println(var1.trim());\n" +
" ^^^^\n" +
"No enclosing instance of the type X is accessible in scope\n" +
@@ -7038,27 +6815,22 @@ public void test172() throws Exception {
"}\n",
},
"----------\n" +
- "1. WARNING in X.java (at line 4)\n" +
- " private void c() {}\n" +
- " ^^^\n" +
- "The method c() from the type X is never used locally\n" +
- "----------\n" +
- "2. WARNING in X.java (at line 8)\n" +
+ "1. WARNING in X.java (at line 8)\n" +
" a(null);\n" +
" ^^^^^^^\n" +
"Access to enclosing method a(String) from the type X is emulated by a synthetic accessor method\n" +
"----------\n" +
- "3. WARNING in X.java (at line 9)\n" +
+ "2. WARNING in X.java (at line 9)\n" +
" c(null);\n" +
" ^^^^^^^\n" +
"Access to enclosing method c(String) from the type X is emulated by a synthetic accessor method\n" +
"----------\n" +
- "4. WARNING in X.java (at line 14)\n" +
+ "3. WARNING in X.java (at line 14)\n" +
" a(null);\n" +
" ^^^^^^^\n" +
"Access to enclosing method a(String) from the type X is emulated by a synthetic accessor method\n" +
"----------\n" +
- "5. WARNING in X.java (at line 15)\n" +
+ "4. WARNING in X.java (at line 15)\n" +
" c(null);\n" +
" ^^^^^^^\n" +
"Access to enclosing method c(String) from the type X is emulated by a synthetic accessor method\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 5ff18a81e..f057a10f3 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
@@ -35,6 +35,10 @@ public LookupTest(String name) {
public static Test suite() {
return buildAllCompliancesTestSuite(testClass());
}
+
+static {
+// TESTS_NAMES = new String [] { "test096" };
+}
/**
* Non-static member class
*/
@@ -3097,6 +3101,363 @@ public void test095() {
"The type p1.B1 is not visible\n" +
"----------\n");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id= 317212
+public void test096() {
+ this.runNegativeTest(
+ new String[] {
+ "p0/B.java",//------------------------------
+ "package p0;\n" +
+ "public class B {\n" +
+ " public static A m() {\n" +
+ " return new A();\n" +
+ " }\n" +
+ "}\n" +
+ "class A {\n" +
+ " public class M {\n" +
+ " public M() {}\n" +
+ " }\n" +
+ "}\n",
+ "p1/C.java",//------------------------------
+ "package p1;\n" +
+ "import p0.B;\n" +
+ "public class C {\n" +
+ " public static void main(String[] args) {\n" +
+ " B.m().new M();\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in p1\\C.java (at line 5)\n" +
+ " B.m().new M();\n" +
+ " ^^^^^\n" +
+ "The type p0.A is not visible\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id= 317212
+public void test097() {
+ this.runNegativeTest(
+ new String[] {
+ "B.java",//------------------------------
+ "public class B {\n" +
+ " public static A m() {\n" +
+ " return new B().new A();\n" +
+ " }\n" +
+ " private class A {\n" +
+ " public class M {\n" +
+ " public M() {}\n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "class C {\n" +
+ " public static void main(String[] args) {\n" +
+ " B.m().new M();\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in B.java (at line 3)\n" +
+ " return new B().new A();\n" +
+ " ^^^^^^^^^^^^^^^\n" +
+ "Access to enclosing constructor B.A() is emulated by a synthetic accessor method\n" +
+ "----------\n" +
+ "2. WARNING in B.java (at line 6)\n" +
+ " public class M {\n" +
+ " ^\n" +
+ "The type B.A.M is never used locally\n" +
+ "----------\n" +
+ "3. WARNING in B.java (at line 7)\n" +
+ " public M() {}\n" +
+ " ^^^\n" +
+ "The constructor B.A.M() is never used locally\n" +
+ "----------\n" +
+ "4. ERROR in B.java (at line 13)\n" +
+ " B.m().new M();\n" +
+ " ^^^^^\n" +
+ "The type B$A is not visible\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317858
+public void test098() {
+ this.runConformTest(
+ new String[] {
+ "B.java",//------------------------------
+ "class A {\n" +
+ " public final static class B {\n" +
+ " public final static String length = \"very long\";\n" +
+ " }\n" +
+ " private int [] B = new int[5];\n" +
+ "}\n" +
+ "public class B {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(A.B.length);\n" +
+ " }\n" +
+ "}\n",
+ },
+ "very long");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317858
+public void test099() {
+ this.runNegativeTest(
+ new String[] {
+ "B.java",//------------------------------
+ "class A {\n" +
+ " public final static class B {\n" +
+ " public final static String length = \"very long\";\n" +
+ " }\n" +
+ " public int [] B = new int[5];\n" +
+ "}\n" +
+ "public class B {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(A.B.length);\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. ERROR in B.java (at line 9)\n" +
+ " System.out.println(A.B.length);\n" +
+ " ^^^^^^^^^^\n" +
+ "Cannot make a static reference to the non-static field A.B\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317858
+public void test100() {
+ this.runConformTest(
+ new String[] {
+ "B.java",//------------------------------
+ "class A {\n" +
+ " public final class B {\n" +
+ " public final String length = \"very long\";\n" +
+ " }\n" +
+ " public static int [] B = new int[5];\n" +
+ "}\n" +
+ "public class B {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(A.B.length);\n" +
+ " }\n" +
+ "}\n",
+ },
+ "5");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317858
+public void test101() {
+ this.runNegativeTest(
+ new String[] {
+ "B.java",//------------------------------
+ "class A {\n" +
+ " private final class B {\n" +
+ " public final String length = \"very long\";\n" +
+ " }\n" +
+ " private int [] B = new int[5];\n" +
+ "}\n" +
+ "public class B {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(A.B.length);\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in B.java (at line 2)\n" +
+ " private final class B {\n" +
+ " ^\n" +
+ "The type A.B is never used locally\n" +
+ "----------\n" +
+ "2. WARNING in B.java (at line 3)\n" +
+ " public final String length = \"very long\";\n" +
+ " ^^^^^^\n" +
+ "The field A.B.length is never read locally\n" +
+ "----------\n" +
+ "3. WARNING in B.java (at line 5)\n" +
+ " private int [] B = new int[5];\n" +
+ " ^\n" +
+ "The field A.B is never read locally\n" +
+ "----------\n" +
+ "4. ERROR in B.java (at line 9)\n" +
+ " System.out.println(A.B.length);\n" +
+ " ^\n" +
+ "The field A.B is not visible\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317858
+public void test102() {
+ this.runNegativeTest(
+ new String[] {
+ "B.java",//------------------------------
+ "class A {\n" +
+ " public final class B {\n" +
+ " private final String length = \"very long\";\n" +
+ " }\n" +
+ " private int [] B = new int[5];\n" +
+ "}\n" +
+ "public class B {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(A.B.length);\n" +
+ " }\n" +
+ "}\n",
+ },
+ "----------\n" +
+ "1. WARNING in B.java (at line 3)\n" +
+ " private final String length = \"very long\";\n" +
+ " ^^^^^^\n" +
+ "The field A.B.length is never read locally\n" +
+ "----------\n" +
+ "2. WARNING in B.java (at line 5)\n" +
+ " private int [] B = new int[5];\n" +
+ " ^\n" +
+ "The field A.B is never read locally\n" +
+ "----------\n" +
+ "3. ERROR in B.java (at line 9)\n" +
+ " System.out.println(A.B.length);\n" +
+ " ^^^^^^\n" +
+ "The field A.B.length is not visible\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316956
+public void test103() {
+ Map options = getCompilerOptions();
+ CompilerOptions compOptions = new CompilerOptions(options);
+ if (compOptions.complianceLevel < ClassFileConstants.JDK1_4) return;
+ this.runNegativeTest(
+ new String[] {
+ "A.java",//------------------------------
+ "public class A {\n" +
+ " private int x;\n" +
+ " static class B {\n" +
+ " private int x;\n" +
+ " private C c = new C() {\n" +
+ " void foo() {\n" +
+ " x = 3;\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ " static class C {\n" +
+ " private int x;\n" +
+ " }\n" +
+ " }\n",
+ },
+ "----------\n" +
+ "1. WARNING in A.java (at line 2)\n" +
+ " private int x;\n" +
+ " ^\n" +
+ "The field A.x is never read locally\n" +
+ "----------\n" +
+ "2. WARNING in A.java (at line 4)\n" +
+ " private int x;\n" +
+ " ^\n" +
+ "The field A.B.x is never read locally\n" +
+ "----------\n" +
+ "3. WARNING in A.java (at line 5)\n" +
+ " private C c = new C() {\n" +
+ " ^\n" +
+ "The field A.B.c is never read locally\n" +
+ "----------\n" +
+ "4. WARNING in A.java (at line 6)\n" +
+ " void foo() {\n" +
+ " ^^^^^\n" +
+ "The method foo() from the type new A.C(){} is never used locally\n" +
+ "----------\n" +
+ "5. WARNING in A.java (at line 7)\n" +
+ " x = 3;\n" +
+ " ^\n" +
+ "Write access to enclosing field A.B.x is emulated by a synthetic accessor method\n" +
+ "----------\n" +
+ "6. WARNING in A.java (at line 12)\n" +
+ " private int x;\n" +
+ " ^\n" +
+ "The field A.C.x is never read locally\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316956
+public void test104() {
+ Map options = getCompilerOptions();
+ CompilerOptions compOptions = new CompilerOptions(options);
+ if (compOptions.complianceLevel < ClassFileConstants.JDK1_4) return;
+ this.runNegativeTest(
+ new String[] {
+ "A.java",//------------------------------
+ "public class A {\n" +
+ " private int x;\n" +
+ " static class B {\n" +
+ " private int x;\n" +
+ " private C c = new C() {\n" +
+ " void foo() {\n" +
+ " x = 3;\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ " static class C {\n" +
+ " public int x;\n" +
+ " }\n" +
+ " }\n",
+ },
+ "----------\n" +
+ "1. WARNING in A.java (at line 2)\n" +
+ " private int x;\n" +
+ " ^\n" +
+ "The field A.x is never read locally\n" +
+ "----------\n" +
+ "2. WARNING in A.java (at line 4)\n" +
+ " private int x;\n" +
+ " ^\n" +
+ "The field A.B.x is never read locally\n" +
+ "----------\n" +
+ "3. WARNING in A.java (at line 5)\n" +
+ " private C c = new C() {\n" +
+ " ^\n" +
+ "The field A.B.c is never read locally\n" +
+ "----------\n" +
+ "4. WARNING in A.java (at line 6)\n" +
+ " void foo() {\n" +
+ " ^^^^^\n" +
+ "The method foo() from the type new A.C(){} is never used locally\n" +
+ "----------\n");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=316956
+public void test105() {
+ Map options = getCompilerOptions();
+ CompilerOptions compOptions = new CompilerOptions(options);
+ if (compOptions.complianceLevel < ClassFileConstants.JDK1_4) return;
+ this.runNegativeTest(
+ new String[] {
+ "A.java",//------------------------------
+ "public class A {\n" +
+ " private int x;\n" +
+ " private C c = new C() {\n" +
+ " void foo() {\n" +
+ " x = 3;\n" +
+ " }\n" +
+ " };\n" +
+ " static class C {\n" +
+ " private int x;\n" +
+ " }\n" +
+ " }\n",
+ },
+ "----------\n" +
+ "1. WARNING in A.java (at line 2)\n" +
+ " private int x;\n" +
+ " ^\n" +
+ "The field A.x is never read locally\n" +
+ "----------\n" +
+ "2. WARNING in A.java (at line 3)\n" +
+ " private C c = new C() {\n" +
+ " ^\n" +
+ "The field A.c is never read locally\n" +
+ "----------\n" +
+ "3. WARNING in A.java (at line 4)\n" +
+ " void foo() {\n" +
+ " ^^^^^\n" +
+ "The method foo() from the type new A.C(){} is never used locally\n" +
+ "----------\n" +
+ "4. WARNING in A.java (at line 5)\n" +
+ " x = 3;\n" +
+ " ^\n" +
+ "Write access to enclosing field A.x is emulated by a synthetic accessor method\n" +
+ "----------\n" +
+ "5. WARNING in A.java (at line 9)\n" +
+ " private int x;\n" +
+ " ^\n" +
+ "The field A.C.x is never read locally\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/MethodVerifyTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
index 2c81d7ff0..297b5b2de 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java
@@ -16,6 +16,7 @@ import java.util.Map;
import junit.framework.Test;
import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
@@ -26,8 +27,8 @@ import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class MethodVerifyTest extends AbstractComparableTest {
static {
-// TESTS_NAMES = new String[] { "test000" };
-// TESTS_NUMBERS = new int[] { 184 };
+// TESTS_NAMES = new String[] { "test211" };
+// TESTS_NUMBERS = new int[] { 213 };
// TESTS_RANGE = new int[] { 190, -1};
}
@@ -9583,6 +9584,11 @@ public void test176() {
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=251091
+// Srikanth, Aug 10th 2010. This test does not elicit any name clash error from javac 5 or javac6
+// javac7 reports "X.java:7: name clash: foo(Collection<?>) in X and foo(Collection) in A have the
+// same erasure, yet neither overrides the other"
+// After the fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=322001, we match
+// JDK7 (7b100) behavior. (earlier we would issue an extra name clash)
public void test177() {
if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_6) { // see test187()
this.runNegativeTest(
@@ -9613,17 +9619,12 @@ public void test177() {
" ^^^^^^^^^^\n" +
"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" +
"----------\n" +
- "4. ERROR in X.java (at line 6)\n" +
- " class X extends A implements I {\n" +
- " ^\n" +
- "Name clash: The method foo(Collection<?>) of type I has the same erasure as foo(Collection) of type A but does not override it\n" +
- "----------\n" +
- "5. WARNING in X.java (at line 6)\n" +
+ "4. WARNING in X.java (at line 6)\n" +
" class X extends A implements I {\n" +
" ^\n" +
"The serializable class X does not declare a static final serialVersionUID field of type long\n" +
"----------\n" +
- "6. ERROR in X.java (at line 7)\n" +
+ "5. ERROR in X.java (at line 7)\n" +
" @Override public X foo(Collection<?> c) { return this; }\n" +
" ^^^^^^^^^^^^^^^^^^^^\n" +
"Name clash: The method foo(Collection<?>) of type X has the same erasure as foo(Collection) of type A but does not override it\n" +
@@ -9658,22 +9659,17 @@ public void test177() {
" ^^^^^^^^^^\n" +
"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" +
"----------\n" +
- "4. ERROR in X.java (at line 6)\n" +
- " class X extends A implements I {\n" +
- " ^\n" +
- "Name clash: The method foo(Collection<?>) of type I has the same erasure as foo(Collection) of type A but does not override it\n" +
- "----------\n" +
- "5. WARNING in X.java (at line 6)\n" +
+ "4. WARNING in X.java (at line 6)\n" +
" class X extends A implements I {\n" +
" ^\n" +
"The serializable class X does not declare a static final serialVersionUID field of type long\n" +
"----------\n" +
- "6. ERROR in X.java (at line 7)\n" +
+ "5. ERROR in X.java (at line 7)\n" +
" @Override public X foo(Collection<?> c) { return this; }\n" +
" ^^^^^^^^^^^^^^^^^^^^\n" +
"Name clash: The method foo(Collection<?>) of type X has the same erasure as foo(Collection) of type A but does not override it\n" +
"----------\n" +
- "7. ERROR in X.java (at line 7)\n" +
+ "6. ERROR in X.java (at line 7)\n" +
" @Override public X foo(Collection<?> c) { return this; }\n" +
" ^^^^^^^^^^^^^^^^^^^^\n" +
"The method foo(Collection<?>) of type X must override a superclass method\n" +
@@ -10166,17 +10162,12 @@ public void test187() {
" ^^^^^^^^^^^^^^^^^^\n" +
"Name clash: The method f(List<Integer>) of type Y has the same erasure as f(List<String>) of type X but does not override it\n" +
"----------\n" +
- "2. ERROR in X.java (at line 11)\n" +
- " abstract class Z extends X implements I {}\n" +
- " ^\n" +
- "Name clash: The method f(List<String>) of type X has the same erasure as f(List<Integer>) of type I but does not override it\n" +
- "----------\n" +
- "3. ERROR in X.java (at line 13)\n" +
+ "2. ERROR in X.java (at line 13)\n" +
" int f(List<String> l) {return 0;}\n" +
" ^^^^^^^^^^^^^^^^^\n" +
"Method f(List<String>) has the same erasure f(List<E>) as another method in type XX\n" +
"----------\n" +
- "4. ERROR in X.java (at line 14)\n" +
+ "3. ERROR in X.java (at line 14)\n" +
" double f(List<Integer> l) {return 0;}\n" +
" ^^^^^^^^^^^^^^^^^^\n" +
"Method f(List<Integer>) has the same erasure f(List<E>) as another method in type XX\n" +
@@ -10907,4 +10898,167 @@ public void test208a() {
},
this.complianceLevel <= ClassFileConstants.JDK1_5 ? "Annotation was found" : "Annotation was not found");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=322001
+public void test209() {
+ this.runNegativeTest(
+ new String[] {
+ "Concrete.java",
+ "class Bar extends Zork {}\n" +
+ "class Foo {}\n" +
+ "\n" +
+ "interface Function<F, T> {\n" +
+ " T apply(F f);\n" +
+ "}\n" +
+ "interface Predicate<T> {\n" +
+ " boolean apply(T t);\n" +
+ "}\n" +
+ "\n" +
+ "public class Concrete implements Predicate<Foo>, Function<Bar, Boolean> {\n" +
+ " public Boolean apply(Bar two) {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public boolean apply(Foo foo) {\n" +
+ " return false;\n" +
+ " }\n" +
+
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in Concrete.java (at line 1)\n" +
+ " class Bar extends Zork {}\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321548
+public void test210() {
+ this.runNegativeTest(
+ new String[] {
+ "ErasureTest.java",
+ "interface Interface1<T> {\n" +
+ " public void hello(T greeting);\n" +
+ "}\n" +
+ "interface Interface2<T> {\n" +
+ " public int hello(T greeting);\n" +
+ "}\n" +
+ "public class ErasureTest extends Zork implements Interface1<String>, Interface2<Double> {\n" +
+ " public void hello(String greeting) { }\n" +
+ " public int hello(Double greeting) {\n" +
+ " return 0;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in ErasureTest.java (at line 7)\n" +
+ " public class ErasureTest extends Zork implements Interface1<String>, Interface2<Double> {\n" +
+ " ^^^^\n" +
+ "Zork cannot be resolved to a type\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=83162
+public void test211() {
+ this.runNegativeTest(
+ new String[] {
+ "SomeClass.java",
+ "interface Equivalent<T> {\n" +
+ " boolean equalTo(T other);\n" +
+ "}\n" +
+ "\n" +
+ "interface EqualityComparable<T> {\n" +
+ " boolean equalTo(T other);\n" +
+ "}\n" +
+ "\n" +
+ "public class SomeClass implements Equivalent<String>, EqualityComparable<Integer> {\n" +
+ " public boolean equalTo(String other) {\n" +
+ " return true;\n" +
+ " }\n" +
+ " public boolean equalTo(Integer other) {\n" +
+ " return true;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in SomeClass.java (at line 9)\n" +
+ " public class SomeClass implements Equivalent<String>, EqualityComparable<Integer> {\n" +
+ " ^^^^^^^^^\n" +
+ "Name clash: The method equalTo(T) of type EqualityComparable<T> has the same erasure as equalTo(T) of type Equivalent<T> but does not override it\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=323693
+public void test212() {
+ this.runNegativeTest(
+ new String[] {
+ "Derived.java",
+ "class Base<T> {\n" +
+ " T foo(T x) {\n" +
+ " return x;\n" +
+ " }\n" +
+ "}\n" +
+ "interface Interface<T>{\n" +
+ " T foo(T x);\n" +
+ "}\n" +
+ "public class Derived extends Base<String> implements Interface<Integer> {\n" +
+ " public Integer foo(Integer x) {\n" +
+ " return x;\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in Derived.java (at line 9)\n" +
+ " public class Derived extends Base<String> implements Interface<Integer> {\n" +
+ " ^^^^^^^\n" +
+ "Name clash: The method foo(T) of type Interface<T> has the same erasure as foo(T) of type Base<T> but does not override it\n" +
+ "----------\n");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=324850
+public void _test213() {
+ Map compilerOptions15 = getCompilerOptions();
+ compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
+ compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
+ compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
+ this.runConformTest(
+ new String[] {
+ "Y.java",
+ "public abstract class Y implements I<Y> {\n" +
+ " public final Y foo(Object o, J<Y> j) {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public final void bar(Object o, J<Y> j, Y y) {\n" +
+ " }\n" +
+ "}",
+ "I.java",
+ "public interface I<S> {\n" +
+ " public S foo(Object o, J<S> j);\n" +
+ " public void bar(Object o, J<S> j, S s);\n" +
+ "}",
+ "J.java",
+ "public interface J<S> {}"
+ },
+ "",
+ null,
+ true,
+ null,
+ compilerOptions15,
+ null);
+
+ Map compilerOptions14 = getCompilerOptions();
+ compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
+ compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
+ compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public Object foo() {\n" +
+ " return new Y() {};\n" +
+ " }\n" +
+ "}"
+ },
+ "",
+ null,
+ false,
+ null,
+ compilerOptions14,
+ null);
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
index b4c9b2bbe..d93883b60 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
@@ -206,4 +206,56 @@ public class NonFatalErrorTest extends AbstractRegressionTest {
// javac options
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
}
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=319626
+ public void test006() {
+ Map customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_FatalOptionalError, CompilerOptions.DISABLED);
+ customOptions.put(CompilerOptions.OPTION_ReportUndocumentedEmptyBlock, CompilerOptions.ERROR);
+ runNegativeTest(
+ // test directory preparation
+ true /* flush output directory */,
+ new String[] { /* test files */
+ "X.java",
+ "public class X {\n" +
+ " { }\n" +
+ " static { }\n" +
+ " X() { }\n" +
+ " X(int a) {}\n" +
+ " public void foo() {}\n" +
+ " public static void main(String argv[]) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ "}\n"
+ },
+ // compiler options
+ null /* no class libraries */,
+ customOptions /* custom options */,
+ // compiler results
+ "----------\n" +
+ "1. ERROR in X.java (at line 2)\n" +
+ " { }\n" +
+ " ^^^^^^^\n" +
+ "Empty block should be documented\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 3)\n" +
+ " static { }\n" +
+ " ^^^^\n" +
+ "Empty block should be documented\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 5)\n" +
+ " X(int a) {}\n" +
+ " ^^\n" +
+ "Empty block should be documented\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 6)\n" +
+ " public void foo() {}\n" +
+ " ^^\n" +
+ "Empty block should be documented\n" +
+ "----------\n",
+ // runtime results
+ "SUCCESS" /* expected output string */,
+ null /* do not check error string */,
+ // javac options
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java
index c93c346fc..95af131fd 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 320170
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -24,6 +25,10 @@ import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.flow.NullInfoRegistry;
import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
@@ -33,10 +38,6 @@ import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import junit.framework.AssertionFailedError;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
/**
* A tests series especially meant to validate the internals of our null
* reference analysis. See NullReferenceTest for tests targetted at
@@ -96,7 +97,7 @@ public class NullReferenceImplTests extends NullReferenceTest {
011001
011010
011011
- 011100
+ 011100 pot. n & pot. nn & pot. un
011101
011110
011111
@@ -853,7 +854,7 @@ public void test2500_addInitializationsFrom_for_definites() {
// Note: coverage tests tend to fill the console with messages, and the
// instrumented code is slower, so never release code with active
// coverage tests.
-private static int coveragePointsNb = 39;
+private static int coveragePointsNb = 41;
// PREMATURE reactivate coverage tests
// Coverage by state transition tables methods.
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTransformations.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTransformations.java
index 9f15664ce..be763c83c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTransformations.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTransformations.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java
index c18c349cb..6736c333c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bugs 325755, 133125, 292478, 319201 and 320170
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -34,7 +35,7 @@ public NullReferenceTest(String name) {
// Only the highest compliance level is run; add the VM argument
// -Dcompliance=1.4 (for example) to lower it if needed
static {
-// TESTS_NAMES = new String[] { "testBug304416" };
+// TESTS_NAMES = new String[] { "testBug325229" };
// TESTS_NUMBERS = new int[] { 561 };
// TESTS_RANGE = new int[] { 1, 2049 };
}
@@ -728,17 +729,8 @@ public void test0033_conditional_expression() {
}
// null analysis -- conditional expression
-// TODO (maxime) fix - may consider simultaneous computation of expression null status
-// this case is one of those which raise the need for the simultaneous calculation of
-// the null status of an expression and the code analysis of the said expression; this
-// case is simplistic: we need a value (here, potentially null), that is *not* carried
-// by the current embodiment of the flow info; other cases are less trivial in which
-// side effects on variables could introduce errors into after the facts evaluations;
-// one possible trick would be to add a slot for this
-// other path: use a tainted unknown expression status; does not seem to cope well
-// with o = (o == null ? new Object() : o)
-// TODO (maxime) https://bugs.eclipse.org/bugs/show_bug.cgi?id=133125
-public void _test0034_conditional_expression() {
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=133125
+public void test0034_conditional_expression() {
this.runNegativeTest(
new String[] {
"X.java",
@@ -749,12 +741,90 @@ public void _test0034_conditional_expression() {
" o.toString();\n" +
" }\n" +
"}\n"},
- "----------\n" +
- "1. ERROR in X.java (at line 4)\n" +
- " o.toString();\n" +
- " ^\n" +
- "The variable o may be null\n" +
- "----------\n");
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " o.toString();\n" +
+ " ^\n" +
+ "Potential null pointer access: The variable o may be null at this location\n" +
+ "----------\n");
+}
+
+// null analysis -- conditional expression
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=133125
+// variant with constant condition
+public void test0034_conditional_expression_2() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " boolean b;\n" +
+ " void foo() {\n" +
+ " Object o = false ? null : new Object();\n" +
+ " o.toString();\n" +
+ " }\n" +
+ "}\n"},
+ "");
+}
+
+// null analysis -- conditional expression
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=133125
+public void test0034_conditional_expression_3() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " boolean b;\n" +
+ " void foo(Object a) {\n" +
+ " if (a == null) {}\n" +
+ " Object o = b ? a : new Object();\n" +
+ " o.toString();\n" +
+ " }\n" +
+ "}\n"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " o.toString();\n" +
+ " ^\n" +
+ "Potential null pointer access: The variable o may be null at this location\n" +
+ "----------\n");
+}
+
+// null analysis -- conditional expression
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=133125
+// variant with dependency between condition and expression - LocalDeclaration
+// TODO(stephan) cannot analyse this flow dependency
+public void _test0034_conditional_expression_4() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " boolean b;\n" +
+ " void foo(Object u) {\n" +
+ " if (u == null) {}\n" + //taint
+ " Object o = (u == null) ? new Object() : u;\n" +
+ " o.toString();\n" +
+ " }\n" +
+ "}\n"},
+ "");
+}
+
+// null analysis -- conditional expression
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=133125
+// variant with dependency between condition and expression - Assignment
+// TODO(stephan) cannot analyse this flow dependency
+public void _test0034_conditional_expression_5() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " boolean b;\n" +
+ " void foo(Object u) {\n" +
+ " if (u == null) {}\n" + //taint
+ " Object o;\n" +
+ " o = (u == null) ? new Object() : u;\n" +
+ " o.toString();\n" +
+ " }\n" +
+ "}\n"},
+ "");
}
// null analysis -- conditional expression
@@ -5484,6 +5554,78 @@ public void test0535_try_finally() {
"");
}
+// null analysis -- try/finally
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=320170 - [compiler] [null] Whitebox issues in null analysis
+// trigger nullbits 0111 (pot n|nn|un), don't let "definitely unknown" override previous information
+public void test0536_try_finally() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " X bar () { return null; }\n" +
+ " void foo() {\n" +
+ " X x = new X();\n" +
+ " try {\n" +
+ " x = null;\n" +
+ " x = new X();\n" + // if this throws an exception finally finds x==null
+ " x = bar();\n" +
+ " } finally {\n" +
+ " x.toString();\n" + // complain
+ " }\n" +
+ " }\n" +
+ "}\n"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " x.toString();\n" +
+ " ^\n" +
+ "Potential null pointer access: The variable x may be null at this location\n" +
+ "----------\n",
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
+
+// null analysis -- try/finally
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=320170 - [compiler] [null] Whitebox issues in null analysis
+// trigger nullbits 0111 (pot n|nn|un), don't let "definitely unknown" override previous information
+// multiple variables
+public void test0537_try_finally() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " X bar () { return null; }\n" +
+ " void foo() {\n" +
+ " X x1 = new X();\n" +
+ " X x2 = new X();\n" +
+ " X x3 = new X();\n" +
+ " try {\n" +
+ " x1 = null;\n" +
+ " x2 = null;\n" +
+ " x1 = new X();\n" + // if this throws an exception finally finds x1==null
+ " x2 = new X();\n" + // if this throws an exception finally finds x2==null
+ " x3 = new X();\n" + // if this throws an exception finally still finds x3!=null
+ " x1 = bar();\n" +
+ " x2 = bar();\n" +
+ " } finally {\n" +
+ " x1.toString();\n" + // complain
+ " x2.toString();\n" + // complain
+ " x3.toString();\n" + // don't complain
+ " }\n" +
+ " }\n" +
+ "}\n"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 16)\n" +
+ " x1.toString();\n" +
+ " ^^\n" +
+ "Potential null pointer access: The variable x1 may be null at this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 17)\n" +
+ " x2.toString();\n" +
+ " ^^\n" +
+ "Potential null pointer access: The variable x2 may be null at this location\n" +
+ "----------\n",
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
+
// null analysis -- try/catch
public void test0550_try_catch() {
this.runConformTest(
@@ -11662,4 +11804,1765 @@ public void testBug305590() {
"----------\n",
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201
+// unboxing raises an NPE
+// LocalDeclaration
+public void testBug319201() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return;
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo() {\n" +
+ " Integer i = null;\n" +
+ " int j = i;\n" + // should warn
+ " }\n" +
+ "}"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " int j = i;\n" +
+ " ^\n" +
+ "Null pointer access: The variable i can only be null at this location\n" +
+ "----------\n",
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201
+// unboxing could raise an NPE
+// Assignment
+public void testBug319201a() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return;
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(Integer i) {\n" +
+ " if (i == null) {};\n" +
+ " int j;\n" +
+ " j = i;\n" + // should warn
+ " }\n" +
+ "}"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " j = i;\n" +
+ " ^\n" +
+ "Potential null pointer access: The variable i may be null at this location\n" +
+ "----------\n",
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201
+// unboxing raises an NPE
+// MessageSend
+public void testBug319201b() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return;
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo() {\n" +
+ " Boolean bo = null;;\n" +
+ " bar(bo);\n" + // should warn
+ " }\n" +
+ " void bar(boolean b) {}\n" +
+ "}"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " bar(bo);\n" +
+ " ^^\n" +
+ "Null pointer access: The variable bo can only be null at this location\n" +
+ "----------\n",
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201
+// unboxing raises an NPE
+// Node types covered (in this order):
+// ExplicitConstructorCall
+// AllocationExpression
+// AND_AND_Expression
+// OR_OR_Expression
+// ArrayAllocationExpression
+// ForStatement
+// DoStatement
+// IfStatement
+// QualifiedAllocationExpression
+// SwitchStatement
+// WhileStatement
+// CastExpression
+// AssertStatement
+// ReturnStatement
+public void testBug319201c() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return;
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class Y { public Y(boolean b1, boolean b2) {} }\n" +
+ "public class X extends Y {\n" +
+ " public X(boolean b, Boolean b2) {\n" +
+ " super(b2 == null, b2);\n" +
+ " }\n" +
+ " class Z {\n" +
+ " public Z(boolean b) {}\n" +
+ " }\n" +
+ " boolean fB = (Boolean)null;\n" +
+ " public boolean foo(boolean inB) {\n" +
+ " Boolean b1 = null;\n" +
+ " X x = new X(b1, null);\n" +
+ " Boolean b2 = null;\n" +
+ " boolean dontcare = b2 && inB;\n" +
+ " Boolean b3 = null;\n" +
+ " dontcare = inB || b3;\n" +
+ " Integer dims = null;\n" +
+ " char[] cs = new char[dims];\n" +
+ " Boolean b5 = null;\n" +
+ " do {\n" +
+ " Boolean b4 = null;\n" +
+ " for (int i=0;b4; i++);\n" +
+ " } while (b5);\n" +
+ " Boolean b6 = null;\n" +
+ " if (b6) { }\n" +
+ " Boolean b7 = null;\n" +
+ " Z z = this.new Z(b7);\n" +
+ " Integer sel = null;\n" +
+ " switch(sel) {\n" +
+ " case 1: break;\n" +
+ " default: break;\n" +
+ " }\n" +
+ " Boolean b8 = null;\n" +
+ " while (b8) {}\n" +
+ " Boolean b9 = null;\n" +
+ " dontcare = (boolean)b9;\n" +
+ " Boolean b10 = null;\n" +
+ " assert b10 : \"shouldn't happen, but will\";\n" +
+ " Boolean b11 = null;\n" +
+ " return b11;\n" +
+ " }\n" +
+ "}"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 4)\n" +
+ " super(b2 == null, b2);\n" +
+ " ^^\n" +
+ "Potential null pointer access: The variable b2 may be null at this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 12)\n" +
+ " X x = new X(b1, null);\n" +
+ " ^^\n" +
+ "Null pointer access: The variable b1 can only be null at this location\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 14)\n" +
+ " boolean dontcare = b2 && inB;\n" +
+ " ^^\n" +
+ "Null pointer access: The variable b2 can only be null at this location\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 16)\n" +
+ " dontcare = inB || b3;\n" +
+ " ^^\n" +
+ "Null pointer access: The variable b3 can only be null at this location\n" +
+ "----------\n" +
+ "5. ERROR in X.java (at line 18)\n" +
+ " char[] cs = new char[dims];\n" +
+ " ^^^^\n" +
+ "Null pointer access: The variable dims can only be null at this location\n" +
+ "----------\n" +
+ "6. ERROR in X.java (at line 22)\n" +
+ " for (int i=0;b4; i++);\n" +
+ " ^^\n" +
+ "Null pointer access: The variable b4 can only be null at this location\n" +
+ "----------\n" +
+ "7. ERROR in X.java (at line 23)\n" +
+ " } while (b5);\n" +
+ " ^^\n" +
+ "Null pointer access: The variable b5 can only be null at this location\n" +
+ "----------\n" +
+ "8. ERROR in X.java (at line 25)\n" +
+ " if (b6) { }\n" +
+ " ^^\n" +
+ "Null pointer access: The variable b6 can only be null at this location\n" +
+ "----------\n" +
+ "9. ERROR in X.java (at line 27)\n" +
+ " Z z = this.new Z(b7);\n" +
+ " ^^\n" +
+ "Null pointer access: The variable b7 can only be null at this location\n" +
+ "----------\n" +
+ "10. ERROR in X.java (at line 29)\n" +
+ " switch(sel) {\n" +
+ " ^^^\n" +
+ "Null pointer access: The variable sel can only be null at this location\n" +
+ "----------\n" +
+ "11. ERROR in X.java (at line 34)\n" +
+ " while (b8) {}\n" +
+ " ^^\n" +
+ "Null pointer access: The variable b8 can only be null at this location\n" +
+ "----------\n" +
+ "12. ERROR in X.java (at line 36)\n" +
+ " dontcare = (boolean)b9;\n" +
+ " ^^\n" +
+ "Null pointer access: The variable b9 can only be null at this location\n" +
+ "----------\n" +
+ "13. ERROR in X.java (at line 38)\n" +
+ " assert b10 : \"shouldn\'t happen, but will\";\n" +
+ " ^^^\n" +
+ "Null pointer access: The variable b10 can only be null at this location\n" +
+ "----------\n" +
+ "14. ERROR in X.java (at line 40)\n" +
+ " return b11;\n" +
+ " ^^^\n" +
+ "Null pointer access: The variable b11 can only be null at this location\n" +
+ "----------\n",
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201
+// unboxing raises an NPE
+// DoStatement, variants with assignement and/or continue in the body & empty body
+public void testBug319201d() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5)
+ return;
+ Map customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_ReportUnnecessaryElse, CompilerOptions.IGNORE);
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public void foo(boolean cond, boolean cond2) {\n" +
+ " Boolean b = null;\n" +
+ " do {\n" +
+ " b = false;\n" +
+ " if (cond) continue;\n" + // shouldn't make a difference
+ " } while (b);\n" + // don't complain, loop body has already assigned b
+ " Boolean b2 = null;\n" +
+ " do {\n" +
+ " if (cond) continue;\n" +
+ " b2 = false;\n" +
+ " } while (b2);\n" + // complain here: potentially null
+ " Boolean b3 = null;\n" +
+ " do {\n" +
+ " } while (b3);\n" + // complain here: definitely null
+ " Boolean b4 = null;\n" +
+ " do {\n" +
+ " if (cond) {\n" +
+ " b4 = true;\n" +
+ " if (cond2) continue;\n" +
+ " }\n" +
+ " b4 = false;\n" +
+ " } while (b4);\n" + // don't complain here: definitely non-null
+ " Boolean b5 = null;\n" +
+ " do {\n" +
+ " b5 = true;\n" +
+ " } while (b5);\n" + // don't complain
+ " Boolean b6 = null;\n" +
+ " do {\n" +
+ " b6 = true;\n" +
+ " continue;\n" +
+ " } while (b6); \n" + // don't complain
+ " Boolean b7 = null;\n" +
+ " Boolean b8 = null;\n" +
+ " do {\n" +
+ " if (cond) {\n" +
+ " b7 = true;\n" +
+ " continue;\n" +
+ " } else {\n" +
+ " b8 = true;\n" +
+ " }\n" +
+ " } while (b7);\n" + // complain here: after else branch b7 can still be null
+ " }\n" +
+ "}"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 12)\n" +
+ " } while (b2);\n" +
+ " ^^\n" +
+ "Potential null pointer access: The variable b2 may be null at this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 15)\n" +
+ " } while (b3);\n" +
+ " ^^\n" +
+ "Null pointer access: The variable b3 can only be null at this location\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 42)\n" +
+ " } while (b7);\n" +
+ " ^^\n" +
+ "Potential null pointer access: The variable b7 may be null at this location\n" +
+ "----------\n",
+ null/*classLibraries*/,
+ true/*shouldFlushOutputDirectory*/,
+ customOptions);
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=320414
+public void testBug320414() throws Exception {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportNullReference, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_ReportPotentialNullReference, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.ERROR);
+ options.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " static class B {\n" +
+ " public static final int CONST = 16;\n" +
+ " int i;\n" +
+ " }\n" +
+ " B b;\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().foo();\n" +
+ " }\n" +
+ " void foo() {\n" +
+ " B localB = b; \n" +
+ " int i = localB.CONST;\n" +
+ " if (localB != null) {\n" +
+ " i = localB.i;\n" +
+ " }\n" +
+ " System.out.println(i);\n" +
+ " }\n" +
+ "}",
+ },
+ "16",
+ null,
+ true,
+ null,
+ options,
+ null);
+ String expectedOutput =
+ " void foo();\n" +
+ " 0 aload_0 [this]\n" +
+ " 1 getfield X.b : X.B [24]\n" +
+ " 4 astore_1 [localB]\n" +
+ " 5 bipush 16\n" +
+ " 7 istore_2 [i]\n" +
+ " 8 aload_1 [localB]\n" +
+ " 9 ifnull 17\n" +
+ " 12 aload_1 [localB]\n" +
+ " 13 getfield X$B.i : int [26]\n" +
+ " 16 istore_2 [i]\n" +
+ " 17 getstatic java.lang.System.out : java.io.PrintStream [32]\n" +
+ " 20 iload_2 [i]\n" +
+ " 21 invokevirtual java.io.PrintStream.println(int) : void [38]\n" +
+ " 24 return\n";
+ checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=321926
+// To verify that a "redundant null check" warning is NOT elicited for a variable assigned non-null
+// in an infinite while loop inside a try catch block and that code generation shows no surprises.
+public void testBug321926a() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good");
+}
+// Test that dead code warning does show up.
+public void testBug321926b() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " System.out.println(\"This is dead code\");\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 15)\n" +
+ " System.out.println(\"This is dead code\");\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Unreachable code\n" +
+ "----------\n");
+}
+// Check nullness in catch block, finally block and downstream code.
+public void testBug321926c() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " } finally {\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good Compiler good Compiler good");
+}
+// Various nested loops.
+public void testBug321926d() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " for(;;) { \n" +
+ " while (true) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " } finally {\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good Compiler good Compiler good");
+}
+// Test widening catch.
+public void testBug321926e() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (Exception e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good");
+}
+// Tested nested try blocks.
+public void testBug321926f() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i != 0) {\n" +
+ " try {\n" +
+ " throw new IOException();\n" +
+ " } catch (IOException e) {\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"The compiler is buggy\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " throw e;\n" +
+ " }\n" +
+ " } else {\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " }\n" +
+ " } catch (Exception e) {\n" +
+ " // having broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"The compiler is buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"},
+ "Compiler good Compiler good");
+}
+// test for loop
+public void testBug321926g() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " for (int j = 0; true; j++) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good");
+}
+// test do while loop
+public void testBug321926h() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " do {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " } while(true);\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good");
+}
+// test with while (true) with a break inside. was working already.
+public void testBug321926i() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " break;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good");
+}
+// Test with non-explicit throws, i.e call method which throws rather than an inline throw statement.
+public void testBug321926j() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " invokeSomeMethod();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ " public static void invokeSomeMethod() throws IOException {\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ "}"},
+ "Compiler good");
+}
+// Variation with nested loops
+public void testBug321926k() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good Compiler good");
+}
+// variation with nested loops.
+public void testBug321926l() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " someVariable = null;\n"+
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good Compiler good");
+}
+public void testBug321926m() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " if (true) {\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good");
+}
+public void testBug321926n() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " someVariable = \"not null\";\n" +
+ " while (true) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good");
+}
+public void testBug321926o() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " someVariable = \"not null\";\n" +
+ " for(;;) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good");
+}
+public void testBug321926p() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " someVariable = \"not null\";\n" +
+ " do {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " } while (true);\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good");
+}
+public void testBug321926q() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.WARNING);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " someVariable = \"not null\";\n" +
+ " do {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " } while ((someVariable = \"not null\") != null);\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good", null, true, null, options, null);
+}
+public void testBug321926r() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.IGNORE);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while ((someVariable = \"not null\") != null) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good", null, true, null, options, null
+ );
+}
+public void testBug321926s() {
+ Map options = getCompilerOptions();
+ options.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.IGNORE);
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " someVariable = \" not null\";\n" +
+ " while ((someVariable = null) != null) {\n" +
+ " if (i == 0){\n" +
+ " someVariable = \"not null\";\n" +
+ " i++;\n" +
+ " }\n" +
+ " else\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " // broken from loop, continue on\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler buggy\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good", null, true, null, options, null
+ );
+}
+public void testBug321926t() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String s[]) {\n" +
+ " String file = \"non null\";\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0) {\n" +
+ " file = null;\n" +
+ " i++;\n"+
+ " }\n" +
+ " else \n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " }\n" +
+ " if (file == null)\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " else \n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " }\n" +
+ "}\n"},
+ "Compiler good");
+}
+public void testBug321926u() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String s[]) {\n" +
+ " String file = \"non null\";\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0) {\n" +
+ " file = null;\n" +
+ " i++;\n"+
+ " }\n" +
+ " else {\n" +
+ " file = null;\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " }\n" +
+ " if (file == null)\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " else \n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " }\n" +
+ "}\n"},
+ "Compiler good");
+}
+public void testBug321926v() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String s[]) {\n" +
+ " String file = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " while (true) {\n" +
+ " if (i == 0) {\n" +
+ " file = \"non null\";\n" +
+ " i++;\n"+
+ " }\n" +
+ " else {\n" +
+ " file = \"non null\";\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " }\n" +
+ " if (file == null)\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " else \n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ "}\n"},
+ "Compiler good");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317829
+public void testBug317829a() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " someVariable = \"not null\";\n" +
+ " while (true) {\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good Compiler good");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=317829
+public void testBug317829b() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " someVariable = \"not null\";\n" +
+ " while (true) {\n" +
+ " someMethod();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ " public static void someMethod() throws IOException {\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ "}"},
+ "Compiler good Compiler good");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317829
+public void testBug317829c() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " someVariable = \"not null\";\n" +
+ " for (;;) {\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good Compiler good");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=317829
+public void testBug317829d() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " someVariable = \"not null\";\n" +
+ " for(;;) {\n" +
+ " someMethod();\n" +
+ " }\n" +
+ " } catch (IOException e) {\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ " public static void someMethod() throws IOException {\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ "}"},
+ "Compiler good Compiler good");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317829
+public void testBug317829e() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " someVariable = \"not null\";\n" +
+ " do {\n" +
+ " throw new IOException();\n" +
+ " } while (true);\n" +
+ " } catch (IOException e) {\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ "}"},
+ "Compiler good Compiler good");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317829
+public void testBug317829f() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String someVariable = null;\n" +
+ " int i = 0;\n" +
+ " try {\n" +
+ " someVariable = \"not null\";\n" +
+ " do {\n" +
+ " someMethod();\n" +
+ " } while (true);\n" +
+ " } catch (IOException e) {\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.print(\"Compiler good \");\n" +
+ " }\n" +
+ " }\n" +
+ " if (someVariable == null) {\n" +
+ " System.out.println(\"Compiler bad\");\n" +
+ " } else {\n" +
+ " System.out.println(\"Compiler good\");\n" +
+ " }\n" +
+ " }\n" +
+ " public static void someMethod() throws IOException {\n" +
+ " throw new IOException();\n" +
+ " }\n" +
+ "}"},
+ "Compiler good Compiler good");
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment
+// LocalDeclaration
+public void testBug292478() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo(Object o) {\n" +
+ " if (o != null) {/* */}\n" +
+ " Object p = o;\n" +
+ " p.toString();\n" + // complain here
+ " }\n" +
+ "}"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " p.toString();\n" +
+ " ^\n" +
+ "Potential null pointer access: The variable p may be null at this location\n" +
+ "----------\n",
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment
+// Assignment
+public void testBug292478a() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo(Object o) {\n" +
+ " Object p;" +
+ " if (o != null) {/* */}\n" +
+ " p = o;\n" +
+ " p.toString();\n" + // complain here
+ " }\n" +
+ "}"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " p.toString();\n" +
+ " ^\n" +
+ "Potential null pointer access: The variable p may be null at this location\n" +
+ "----------\n",
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment
+// Assignment after definite null
+public void testBug292478b() {
+this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo(Object o) {\n" +
+ " Object p = null;\n" +
+ " if (o != null) {/* */}\n" +
+ " p = o;\n" +
+ " p.toString();\n" + // complain here
+ " }\n" +
+ "}"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " p.toString();\n" +
+ " ^\n" +
+ "Potential null pointer access: The variable p may be null at this location\n" +
+ "----------\n",
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment
+// Assignment after definite null - many locals
+public void testBug292478c() {
+this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo(Object o) {\n" +
+ " int i00, i01, i02, i03, i04, i05, i06, i07, i08, i09;\n" +
+ " int i10, i11, i12, i13, i14, i15, i16, i17, i18, i19;\n" +
+ " int i20, i21, i22, i23, i24, i25, i26, i27, i28, i29;\n" +
+ " int i30, i31, i32, i33, i34, i35, i36, i37, i38, i39;\n" +
+ " int i40, i41, i42, i43, i44, i45, i46, i47, i48, i49;\n" +
+ " int i50, i51, i52, i53, i54, i55, i56, i57, i58, i59;\n" +
+ " int i60, i61, i62, i63, i64, i65, i66, i67, i68, i69;\n" +
+ " Object p = null;\n" +
+ " if (o != null) {/* */}\n" +
+ " p = o;\n" +
+ " p.toString();\n" + // complain here
+ " }\n" +
+ "}"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 13)\n" +
+ " p.toString();\n" +
+ " ^\n" +
+ "Potential null pointer access: The variable p may be null at this location\n" +
+ "----------\n",
+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment
+// Assignment affects initsOnFinally
+public void testBug292478d() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " X bar() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " Object foo() {\n" +
+ " X x = null;\n" +
+ " X y = new X();\n" +
+ " X u = null;\n" +
+ " try {\n" +
+ " u = bar();\n" +
+ " x = bar();\n" +
+ " if (x==null) { }\n" +
+ " y = x;\n" + // this makes y potentially null
+ " if (x==null) { y=bar();} else { y=new X(); }\n" +
+ " return x;\n" +
+ " } finally {\n" +
+ " y.toString();\n" + // must complain against potentially null, although normal exist of tryBlock says differently (unknown or non-null)
+ " }\n" +
+ " }\n" +
+ "}\n"},
+ "----------\n" +
+ "1. ERROR in X.java (at line 17)\n" +
+ " y.toString();\n" +
+ " ^\n" +
+ "Potential null pointer access: The variable y may be null at this location\n" +
+ "----------\n");
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment
+// test regression reported in comment 8
+public void testBug292478e() {
+ this.runConformTest(
+ new String[] {
+ "Test.java",
+ "public class Test {\n" +
+ " Object foo(int i, boolean b1, boolean b2) {\n" +
+ " Object o1 = null;\n" +
+ " done : while (true) { \n" +
+ " switch (i) {\n" +
+ " case 1 :\n" +
+ " Object o2 = null;\n" +
+ " if (b2)\n" +
+ " o2 = new Object();\n" +
+ " o1 = o2;\n" +
+ " break;\n" +
+ " case 2 :\n" +
+ " break done;\n" +
+ " }\n" +
+ " } \n" +
+ " if (o1 != null)\n" +
+ " return o1;\n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n"
+ });
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment
+// variant where regression occurred inside the while-switch structure
+public void testBug292478f() {
+ this.runConformTest(
+ new String[] {
+ "Test.java",
+ "public class Test {\n" +
+ " Object foo(int i, boolean b1, boolean b2) {\n" +
+ " Object o1 = null;\n" +
+ " done : while (true) { \n" +
+ " switch (i) {\n" +
+ " case 1 :\n" +
+ " Object o2 = null;\n" +
+ " if (b2)\n" +
+ " o2 = new Object();\n" +
+ " o1 = o2;\n" +
+ " if (o1 != null)\n" +
+ " return o1;\n" +
+ " break;\n" +
+ " case 2 :\n" +
+ " break done;\n" +
+ " }\n" +
+ " } \n" +
+ " return null;\n" +
+ " }\n" +
+ "}\n"
+ });
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292478 - Report potentially null across variable assignment
+// variant for transfering state potentially unknown
+public void testBug292478g() {
+ this.runConformTest(
+ new String[] {
+ "Test.java",
+ "public class Test {\n" +
+ " Object foo(int i, boolean b1, boolean b2, Object o2) {\n" +
+ " Object o1 = null;\n" +
+ " done : while (true) { \n" +
+ " switch (i) {\n" +
+ " case 1 :\n" +
+ " if (b2)\n" +
+ " o2 = bar();\n" +
+ " o1 = o2;\n" +
+ " if (o1 != null)\n" +
+ " return o1;\n" +
+ " break;\n" +
+ " case 2 :\n" +
+ " break done;\n" +
+ " }\n" +
+ " } \n" +
+ " return null;\n" +
+ " }\n" +
+ " Object bar() { return null; }\n" +
+ "}\n"
+ });
+}
+
+// Bug 324762 - Compiler thinks there is deadcode and removes it!
+// regression caused by the fix for bug 133125
+// ternary is non-null or null
+public void testBug324762() {
+ this.runConformTest(
+ new String[] {
+ "Test.java",
+ "public class Test {\n" +
+ " void zork(boolean b1) {\n" +
+ " Object satisfied = null;\n" +
+ " if (b1) {\n" +
+ " String[] s = new String[] { \"a\", \"b\" };\n" +
+ " for (int k = 0; k < s.length && satisfied == null; k++)\n" +
+ " satisfied = s.length > 1 ? new Object() : null;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ });
+}
+
+// Bug 324762 - Compiler thinks there is deadcode and removes it!
+// regression caused by the fix for bug 133125
+// ternary is unknown or null
+public void testBug324762a() {
+ this.runConformTest(
+ new String[] {
+ "Test.java",
+ "public class Test {\n" +
+ " void zork(boolean b1) {\n" +
+ " Object satisfied = null;\n" +
+ " if (b1) {\n" +
+ " String[] s = new String[] { \"a\", \"b\" };\n" +
+ " for (int k = 0; k < s.length && satisfied == null; k++)\n" +
+ " satisfied = s.length > 1 ? bar() : null;\n" +
+ " }\n" +
+ " }\n" +
+ " Object bar() { return null; }\n" +
+ "}\n"
+ });
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325229
+// instancof expression
+public void testBug325229a() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) {
+ Map compilerOptions = getCompilerOptions();
+ compilerOptions.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.WARNING);
+ this.runConformTest(
+ new String[] {
+ "Test.java",
+ "public class Test {\n" +
+ " void foo(Object a) {\n" +
+ " assert a instanceof Object;\n " +
+ " if (a!=null) {\n" +
+ " System.out.println(\"a is not null\");\n" +
+ " } else{\n" +
+ " System.out.println(\"a is null\");\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args){\n" +
+ " Test test = new Test();\n" +
+ " test.foo(null);\n" +
+ " }\n" +
+ "}\n"},
+ "a is null",
+ null,
+ true,
+ new String[] {"-da"},
+ compilerOptions,
+ null);
+ }
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325229
+// MessageSend in assert
+public void testBug325229b() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) {
+ Map compilerOptions = getCompilerOptions();
+ compilerOptions.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.WARNING);
+ this.runConformTest(
+ new String[] {
+ "Test.java",
+ "public class Test {\n" +
+ " boolean bar() {\n" +
+ " return false;\n" +
+ " }" +
+ " void foo(Test a) {\n" +
+ " assert a.bar();\n " +
+ " if (a!=null) {\n" +
+ " System.out.println(\"a is not null\");\n" +
+ " } else{\n" +
+ " System.out.println(\"a is null\");\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args){\n" +
+ " Test test = new Test();\n" +
+ " test.foo(null);\n" +
+ " }\n" +
+ "}\n"},
+ "a is null",
+ null,
+ true,
+ new String[] {"-da"},
+ compilerOptions,
+ null);
+ }
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325229
+// QualifiedNameReference in assert
+public void testBug325229c() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) {
+ Map compilerOptions = getCompilerOptions();
+ compilerOptions.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.WARNING);
+ this.runConformTest(
+ new String[] {
+ "Test.java",
+ "public class Test {\n" +
+ " boolean bar() {\n" +
+ " return false;\n" +
+ " }" +
+ " Test tfield;\n" +
+ " void foo(Test a) {\n" +
+ " assert a.tfield.bar();\n " +
+ " if (a!=null) {\n" +
+ " System.out.println(\"a is not null\");\n" +
+ " } else{\n" +
+ " System.out.println(\"a is null\");\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args){\n" +
+ " Test test = new Test();\n" +
+ " test.foo(null);\n" +
+ " }\n" +
+ "}\n"},
+ "a is null",
+ null,
+ true,
+ new String[] {"-da"},
+ compilerOptions,
+ null);
+ }
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325229
+// EqualExpression in assert, comparison against non null
+public void testBug325229d() {
+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) {
+ Map compilerOptions = getCompilerOptions();
+ compilerOptions.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.WARNING);
+ this.runConformTest(
+ new String[] {
+ "Test.java",
+ "public class Test {\n" +
+ " void foo(Object a) {\n" +
+ " Object b = null;" +
+ " assert a == b;\n " +
+ " if (a!=null) {\n" +
+ " System.out.println(\"a is not null\");\n" +
+ " } else{\n" +
+ " System.out.println(\"a is null\");\n" +
+ " }\n" +
+ " assert a != b;\n " +
+ " if (a!=null) {\n" +
+ " System.out.println(\"a is not null\");\n" +
+ " } else{\n" +
+ " System.out.println(\"a is null\");\n" +
+ " }\n" +
+ " }\n" +
+ " public static void main(String[] args){\n" +
+ " Test test = new Test();\n" +
+ " test.foo(null);\n" +
+ " }\n" +
+ "}\n"},
+ "a is null\n" +
+ "a is null",
+ null,
+ true,
+ new String[] {"-da"},
+ compilerOptions,
+ null);
+ }
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325755
+// null analysis -- conditional expression
+public void testBug325755a() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static Object foo(String s1, String s2) {\n" +
+ " String local1 = s1;\n" +
+ " String local2 = s2;\n" +
+ " \n" +
+ " String local3 = null;\n" +
+ " if (local1 != null && local2 != null)\n" +
+ " local3 = \"\"; //$NON-NLS-1$\n" +
+ " else\n" +
+ " local3 = local1 != null ? local1 : local2;\n" +
+ "\n" +
+ " if (local3 != null)\n" +
+ " return new Integer(local3.length());\n" +
+ " return null;\n" +
+ " }\n" +
+ " \n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(foo(null, null));\n" +
+ " System.out.print(foo(\"p1\", null));\n" +
+ " System.out.print(foo(null, \"p2\"));\n" +
+ " System.out.print(foo(\"p1\", \"p2\"));\n" +
+ " }\n" +
+ "}"},
+ "null220");
+}
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325755
+// null analysis -- conditional expression, many locals
+public void testBug325755b() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static Object foo(String s1, String s2) {\n" +
+ " int i00, i01, i02, i03, i04, i05, i06, i07, i08, i09;\n" +
+ " int i10, i11, i12, i13, i14, i15, i16, i17, i18, i19;\n" +
+ " int i20, i21, i22, i23, i24, i25, i26, i27, i28, i29;\n" +
+ " int i30, i31, i32, i33, i34, i35, i36, i37, i38, i39;\n" +
+ " int i40, i41, i42, i43, i44, i45, i46, i47, i48, i49;\n" +
+ " int i50, i51, i52, i53, i54, i55, i56, i57, i58, i59;\n" +
+ " int i60, i61, i62, i63, i64, i65, i66, i67, i68, i69;\n" +
+
+ " String local1 = s1;\n" +
+ " String local2 = s2;\n" +
+ " \n" +
+ " String local3 = null;\n" +
+ " if (local1 != null && local2 != null)\n" +
+ " local3 = \"\"; //$NON-NLS-1$\n" +
+ " else\n" +
+ " local3 = local1 != null ? local1 : local2;\n" +
+ "\n" +
+ " if (local3 != null)\n" +
+ " return new Integer(local3.length());\n" +
+ " return null;\n" +
+ " }\n" +
+ " \n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.print(foo(null, null));\n" +
+ " System.out.print(foo(\"p1\", null));\n" +
+ " System.out.print(foo(null, \"p2\"));\n" +
+ " System.out.print(foo(\"p1\", \"p2\"));\n" +
+ " }\n" +
+ "}"},
+ "null220");
+}
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java
index af7f856d4..ce281f204 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java
@@ -31,8 +31,8 @@ public ProblemTypeAndMethodTest(String name) {
// All specified tests which does not belong to the class are skipped...
static {
// TESTS_NAMES = new String[] { "test127" };
-// TESTS_NUMBERS = new int[] { 104 };
-// TESTS_RANGE = new int[] { 169, 180 };
+// TESTS_NUMBERS = new int[] { 113 };
+// TESTS_RANGE = new int[] { 108, -1 };
}
public static Test suite() {
@@ -5339,4 +5339,552 @@ public void test106() {
"Listener cannot be resolved to a type\n" +
"----------\n");
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=319425
+public void test107() {
+ this.runNegativeTest(
+ new String[] {
+ "p/OuterBogus.java", //-----------------------------------------------------------------------
+ "package p;\n" +
+ "abstract final class OuterBogus {\n" +
+ " public static void call() {\n" +
+ " System.out.println(\"Hi. I'm outer bogus.\");\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in p\\OuterBogus.java (at line 2)\n" +
+ " abstract final class OuterBogus {\n" +
+ " ^^^^^^^^^^\n" +
+ "The class OuterBogus can be either abstract or final, not both\n" +
+ "----------\n",
+ null /* no extra class libraries */,
+ true /* flush output directory */,
+ null /* no custom options */,
+ true /* do not generate output */,
+ false /* do not show category */,
+ false /* do not show warning token */,
+ false /* do not skip javac for this peculiar test */,
+ false /* do not perform statements recovery */);
+ this.runConformTest(
+ new String[] {
+ "p/Bogus.java", //-----------------------------------------------------------------------
+ "package p;\n" +
+ "\n" +
+ "public class Bogus {\n" +
+ " public static void main(String[] args) {\n" +
+ " try {\n" +
+ " OuterBogus.call();\n" +
+ " } catch(ClassFormatError e) {\n" +
+ " System.out.println(\"Wrong error found\");\n" +
+ " } catch(Error e) {\n" +
+ " System.out.println(\"Compilation error found\");\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ },
+ "Compilation error found",
+ null,
+ false,
+ null);
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=321414
+public void test108() {
+ if (this.complianceLevel <= ClassFileConstants.JDK1_4) return;
+ this.runNegativeTest(
+ new String[] {
+ "SyntheticConstructorTooManyArgs.java", //-----------------------------------------------------------------------
+ "public class SyntheticConstructorTooManyArgs {\n" +
+ "\n" +
+ " static class A {\n" +
+ " private A(\n" +
+ " /*this,*/int p01, int p02, int p03, int p04, int p05, int p06, int p07, int p08, int p09, int p0a, int p0b, int p0c, int p0d, int p0e, int p0f, \n" +
+ " int p10, int p11, int p12, int p13, int p14, int p15, int p16, int p17, int p18, int p19, int p1a, int p1b, int p1c, int p1d, int p1e, int p1f, \n" +
+ " int p20, int p21, int p22, int p23, int p24, int p25, int p26, int p27, int p28, int p29, int p2a, int p2b, int p2c, int p2d, int p2e, int p2f, \n" +
+ " int p30, int p31, int p32, int p33, int p34, int p35, int p36, int p37, int p38, int p39, int p3a, int p3b, int p3c, int p3d, int p3e, int p3f, \n" +
+ " int p40, int p41, int p42, int p43, int p44, int p45, int p46, int p47, int p48, int p49, int p4a, int p4b, int p4c, int p4d, int p4e, int p4f, \n" +
+ " int p50, int p51, int p52, int p53, int p54, int p55, int p56, int p57, int p58, int p59, int p5a, int p5b, int p5c, int p5d, int p5e, int p5f, \n" +
+ " int p60, int p61, int p62, int p63, int p64, int p65, int p66, int p67, int p68, int p69, int p6a, int p6b, int p6c, int p6d, int p6e, int p6f, \n" +
+ " int p70, int p71, int p72, int p73, int p74, int p75, int p76, int p77, int p78, int p79, int p7a, int p7b, int p7c, int p7d, int p7e, int p7f, \n" +
+ " int p80, int p81, int p82, int p83, int p84, int p85, int p86, int p87, int p88, int p89, int p8a, int p8b, int p8c, int p8d, int p8e, int p8f, \n" +
+ " int p90, int p91, int p92, int p93, int p94, int p95, int p96, int p97, int p98, int p99, int p9a, int p9b, int p9c, int p9d, int p9e, int p9f, \n" +
+ " int pa0, int pa1, int pa2, int pa3, int pa4, int pa5, int pa6, int pa7, int pa8, int pa9, int paa, int pab, int pac, int pad, int pae, int paf, \n" +
+ " int pb0, int pb1, int pb2, int pb3, int pb4, int pb5, int pb6, int pb7, int pb8, int pb9, int pba, int pbb, int pbc, int pbd, int pbe, int pbf, \n" +
+ " int pc0, int pc1, int pc2, int pc3, int pc4, int pc5, int pc6, int pc7, int pc8, int pc9, int pca, int pcb, int pcc, int pcd, int pce, int pcf, \n" +
+ " int pd0, int pd1, int pd2, int pd3, int pd4, int pd5, int pd6, int pd7, int pd8, int pd9, int pda, int pdb, int pdc, int pdd, int pde, int pdf, \n" +
+ " int pe0, int pe1, int pe2, int pe3, int pe4, int pe5, int pe6, int pe7, int pe8, int pe9, int pea, int peb, int pec, int ped, int pee, int pef, \n" +
+ " int pf0, int pf1, int pf2, int pf3, int pf4, int pf5, int pf6, int pf7, int pf8, int pf9, int pfa, int pfb, int pfc, int pfd, int pfe\n" +
+ " ) {}\n" +
+ " }\n" +
+ " @SuppressWarnings(\"synthetic-access\")\n" +
+ " A a = new A(\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n" +
+ " );\n" +
+ " public static void main(String[] args) {\n" +
+ " StringBuilder params = new StringBuilder();\n" +
+ " params.append(\"/*this,*/\");\n" +
+ " for (int p = 1; p < 255; p++) {\n" +
+ " if (p > 1) {\n" +
+ " params.append(\", \");\n" +
+ " if (p % 16 == 0)\n" +
+ " params.append('\\n');\n" +
+ " }\n" +
+ " params.append(\"int p\"\n" +
+ " + Character.forDigit(p / 16, 16)\n" +
+ " + Character.forDigit(p % 16, 16)\n" +
+ " );\n" +
+ " }\n" +
+ " System.out.println(params);\n" +
+ " A.class.getName(); // ClassFormatError\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in SyntheticConstructorTooManyArgs.java (at line 4)\n" +
+ " private A(\n" +
+ " /*this,*/int p01, int p02, int p03, int p04, int p05, int p06, int p07, int p08, int p09, int p0a, int p0b, int p0c, int p0d, int p0e, int p0f, \n" +
+ " int p10, int p11, int p12, int p13, int p14, int p15, int p16, int p17, int p18, int p19, int p1a, int p1b, int p1c, int p1d, int p1e, int p1f, \n" +
+ " int p20, int p21, int p22, int p23, int p24, int p25, int p26, int p27, int p28, int p29, int p2a, int p2b, int p2c, int p2d, int p2e, int p2f, \n" +
+ " int p30, int p31, int p32, int p33, int p34, int p35, int p36, int p37, int p38, int p39, int p3a, int p3b, int p3c, int p3d, int p3e, int p3f, \n" +
+ " int p40, int p41, int p42, int p43, int p44, int p45, int p46, int p47, int p48, int p49, int p4a, int p4b, int p4c, int p4d, int p4e, int p4f, \n" +
+ " int p50, int p51, int p52, int p53, int p54, int p55, int p56, int p57, int p58, int p59, int p5a, int p5b, int p5c, int p5d, int p5e, int p5f, \n" +
+ " int p60, int p61, int p62, int p63, int p64, int p65, int p66, int p67, int p68, int p69, int p6a, int p6b, int p6c, int p6d, int p6e, int p6f, \n" +
+ " int p70, int p71, int p72, int p73, int p74, int p75, int p76, int p77, int p78, int p79, int p7a, int p7b, int p7c, int p7d, int p7e, int p7f, \n" +
+ " int p80, int p81, int p82, int p83, int p84, int p85, int p86, int p87, int p88, int p89, int p8a, int p8b, int p8c, int p8d, int p8e, int p8f, \n" +
+ " int p90, int p91, int p92, int p93, int p94, int p95, int p96, int p97, int p98, int p99, int p9a, int p9b, int p9c, int p9d, int p9e, int p9f, \n" +
+ " int pa0, int pa1, int pa2, int pa3, int pa4, int pa5, int pa6, int pa7, int pa8, int pa9, int paa, int pab, int pac, int pad, int pae, int paf, \n" +
+ " int pb0, int pb1, int pb2, int pb3, int pb4, int pb5, int pb6, int pb7, int pb8, int pb9, int pba, int pbb, int pbc, int pbd, int pbe, int pbf, \n" +
+ " int pc0, int pc1, int pc2, int pc3, int pc4, int pc5, int pc6, int pc7, int pc8, int pc9, int pca, int pcb, int pcc, int pcd, int pce, int pcf, \n" +
+ " int pd0, int pd1, int pd2, int pd3, int pd4, int pd5, int pd6, int pd7, int pd8, int pd9, int pda, int pdb, int pdc, int pdd, int pde, int pdf, \n" +
+ " int pe0, int pe1, int pe2, int pe3, int pe4, int pe5, int pe6, int pe7, int pe8, int pe9, int pea, int peb, int pec, int ped, int pee, int pef, \n" +
+ " int pf0, int pf1, int pf2, int pf3, int pf4, int pf5, int pf6, int pf7, int pf8, int pf9, int pfa, int pfb, int pfc, int pfd, int pfe\n" +
+ " ) {}\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The synthetic method created to access A(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) of type SyntheticConstructorTooManyArgs.A has too many parameters\n" +
+ "----------\n");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=321414
+public void test109() {
+ if (this.complianceLevel <= ClassFileConstants.JDK1_4) return;
+ this.runConformTest(
+ new String[] {
+ "SyntheticConstructorTooManyArgs.java", //-----------------------------------------------------------------------
+ "public class SyntheticConstructorTooManyArgs {\n" +
+ "\n" +
+ " static class A {\n" +
+ " private A foo(\n" +
+ " /*this,*/int p01, int p02, int p03, int p04, int p05, int p06, int p07, int p08, int p09, int p0a, int p0b, int p0c, int p0d, int p0e, int p0f, \n" +
+ " int p10, int p11, int p12, int p13, int p14, int p15, int p16, int p17, int p18, int p19, int p1a, int p1b, int p1c, int p1d, int p1e, int p1f, \n" +
+ " int p20, int p21, int p22, int p23, int p24, int p25, int p26, int p27, int p28, int p29, int p2a, int p2b, int p2c, int p2d, int p2e, int p2f, \n" +
+ " int p30, int p31, int p32, int p33, int p34, int p35, int p36, int p37, int p38, int p39, int p3a, int p3b, int p3c, int p3d, int p3e, int p3f, \n" +
+ " int p40, int p41, int p42, int p43, int p44, int p45, int p46, int p47, int p48, int p49, int p4a, int p4b, int p4c, int p4d, int p4e, int p4f, \n" +
+ " int p50, int p51, int p52, int p53, int p54, int p55, int p56, int p57, int p58, int p59, int p5a, int p5b, int p5c, int p5d, int p5e, int p5f, \n" +
+ " int p60, int p61, int p62, int p63, int p64, int p65, int p66, int p67, int p68, int p69, int p6a, int p6b, int p6c, int p6d, int p6e, int p6f, \n" +
+ " int p70, int p71, int p72, int p73, int p74, int p75, int p76, int p77, int p78, int p79, int p7a, int p7b, int p7c, int p7d, int p7e, int p7f, \n" +
+ " int p80, int p81, int p82, int p83, int p84, int p85, int p86, int p87, int p88, int p89, int p8a, int p8b, int p8c, int p8d, int p8e, int p8f, \n" +
+ " int p90, int p91, int p92, int p93, int p94, int p95, int p96, int p97, int p98, int p99, int p9a, int p9b, int p9c, int p9d, int p9e, int p9f, \n" +
+ " int pa0, int pa1, int pa2, int pa3, int pa4, int pa5, int pa6, int pa7, int pa8, int pa9, int paa, int pab, int pac, int pad, int pae, int paf, \n" +
+ " int pb0, int pb1, int pb2, int pb3, int pb4, int pb5, int pb6, int pb7, int pb8, int pb9, int pba, int pbb, int pbc, int pbd, int pbe, int pbf, \n" +
+ " int pc0, int pc1, int pc2, int pc3, int pc4, int pc5, int pc6, int pc7, int pc8, int pc9, int pca, int pcb, int pcc, int pcd, int pce, int pcf, \n" +
+ " int pd0, int pd1, int pd2, int pd3, int pd4, int pd5, int pd6, int pd7, int pd8, int pd9, int pda, int pdb, int pdc, int pdd, int pde, int pdf, \n" +
+ " int pe0, int pe1, int pe2, int pe3, int pe4, int pe5, int pe6, int pe7, int pe8, int pe9, int pea, int peb, int pec, int ped, int pee, int pef, \n" +
+ " int pf0, int pf1, int pf2, int pf3, int pf4, int pf5, int pf6, int pf7, int pf8, int pf9, int pfa, int pfb, int pfc, int pfd, int pfe\n" +
+ " ) { return new A();}\n" +
+ " }\n" +
+ " @SuppressWarnings(\"synthetic-access\")\n" +
+ " A a = new A().foo(\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n" +
+ " );\n" +
+ " public static void main(String[] args) {\n" +
+ " StringBuilder params = new StringBuilder();\n" +
+ " params.append(\"/*this,*/\");\n" +
+ " for (int p = 1; p < 255; p++) {\n" +
+ " if (p > 1) {\n" +
+ " params.append(\", \");\n" +
+ " if (p % 16 == 0)\n" +
+ " params.append('\\n');\n" +
+ " }\n" +
+ " params.append(\"int p\"\n" +
+ " + Character.forDigit(p / 16, 16)\n" +
+ " + Character.forDigit(p % 16, 16)\n" +
+ " );\n" +
+ " }\n" +
+ " System.out.println(params);\n" +
+ " A.class.getName(); // ClassFormatError\n" +
+ " }\n" +
+ "}",
+ },
+ "/*this,*/int p01, int p02, int p03, int p04, int p05, int p06, int p07, int p08, int p09, int p0a, int p0b, int p0c, int p0d, int p0e, int p0f, \n" +
+ "int p10, int p11, int p12, int p13, int p14, int p15, int p16, int p17, int p18, int p19, int p1a, int p1b, int p1c, int p1d, int p1e, int p1f, \n" +
+ "int p20, int p21, int p22, int p23, int p24, int p25, int p26, int p27, int p28, int p29, int p2a, int p2b, int p2c, int p2d, int p2e, int p2f, \n" +
+ "int p30, int p31, int p32, int p33, int p34, int p35, int p36, int p37, int p38, int p39, int p3a, int p3b, int p3c, int p3d, int p3e, int p3f, \n" +
+ "int p40, int p41, int p42, int p43, int p44, int p45, int p46, int p47, int p48, int p49, int p4a, int p4b, int p4c, int p4d, int p4e, int p4f, \n" +
+ "int p50, int p51, int p52, int p53, int p54, int p55, int p56, int p57, int p58, int p59, int p5a, int p5b, int p5c, int p5d, int p5e, int p5f, \n" +
+ "int p60, int p61, int p62, int p63, int p64, int p65, int p66, int p67, int p68, int p69, int p6a, int p6b, int p6c, int p6d, int p6e, int p6f, \n" +
+ "int p70, int p71, int p72, int p73, int p74, int p75, int p76, int p77, int p78, int p79, int p7a, int p7b, int p7c, int p7d, int p7e, int p7f, \n" +
+ "int p80, int p81, int p82, int p83, int p84, int p85, int p86, int p87, int p88, int p89, int p8a, int p8b, int p8c, int p8d, int p8e, int p8f, \n" +
+ "int p90, int p91, int p92, int p93, int p94, int p95, int p96, int p97, int p98, int p99, int p9a, int p9b, int p9c, int p9d, int p9e, int p9f, \n" +
+ "int pa0, int pa1, int pa2, int pa3, int pa4, int pa5, int pa6, int pa7, int pa8, int pa9, int paa, int pab, int pac, int pad, int pae, int paf, \n" +
+ "int pb0, int pb1, int pb2, int pb3, int pb4, int pb5, int pb6, int pb7, int pb8, int pb9, int pba, int pbb, int pbc, int pbd, int pbe, int pbf, \n" +
+ "int pc0, int pc1, int pc2, int pc3, int pc4, int pc5, int pc6, int pc7, int pc8, int pc9, int pca, int pcb, int pcc, int pcd, int pce, int pcf, \n" +
+ "int pd0, int pd1, int pd2, int pd3, int pd4, int pd5, int pd6, int pd7, int pd8, int pd9, int pda, int pdb, int pdc, int pdd, int pde, int pdf, \n" +
+ "int pe0, int pe1, int pe2, int pe3, int pe4, int pe5, int pe6, int pe7, int pe8, int pe9, int pea, int peb, int pec, int ped, int pee, int pef, \n" +
+ "int pf0, int pf1, int pf2, int pf3, int pf4, int pf5, int pf6, int pf7, int pf8, int pf9, int pfa, int pfb, int pfc, int pfd, int pfe");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=321414
+public void test110() {
+ if (this.complianceLevel <= ClassFileConstants.JDK1_4) return;
+ this.runConformTest(
+ new String[] {
+ "SyntheticConstructorTooManyArgs.java", //-----------------------------------------------------------------------
+ "public class SyntheticConstructorTooManyArgs {\n" +
+ "\n" +
+ " static class A {\n" +
+ " private static A foo(\n" +
+ " /*this,*/int p01, int p02, int p03, int p04, int p05, int p06, int p07, int p08, int p09, int p0a, int p0b, int p0c, int p0d, int p0e, int p0f, \n" +
+ " int p10, int p11, int p12, int p13, int p14, int p15, int p16, int p17, int p18, int p19, int p1a, int p1b, int p1c, int p1d, int p1e, int p1f, \n" +
+ " int p20, int p21, int p22, int p23, int p24, int p25, int p26, int p27, int p28, int p29, int p2a, int p2b, int p2c, int p2d, int p2e, int p2f, \n" +
+ " int p30, int p31, int p32, int p33, int p34, int p35, int p36, int p37, int p38, int p39, int p3a, int p3b, int p3c, int p3d, int p3e, int p3f, \n" +
+ " int p40, int p41, int p42, int p43, int p44, int p45, int p46, int p47, int p48, int p49, int p4a, int p4b, int p4c, int p4d, int p4e, int p4f, \n" +
+ " int p50, int p51, int p52, int p53, int p54, int p55, int p56, int p57, int p58, int p59, int p5a, int p5b, int p5c, int p5d, int p5e, int p5f, \n" +
+ " int p60, int p61, int p62, int p63, int p64, int p65, int p66, int p67, int p68, int p69, int p6a, int p6b, int p6c, int p6d, int p6e, int p6f, \n" +
+ " int p70, int p71, int p72, int p73, int p74, int p75, int p76, int p77, int p78, int p79, int p7a, int p7b, int p7c, int p7d, int p7e, int p7f, \n" +
+ " int p80, int p81, int p82, int p83, int p84, int p85, int p86, int p87, int p88, int p89, int p8a, int p8b, int p8c, int p8d, int p8e, int p8f, \n" +
+ " int p90, int p91, int p92, int p93, int p94, int p95, int p96, int p97, int p98, int p99, int p9a, int p9b, int p9c, int p9d, int p9e, int p9f, \n" +
+ " int pa0, int pa1, int pa2, int pa3, int pa4, int pa5, int pa6, int pa7, int pa8, int pa9, int paa, int pab, int pac, int pad, int pae, int paf, \n" +
+ " int pb0, int pb1, int pb2, int pb3, int pb4, int pb5, int pb6, int pb7, int pb8, int pb9, int pba, int pbb, int pbc, int pbd, int pbe, int pbf, \n" +
+ " int pc0, int pc1, int pc2, int pc3, int pc4, int pc5, int pc6, int pc7, int pc8, int pc9, int pca, int pcb, int pcc, int pcd, int pce, int pcf, \n" +
+ " int pd0, int pd1, int pd2, int pd3, int pd4, int pd5, int pd6, int pd7, int pd8, int pd9, int pda, int pdb, int pdc, int pdd, int pde, int pdf, \n" +
+ " int pe0, int pe1, int pe2, int pe3, int pe4, int pe5, int pe6, int pe7, int pe8, int pe9, int pea, int peb, int pec, int ped, int pee, int pef, \n" +
+ " int pf0, int pf1, int pf2, int pf3, int pf4, int pf5, int pf6, int pf7, int pf8, int pf9, int pfa, int pfb, int pfc, int pfd, int pfe\n" +
+ " ) { return new A();}\n" +
+ " }\n" +
+ " @SuppressWarnings(\"synthetic-access\")\n" +
+ " A a = A.foo(\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n" +
+ " );\n" +
+ " public static void main(String[] args) {\n" +
+ " StringBuilder params = new StringBuilder();\n" +
+ " params.append(\"/*this,*/\");\n" +
+ " for (int p = 1; p < 255; p++) {\n" +
+ " if (p > 1) {\n" +
+ " params.append(\", \");\n" +
+ " if (p % 16 == 0)\n" +
+ " params.append('\\n');\n" +
+ " }\n" +
+ " params.append(\"int p\"\n" +
+ " + Character.forDigit(p / 16, 16)\n" +
+ " + Character.forDigit(p % 16, 16)\n" +
+ " );\n" +
+ " }\n" +
+ " System.out.println(params);\n" +
+ " A.class.getName(); // ClassFormatError\n" +
+ " }\n" +
+ "}",
+ },
+ "/*this,*/int p01, int p02, int p03, int p04, int p05, int p06, int p07, int p08, int p09, int p0a, int p0b, int p0c, int p0d, int p0e, int p0f, \n" +
+ "int p10, int p11, int p12, int p13, int p14, int p15, int p16, int p17, int p18, int p19, int p1a, int p1b, int p1c, int p1d, int p1e, int p1f, \n" +
+ "int p20, int p21, int p22, int p23, int p24, int p25, int p26, int p27, int p28, int p29, int p2a, int p2b, int p2c, int p2d, int p2e, int p2f, \n" +
+ "int p30, int p31, int p32, int p33, int p34, int p35, int p36, int p37, int p38, int p39, int p3a, int p3b, int p3c, int p3d, int p3e, int p3f, \n" +
+ "int p40, int p41, int p42, int p43, int p44, int p45, int p46, int p47, int p48, int p49, int p4a, int p4b, int p4c, int p4d, int p4e, int p4f, \n" +
+ "int p50, int p51, int p52, int p53, int p54, int p55, int p56, int p57, int p58, int p59, int p5a, int p5b, int p5c, int p5d, int p5e, int p5f, \n" +
+ "int p60, int p61, int p62, int p63, int p64, int p65, int p66, int p67, int p68, int p69, int p6a, int p6b, int p6c, int p6d, int p6e, int p6f, \n" +
+ "int p70, int p71, int p72, int p73, int p74, int p75, int p76, int p77, int p78, int p79, int p7a, int p7b, int p7c, int p7d, int p7e, int p7f, \n" +
+ "int p80, int p81, int p82, int p83, int p84, int p85, int p86, int p87, int p88, int p89, int p8a, int p8b, int p8c, int p8d, int p8e, int p8f, \n" +
+ "int p90, int p91, int p92, int p93, int p94, int p95, int p96, int p97, int p98, int p99, int p9a, int p9b, int p9c, int p9d, int p9e, int p9f, \n" +
+ "int pa0, int pa1, int pa2, int pa3, int pa4, int pa5, int pa6, int pa7, int pa8, int pa9, int paa, int pab, int pac, int pad, int pae, int paf, \n" +
+ "int pb0, int pb1, int pb2, int pb3, int pb4, int pb5, int pb6, int pb7, int pb8, int pb9, int pba, int pbb, int pbc, int pbd, int pbe, int pbf, \n" +
+ "int pc0, int pc1, int pc2, int pc3, int pc4, int pc5, int pc6, int pc7, int pc8, int pc9, int pca, int pcb, int pcc, int pcd, int pce, int pcf, \n" +
+ "int pd0, int pd1, int pd2, int pd3, int pd4, int pd5, int pd6, int pd7, int pd8, int pd9, int pda, int pdb, int pdc, int pdd, int pde, int pdf, \n" +
+ "int pe0, int pe1, int pe2, int pe3, int pe4, int pe5, int pe6, int pe7, int pe8, int pe9, int pea, int peb, int pec, int ped, int pee, int pef, \n" +
+ "int pf0, int pf1, int pf2, int pf3, int pf4, int pf5, int pf6, int pf7, int pf8, int pf9, int pfa, int pfb, int pfc, int pfd, int pfe");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=321414
+public void test111() {
+ if (this.complianceLevel <= ClassFileConstants.JDK1_4) return;
+ this.runNegativeTest(
+ new String[] {
+ "SyntheticConstructorTooManyArgs.java", //-----------------------------------------------------------------------
+ "public class SyntheticConstructorTooManyArgs {\n" +
+ "\n" +
+ " class A {\n" +
+ " private A(\n" +
+ " /*this,*/int p01, int p02, int p03, int p04, int p05, int p06, int p07, int p08, int p09, int p0a, int p0b, int p0c, int p0d, int p0e, int p0f, \n" +
+ " int p10, int p11, int p12, int p13, int p14, int p15, int p16, int p17, int p18, int p19, int p1a, int p1b, int p1c, int p1d, int p1e, int p1f, \n" +
+ " int p20, int p21, int p22, int p23, int p24, int p25, int p26, int p27, int p28, int p29, int p2a, int p2b, int p2c, int p2d, int p2e, int p2f, \n" +
+ " int p30, int p31, int p32, int p33, int p34, int p35, int p36, int p37, int p38, int p39, int p3a, int p3b, int p3c, int p3d, int p3e, int p3f, \n" +
+ " int p40, int p41, int p42, int p43, int p44, int p45, int p46, int p47, int p48, int p49, int p4a, int p4b, int p4c, int p4d, int p4e, int p4f, \n" +
+ " int p50, int p51, int p52, int p53, int p54, int p55, int p56, int p57, int p58, int p59, int p5a, int p5b, int p5c, int p5d, int p5e, int p5f, \n" +
+ " int p60, int p61, int p62, int p63, int p64, int p65, int p66, int p67, int p68, int p69, int p6a, int p6b, int p6c, int p6d, int p6e, int p6f, \n" +
+ " int p70, int p71, int p72, int p73, int p74, int p75, int p76, int p77, int p78, int p79, int p7a, int p7b, int p7c, int p7d, int p7e, int p7f, \n" +
+ " int p80, int p81, int p82, int p83, int p84, int p85, int p86, int p87, int p88, int p89, int p8a, int p8b, int p8c, int p8d, int p8e, int p8f, \n" +
+ " int p90, int p91, int p92, int p93, int p94, int p95, int p96, int p97, int p98, int p99, int p9a, int p9b, int p9c, int p9d, int p9e, int p9f, \n" +
+ " int pa0, int pa1, int pa2, int pa3, int pa4, int pa5, int pa6, int pa7, int pa8, int pa9, int paa, int pab, int pac, int pad, int pae, int paf, \n" +
+ " int pb0, int pb1, int pb2, int pb3, int pb4, int pb5, int pb6, int pb7, int pb8, int pb9, int pba, int pbb, int pbc, int pbd, int pbe, int pbf, \n" +
+ " int pc0, int pc1, int pc2, int pc3, int pc4, int pc5, int pc6, int pc7, int pc8, int pc9, int pca, int pcb, int pcc, int pcd, int pce, int pcf, \n" +
+ " int pd0, int pd1, int pd2, int pd3, int pd4, int pd5, int pd6, int pd7, int pd8, int pd9, int pda, int pdb, int pdc, int pdd, int pde, int pdf, \n" +
+ " int pe0, int pe1, int pe2, int pe3, int pe4, int pe5, int pe6, int pe7, int pe8, int pe9, int pea, int peb, int pec, int ped, int pee, int pef, \n" +
+ " int pf0, int pf1, int pf2, int pf3, int pf4, int pf5, int pf6, int pf7, int pf8, int pf9, int pfa, int pfb, int pfc, int pfd\n" +
+ " ) {}\n" +
+ " }\n" +
+ " @SuppressWarnings(\"synthetic-access\")\n" +
+ " A a = new A(\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0\n" +
+ " );\n" +
+ " public static void main(String[] args) {\n" +
+ " StringBuilder params = new StringBuilder();\n" +
+ " params.append(\"/*this,*/\");\n" +
+ " for (int p = 1; p < 255; p++) {\n" +
+ " if (p > 1) {\n" +
+ " params.append(\", \");\n" +
+ " if (p % 16 == 0)\n" +
+ " params.append('\\n');\n" +
+ " }\n" +
+ " params.append(\"int p\"\n" +
+ " + Character.forDigit(p / 16, 16)\n" +
+ " + Character.forDigit(p % 16, 16)\n" +
+ " );\n" +
+ " }\n" +
+ " System.out.println(params);\n" +
+ " A.class.getName(); // ClassFormatError\n" +
+ " }\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in SyntheticConstructorTooManyArgs.java (at line 4)\n" +
+ " private A(\n" +
+ " /*this,*/int p01, int p02, int p03, int p04, int p05, int p06, int p07, int p08, int p09, int p0a, int p0b, int p0c, int p0d, int p0e, int p0f, \n" +
+ " int p10, int p11, int p12, int p13, int p14, int p15, int p16, int p17, int p18, int p19, int p1a, int p1b, int p1c, int p1d, int p1e, int p1f, \n" +
+ " int p20, int p21, int p22, int p23, int p24, int p25, int p26, int p27, int p28, int p29, int p2a, int p2b, int p2c, int p2d, int p2e, int p2f, \n" +
+ " int p30, int p31, int p32, int p33, int p34, int p35, int p36, int p37, int p38, int p39, int p3a, int p3b, int p3c, int p3d, int p3e, int p3f, \n" +
+ " int p40, int p41, int p42, int p43, int p44, int p45, int p46, int p47, int p48, int p49, int p4a, int p4b, int p4c, int p4d, int p4e, int p4f, \n" +
+ " int p50, int p51, int p52, int p53, int p54, int p55, int p56, int p57, int p58, int p59, int p5a, int p5b, int p5c, int p5d, int p5e, int p5f, \n" +
+ " int p60, int p61, int p62, int p63, int p64, int p65, int p66, int p67, int p68, int p69, int p6a, int p6b, int p6c, int p6d, int p6e, int p6f, \n" +
+ " int p70, int p71, int p72, int p73, int p74, int p75, int p76, int p77, int p78, int p79, int p7a, int p7b, int p7c, int p7d, int p7e, int p7f, \n" +
+ " int p80, int p81, int p82, int p83, int p84, int p85, int p86, int p87, int p88, int p89, int p8a, int p8b, int p8c, int p8d, int p8e, int p8f, \n" +
+ " int p90, int p91, int p92, int p93, int p94, int p95, int p96, int p97, int p98, int p99, int p9a, int p9b, int p9c, int p9d, int p9e, int p9f, \n" +
+ " int pa0, int pa1, int pa2, int pa3, int pa4, int pa5, int pa6, int pa7, int pa8, int pa9, int paa, int pab, int pac, int pad, int pae, int paf, \n" +
+ " int pb0, int pb1, int pb2, int pb3, int pb4, int pb5, int pb6, int pb7, int pb8, int pb9, int pba, int pbb, int pbc, int pbd, int pbe, int pbf, \n" +
+ " int pc0, int pc1, int pc2, int pc3, int pc4, int pc5, int pc6, int pc7, int pc8, int pc9, int pca, int pcb, int pcc, int pcd, int pce, int pcf, \n" +
+ " int pd0, int pd1, int pd2, int pd3, int pd4, int pd5, int pd6, int pd7, int pd8, int pd9, int pda, int pdb, int pdc, int pdd, int pde, int pdf, \n" +
+ " int pe0, int pe1, int pe2, int pe3, int pe4, int pe5, int pe6, int pe7, int pe8, int pe9, int pea, int peb, int pec, int ped, int pee, int pef, \n" +
+ " int pf0, int pf1, int pf2, int pf3, int pf4, int pf5, int pf6, int pf7, int pf8, int pf9, int pfa, int pfb, int pfc, int pfd\n" +
+ " ) {}\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The synthetic method created to access A(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) of type SyntheticConstructorTooManyArgs.A has too many parameters\n" +
+ "----------\n");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=321414
+public void test112() {
+ if (this.complianceLevel <= ClassFileConstants.JDK1_4) return;
+ this.runConformTest(
+ new String[] {
+ "SyntheticConstructorTooManyArgs.java", //-----------------------------------------------------------------------
+ "public class SyntheticConstructorTooManyArgs {\n" +
+ "\n" +
+ " class A {\n" +
+ " private A(\n" +
+ " /*this,*/int p01, int p02, int p03, int p04, int p05, int p06, int p07, int p08, int p09, int p0a, int p0b, int p0c, int p0d, int p0e, int p0f, \n" +
+ " int p10, int p11, int p12, int p13, int p14, int p15, int p16, int p17, int p18, int p19, int p1a, int p1b, int p1c, int p1d, int p1e, int p1f, \n" +
+ " int p20, int p21, int p22, int p23, int p24, int p25, int p26, int p27, int p28, int p29, int p2a, int p2b, int p2c, int p2d, int p2e, int p2f, \n" +
+ " int p30, int p31, int p32, int p33, int p34, int p35, int p36, int p37, int p38, int p39, int p3a, int p3b, int p3c, int p3d, int p3e, int p3f, \n" +
+ " int p40, int p41, int p42, int p43, int p44, int p45, int p46, int p47, int p48, int p49, int p4a, int p4b, int p4c, int p4d, int p4e, int p4f, \n" +
+ " int p50, int p51, int p52, int p53, int p54, int p55, int p56, int p57, int p58, int p59, int p5a, int p5b, int p5c, int p5d, int p5e, int p5f, \n" +
+ " int p60, int p61, int p62, int p63, int p64, int p65, int p66, int p67, int p68, int p69, int p6a, int p6b, int p6c, int p6d, int p6e, int p6f, \n" +
+ " int p70, int p71, int p72, int p73, int p74, int p75, int p76, int p77, int p78, int p79, int p7a, int p7b, int p7c, int p7d, int p7e, int p7f, \n" +
+ " int p80, int p81, int p82, int p83, int p84, int p85, int p86, int p87, int p88, int p89, int p8a, int p8b, int p8c, int p8d, int p8e, int p8f, \n" +
+ " int p90, int p91, int p92, int p93, int p94, int p95, int p96, int p97, int p98, int p99, int p9a, int p9b, int p9c, int p9d, int p9e, int p9f, \n" +
+ " int pa0, int pa1, int pa2, int pa3, int pa4, int pa5, int pa6, int pa7, int pa8, int pa9, int paa, int pab, int pac, int pad, int pae, int paf, \n" +
+ " int pb0, int pb1, int pb2, int pb3, int pb4, int pb5, int pb6, int pb7, int pb8, int pb9, int pba, int pbb, int pbc, int pbd, int pbe, int pbf, \n" +
+ " int pc0, int pc1, int pc2, int pc3, int pc4, int pc5, int pc6, int pc7, int pc8, int pc9, int pca, int pcb, int pcc, int pcd, int pce, int pcf, \n" +
+ " int pd0, int pd1, int pd2, int pd3, int pd4, int pd5, int pd6, int pd7, int pd8, int pd9, int pda, int pdb, int pdc, int pdd, int pde, int pdf, \n" +
+ " int pe0, int pe1, int pe2, int pe3, int pe4, int pe5, int pe6, int pe7, int pe8, int pe9, int pea, int peb, int pec, int ped, int pee, int pef, \n" +
+ " int pf0, int pf1, int pf2, int pf3, int pf4, int pf5, int pf6, int pf7, int pf8, int pf9, int pfa, int pfb, int pfc\n" +
+ " ) {}\n" +
+ " }\n" +
+ " @SuppressWarnings(\"synthetic-access\")\n" +
+ " A a = new A(\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n" +
+ " 0,0,0,0,0,0,0,0,0,0,0,0,0\n" +
+ " );\n" +
+ " public static void main(String[] args) {\n" +
+ " StringBuilder params = new StringBuilder();\n" +
+ " params.append(\"/*this,*/\");\n" +
+ " for (int p = 1; p < 253; p++) {\n" +
+ " if (p > 1) {\n" +
+ " params.append(\", \");\n" +
+ " if (p % 16 == 0)\n" +
+ " params.append('\\n');\n" +
+ " }\n" +
+ " params.append(\"int p\"\n" +
+ " + Character.forDigit(p / 16, 16)\n" +
+ " + Character.forDigit(p % 16, 16)\n" +
+ " );\n" +
+ " }\n" +
+ " System.out.println(params);\n" +
+ " A.class.getName(); // ClassFormatError\n" +
+ " }\n" +
+ "}",
+ },
+ "/*this,*/int p01, int p02, int p03, int p04, int p05, int p06, int p07, int p08, int p09, int p0a, int p0b, int p0c, int p0d, int p0e, int p0f, \n" +
+ "int p10, int p11, int p12, int p13, int p14, int p15, int p16, int p17, int p18, int p19, int p1a, int p1b, int p1c, int p1d, int p1e, int p1f, \n" +
+ "int p20, int p21, int p22, int p23, int p24, int p25, int p26, int p27, int p28, int p29, int p2a, int p2b, int p2c, int p2d, int p2e, int p2f, \n" +
+ "int p30, int p31, int p32, int p33, int p34, int p35, int p36, int p37, int p38, int p39, int p3a, int p3b, int p3c, int p3d, int p3e, int p3f, \n" +
+ "int p40, int p41, int p42, int p43, int p44, int p45, int p46, int p47, int p48, int p49, int p4a, int p4b, int p4c, int p4d, int p4e, int p4f, \n" +
+ "int p50, int p51, int p52, int p53, int p54, int p55, int p56, int p57, int p58, int p59, int p5a, int p5b, int p5c, int p5d, int p5e, int p5f, \n" +
+ "int p60, int p61, int p62, int p63, int p64, int p65, int p66, int p67, int p68, int p69, int p6a, int p6b, int p6c, int p6d, int p6e, int p6f, \n" +
+ "int p70, int p71, int p72, int p73, int p74, int p75, int p76, int p77, int p78, int p79, int p7a, int p7b, int p7c, int p7d, int p7e, int p7f, \n" +
+ "int p80, int p81, int p82, int p83, int p84, int p85, int p86, int p87, int p88, int p89, int p8a, int p8b, int p8c, int p8d, int p8e, int p8f, \n" +
+ "int p90, int p91, int p92, int p93, int p94, int p95, int p96, int p97, int p98, int p99, int p9a, int p9b, int p9c, int p9d, int p9e, int p9f, \n" +
+ "int pa0, int pa1, int pa2, int pa3, int pa4, int pa5, int pa6, int pa7, int pa8, int pa9, int paa, int pab, int pac, int pad, int pae, int paf, \n" +
+ "int pb0, int pb1, int pb2, int pb3, int pb4, int pb5, int pb6, int pb7, int pb8, int pb9, int pba, int pbb, int pbc, int pbd, int pbe, int pbf, \n" +
+ "int pc0, int pc1, int pc2, int pc3, int pc4, int pc5, int pc6, int pc7, int pc8, int pc9, int pca, int pcb, int pcc, int pcd, int pce, int pcf, \n" +
+ "int pd0, int pd1, int pd2, int pd3, int pd4, int pd5, int pd6, int pd7, int pd8, int pd9, int pda, int pdb, int pdc, int pdd, int pde, int pdf, \n" +
+ "int pe0, int pe1, int pe2, int pe3, int pe4, int pe5, int pe6, int pe7, int pe8, int pe9, int pea, int peb, int pec, int ped, int pee, int pef, \n" +
+ "int pf0, int pf1, int pf2, int pf3, int pf4, int pf5, int pf6, int pf7, int pf8, int pf9, int pfa, int pfb, int pfc");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=325567
+public void test113() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.io.IOException;\n" +
+ "public class X {\n" +
+ " public static void bar(int i) {\n" +
+ " final String before;\n" +
+ " try {\n" +
+ " before = foo();\n" +
+ " } catch (IOException e) {\n" +
+ " // ignore\n" +
+ " }\n" +
+ " B b = new B(new I() {\n" +
+ " public String bar() {\n" +
+ " return new String(before);\n" +
+ " }\n" +
+ " });\n" +
+ " try {\n" +
+ " b.toString();\n" +
+ " } catch(Exception e) {\n" +
+ " // ignore\n" +
+ " }\n" +
+ " }\n" +
+ " private static String foo() throws IOException {\n" +
+ " return null;\n" +
+ " }\n" +
+ " static class B {\n" +
+ " B(I i) {\n" +
+ " //ignore\n" +
+ " }\n" +
+ " }\n" +
+ " static interface I {\n" +
+ " String bar();\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 12)\n" +
+ " return new String(before);\n" +
+ " ^^^^^^\n" +
+ "The local variable before may not have been initialized\n" +
+ "----------\n",
+ null /* no extra class libraries */,
+ true /* flush output directory */,
+ null /* no custom options */,
+ true /* do not generate output */,
+ false /* do not show category */,
+ false /* do not show warning token */,
+ false /* do not skip javac for this peculiar test */,
+ false /* do not perform statements recovery */
+ );
+ this.runConformTest(
+ new String[] {
+ "Y.java", //-----------------------------------------------------------------------
+ "public class Y {\n" +
+ " public static void main(String[] args) {\n" +
+ " try {\n" +
+ " X.bar(3);\n" +
+ " } catch(VerifyError e) {\n" +
+ " System.out.println(\"FAILED\");\n" +
+ " }\n" +
+ " }\n" +
+ "}",
+ },
+ "",
+ null,
+ false,
+ null);
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java
index b8ef5bab5..0b2db7a84 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java
@@ -35,7 +35,7 @@ public ProgrammingProblemsTest(String name) {
// -Dcompliance=1.4 (for example) to lower it if needed
static {
// TESTS_NAMES = new String[] { "test001" };
-// TESTS_NUMBERS = new int[] { 1 };
+// TESTS_NUMBERS = new int[] { 43 };
// TESTS_RANGE = new int[] { 1, -1 };
}
@@ -1620,4 +1620,67 @@ public void test0042() {
null /* clientRequestor */,
true /* skipJavac */);
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=313825
+public void test0043() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " void foo(int i) {\n" +
+ " foo((a));\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 3)\n" +
+ " foo((a));\n" +
+ " ^\n" +
+ "a cannot be resolved to a variable\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310264
+public void test0044() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " volatile int x;\n" +
+ " int nvx;\n" +
+ " void foo(int i) {\n" +
+ " x = x;\n" +
+ " nvx = nvx;\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 6)\n" +
+ " nvx = nvx;\n" +
+ " ^^^^^^^^^\n" +
+ "The assignment to variable nvx has no effect\n" +
+ "----------\n");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310264
+public void test0045() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " volatile int x = this.x;\n" +
+ " int nvx = this.nvx;\n" +
+ " void foo(int i) {\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 2)\n" +
+ " volatile int x = this.x;\n" +
+ " ^^^^^^^^^^\n" +
+ "The assignment to variable x has no effect\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 3)\n" +
+ " int nvx = this.nvx;\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "The assignment to variable nvx has no effect\n" +
+ "----------\n");
+}
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RunComparableTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RunComparableTests.java
index 6fb6a0ce6..3cc733f18 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RunComparableTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RunComparableTests.java
@@ -31,6 +31,7 @@ public class RunComparableTests extends junit.framework.TestCase {
ALL_CLASSES.add(AutoBoxingTest.class);
ALL_CLASSES.add(Compliance_1_5.class);
ALL_CLASSES.add(GenericTypeTest.class);
+ ALL_CLASSES.add(GenericsRegressionTest.class);
ALL_CLASSES.add(ForeachStatementTest.class);
ALL_CLASSES.add(StaticImportTest.class);
ALL_CLASSES.add(VarargsTest.class);
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
index 6e5b31670..0c08ac5a6 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
@@ -34,7 +34,7 @@ public class StackMapAttributeTest extends AbstractRegressionTest {
static {
// TESTS_PREFIX = "testBug95521";
// TESTS_NAMES = new String[] { "testBug83127a" };
-// TESTS_NUMBERS = new int[] { 46 };
+// TESTS_NUMBERS = new int[] { 47 };
// TESTS_RANGE = new int[] { 23 -1,};
}
public static Test suite() {
@@ -6522,4 +6522,30 @@ public class StackMapAttributeTest extends AbstractRegressionTest {
true,
customOptions);
}
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=324848
+ public void test047() {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void test() {\n" +
+ " final boolean x = true;\n" +
+ " new Runnable() {\n" +
+ " @Override\n" +
+ " public void run() {\n" +
+ " synchronized (X.this) {\n" +
+ " System.out.println(x);\n" +
+ " }\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " synchronized (X.this) {\n" +
+ " ^^^^^^\n" +
+ "No enclosing instance of the type X is accessible in scope\n" +
+ "----------\n");
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuperTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuperTypeTest.java
index 9bed92f89..1147e5ac1 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuperTypeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SuperTypeTest.java
@@ -417,7 +417,7 @@ public void test013() {
"2. ERROR in X.java (at line 2)\n" +
" interface X<E> extends List<E>, Collection<E>, Iterable<E> {}\n" +
" ^^^^^^^^\n" +
- "Redundant superinterface Iterable<E> for the type X<E>, already defined by Collection<E>\n" +
+ "Redundant superinterface Iterable<E> for the type X<E>, already defined by List<E>\n" +
"----------\n" +
"3. ERROR in X.java (at line 3)\n" +
" interface Y<E> extends Collection<E>, List<E> {}\n" +
@@ -431,8 +431,8 @@ public void test013() {
"----------\n" +
"5. ERROR in X.java (at line 4)\n" +
" interface XXX<E> extends Iterable<E>, List<E>, Collection<E> {}\n" +
- " ^^^^^^^^\n" +
- "Redundant superinterface Iterable<E> for the type XXX<E>, already defined by Collection<E>\n" +
+ " ^^^^^^^^^^\n" +
+ "Redundant superinterface Collection<E> for the type XXX<E>, already defined by List<E>\n" +
"----------\n" +
"6. ERROR in X.java (at line 5)\n" +
" abstract class Z implements List<Object>, Collection<Object> {}\n" +
@@ -473,4 +473,173 @@ public void test014() {
"----------\n",
JavacTestOptions.SKIP);
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=320911 (as is)
+public void test015() {
+ Map customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperinterface, CompilerOptions.ERROR);
+ runNegativeTest(
+ // test directory preparation
+ true /* flush output directory */,
+ new String[] { /* test files */
+ "X.java",
+ "interface IVerticalRulerColumn {}\n" +
+ "interface IVerticalRulerInfo {}\n" +
+ "interface IVerticalRulerInfoExtension {}\n" +
+ "interface IChangeRulerColumn extends IVerticalRulerColumn, IVerticalRulerInfoExtension {}\n" +
+ "interface IRevisionRulerColumn extends IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ "public final class X implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension, IChangeRulerColumn, IRevisionRulerColumn {}\n"
+ },
+ // compiler options
+ null /* no class libraries */,
+ customOptions /* custom options */,
+ // compiler results
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " public final class X implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension, IChangeRulerColumn, IRevisionRulerColumn {}\n" +
+ " ^^^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerColumn for the type X, already defined by IChangeRulerColumn\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " public final class X implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension, IChangeRulerColumn, IRevisionRulerColumn {}\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerInfo for the type X, already defined by IRevisionRulerColumn\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 6)\n" +
+ " public final class X implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension, IChangeRulerColumn, IRevisionRulerColumn {}\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerInfoExtension for the type X, already defined by IChangeRulerColumn\n" +
+ "----------\n",
+ JavacTestOptions.SKIP);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=320911 (variation)
+public void test016() {
+ Map customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperinterface, CompilerOptions.ERROR);
+ runNegativeTest(
+ // test directory preparation
+ true /* flush output directory */,
+ new String[] { /* test files */
+ "X.java",
+ "interface IVerticalRulerColumn {}\n" +
+ "interface IVerticalRulerInfo {}\n" +
+ "interface IVerticalRulerInfoExtension {}\n" +
+ "interface IChangeRulerColumn extends IVerticalRulerColumn, IVerticalRulerInfoExtension {}\n" +
+ "interface IRevisionRulerColumn extends IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ "class Z implements IChangeRulerColumn {}\n" +
+ "class Y extends Z implements IRevisionRulerColumn {}\n" +
+ "public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n"
+ },
+ // compiler options
+ null /* no class libraries */,
+ customOptions /* custom options */,
+ // compiler results
+ "----------\n" +
+ "1. ERROR in X.java (at line 8)\n" +
+ " public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ " ^^^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerColumn for the type X, already defined by IRevisionRulerColumn\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerInfo for the type X, already defined by IRevisionRulerColumn\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 8)\n" +
+ " public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerInfoExtension for the type X, already defined by IRevisionRulerColumn\n" +
+ "----------\n",
+ JavacTestOptions.SKIP);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=320911 (variation)
+public void test017() {
+ Map customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperinterface, CompilerOptions.ERROR);
+ runNegativeTest(
+ // test directory preparation
+ true /* flush output directory */,
+ new String[] { /* test files */
+ "X.java",
+ "interface IVerticalRulerColumn {}\n" +
+ "interface IVerticalRulerInfo {}\n" +
+ "interface IVerticalRulerInfoExtension {}\n" +
+ "interface IChangeRulerColumn extends IVerticalRulerColumn, IVerticalRulerInfoExtension {}\n" +
+ "interface IRevisionRulerColumn extends IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ "class Z implements IRevisionRulerColumn{}\n" +
+ "class C extends Z {}\n" +
+ "class B extends C implements IChangeRulerColumn {}\n" +
+ "class H extends B {}\n" +
+ "class Y extends H {}\n" +
+ "public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n"
+ },
+ // compiler options
+ null /* no class libraries */,
+ customOptions /* custom options */,
+ // compiler results
+ "----------\n" +
+ "1. ERROR in X.java (at line 11)\n" +
+ " public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ " ^^^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerColumn for the type X, already defined by IRevisionRulerColumn\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 11)\n" +
+ " public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerInfo for the type X, already defined by IRevisionRulerColumn\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 11)\n" +
+ " public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerInfoExtension for the type X, already defined by IRevisionRulerColumn\n" +
+ "----------\n",
+ JavacTestOptions.SKIP);
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=320911 (variation)
+public void test018() {
+ Map customOptions = getCompilerOptions();
+ customOptions.put(CompilerOptions.OPTION_ReportRedundantSuperinterface, CompilerOptions.ERROR);
+ runNegativeTest(
+ // test directory preparation
+ true /* flush output directory */,
+ new String[] { /* test files */
+ "X.java",
+ "interface IVerticalRulerColumn {}\n" +
+ "interface IVerticalRulerInfo {}\n" +
+ "interface IVerticalRulerInfoExtension {}\n" +
+ "interface IChangeRulerColumn extends IVerticalRulerColumn, IVerticalRulerInfoExtension {}\n" +
+ "interface IRevisionRulerColumn extends IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ "class Z implements IVerticalRulerInfoExtension {}\n" +
+ "class C extends Z {}\n" +
+ "class B extends C implements IChangeRulerColumn {}\n" +
+ "class H extends B implements IVerticalRulerInfo {}\n" +
+ "class Y extends H implements IVerticalRulerColumn {}\n" +
+ "public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n"
+ },
+ // compiler options
+ null /* no class libraries */,
+ customOptions /* custom options */,
+ // compiler results
+ "----------\n" +
+ "1. ERROR in X.java (at line 10)\n" +
+ " class Y extends H implements IVerticalRulerColumn {}\n" +
+ " ^^^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerColumn for the type Y, already defined by IChangeRulerColumn\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 11)\n" +
+ " public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ " ^^^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerColumn for the type X, already defined by Y\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 11)\n" +
+ " public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ " ^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerInfo for the type X, already defined by H\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 11)\n" +
+ " public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "Redundant superinterface IVerticalRulerInfoExtension for the type X, already defined by Z\n" +
+ "----------\n",
+ JavacTestOptions.SKIP);
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
index 692fc100d..4087f9d22 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,7 +25,9 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class SwitchTest extends AbstractRegressionTest {
-
+static {
+// TESTS_NUMBERS = new int[] { 22 };
+}
public SwitchTest(String name) {
super(name);
}
@@ -730,6 +732,103 @@ public void test018() {
}
);
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=314830
+public void test019() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return;
+ this.runConformTest(new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " try {\n" +
+ " switch((Integer) null) {};\n" +
+ " System.out.println(\"FAILED\");\n" +
+ " } catch(NullPointerException e) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "SUCCESS");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=314830
+public void test020() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return;
+ this.runConformTest(new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " try {\n" +
+ " switch(foo()) {};\n" +
+ " System.out.println(\"FAILED\");\n" +
+ " } catch(NullPointerException e) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " }" +
+ " static Integer foo() {\n" +
+ " return (Integer) null;\n" +
+ " }\n" +
+ "}\n",
+ },
+ "SUCCESS");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=314830
+public void test021() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return;
+ this.runConformTest(new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " try {\n" +
+ " switch((Character) null) {\n" +
+ " default: System.out.println(\"FAILED\");\n" +
+ " }\n" +
+ " } catch(NullPointerException e) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "SUCCESS");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=314830
+public void test022() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return;
+ this.runConformTest(new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " java.math.RoundingMode mode = null;\n" +
+ " try {\n" +
+ " switch (mode) {}\n" +
+ " System.out.println(\"FAILED\");\n" +
+ " } catch(NullPointerException e) {\n" +
+ " System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "SUCCESS");
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=314830
+public void test023() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return;
+ this.runConformTest(new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " java.math.RoundingMode mode = java.math.RoundingMode.FLOOR;\n" +
+ " try {\n" +
+ " switch (mode) {\n" +
+ " default: System.out.println(\"SUCCESS\");\n" +
+ " }\n" +
+ " } catch(NullPointerException e) {\n" +
+ " System.out.println(\"FAILED\");\n" +
+ " }\n" +
+ " }\n" +
+ "}\n",
+ },
+ "SUCCESS");
+}
public static Class testClass() {
return SwitchTest.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 c048e24cd..bb651bb86 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
@@ -77,6 +77,7 @@ public static Test suite() {
standardTests.add(LineNumberAttributeTest.class);
standardTests.add(ProgrammingProblemsTest.class);
standardTests.add(ManifestAnalyzerTest.class);
+ standardTests.add(InitializationTests.class);
// add all javadoc tests
for (int i=0, l=JavadocTest.ALL_CLASSES.size(); i<l; i++) {
@@ -99,6 +100,7 @@ public static Test suite() {
since_1_5.add(Deprecated15Test.class);
since_1_5.add(InnerEmulationTest_1_5.class);
since_1_5.add(AssignmentTest_1_5.class);
+ since_1_5.add(InnerClass15Test.class);
// Tests to run when compliance is greater than 1.5
ArrayList since_1_6 = new ArrayList();

Back to the top