Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2020-09-09 01:32:42 +0000
committerManoj Palat2020-09-09 12:49:00 +0000
commitf3f9135001c7ea92b0540aa850ee9584ef1ecb18 (patch)
tree3cba2ea5622c82f1417a7ab46a1e55f7ab80110b
parent4e604f9a678a1911e2601e4482365185b17fe6f1 (diff)
downloadeclipse.jdt.core-f3f9135001c7ea92b0540aa850ee9584ef1ecb18.tar.gz
eclipse.jdt.core-f3f9135001c7ea92b0540aa850ee9584ef1ecb18.tar.xz
eclipse.jdt.core-f3f9135001c7ea92b0540aa850ee9584ef1ecb18.zip
Bug 564557 sec 15.8.3, 15 .8.4
Change-Id: Idd5bd827f353182888be37ac63bf8f8b2ee7c861 Signed-off-by: Manoj Palat <manpalat@in.ibm.com>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java
index 13f01ba098..1d5771fa40 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalStaticsTest_15.java
@@ -868,4 +868,67 @@ public class LocalStaticsTest_15 extends AbstractRegressionTest {
String expectedOutput = "static final enum X$1I {\n";
LocalStaticsTest_15.verifyClassFile(expectedOutput, "X$1I.class", ClassFileBytesDisassembler.SYSTEM);
}
+ // 15.8.3
+ public void testBug564557thisInStatic_007() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void foo() {\n"+
+ " interface I {\n"+
+ " int count = 0;\n"+
+ " static void bar() {\n"+
+ " int i = this.count;\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 3)\n" +
+ " interface I {\n" +
+ " ^\n" +
+ "The type I is never used locally\n" +
+ "----------\n" +
+ "2. WARNING in X.java (at line 4)\n" +
+ " int count = 0;\n" +
+ " ^^^^^\n" +
+ "The value of the field I.count is not used\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 6)\n" +
+ " int i = this.count;\n" +
+ " ^^^^\n" +
+ "Cannot use this in a static context\n" +
+ "----------\n"
+ );
+ }
+ // 15.8.3
+ public void testBug564557thisInStatic_008() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " int count = 0;\n"+
+ " void foo() {\n"+
+ " interface I {\n"+
+ " static void bar() {\n"+
+ " int i = X.this.count;\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. WARNING in X.java (at line 4)\n" +
+ " interface I {\n" +
+ " ^\n" +
+ "The type I is never used locally\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " int i = X.this.count;\n" +
+ " ^^^^^^\n" +
+ "No enclosing instance of the type X is accessible in scope\n" +
+ "----------\n"
+ );
+ }
} \ No newline at end of file

Back to the top