### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java,v retrieving revision 1.85.2.7 diff -u -r1.85.2.7 MethodVerifyTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 6 Oct 2006 09:18:17 -0000 1.85.2.7 +++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 12 Oct 2006 01:51:13 -0000 @@ -14,14 +14,26 @@ import java.io.IOException; import java.util.Map; -import junit.framework.*; +import junit.framework.Test; 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.core.util.IClassFileReader; +import org.eclipse.jdt.core.util.IMethodInfo; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; public class MethodVerifyTest extends AbstractComparableTest { +// Use this static initializer to specify subset for tests +// All specified tests which does not belong to the class are skipped... + static { + // Names of tests to run: can be "testBugXXXX" or "BugXXXX") +// TESTS_NAMES = new String[] { "Bug58069" }; + // Numbers of tests to run: "test" will be run for each number of this array + TESTS_NUMBERS = new int[] { 102, 103, 104, 105, 106 }; + // Range numbers of tests to run: all tests between "test" and "test" will be run for { first, last } +// TESTS_RANGE = new int[] { 85, -1 }; + } public MethodVerifyTest(String name) { super(name); @@ -5256,7 +5268,6 @@ ); } } - // name conflict public void test101() { if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) { @@ -5295,4 +5306,359 @@ ); } } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=159973 +public void test102() { + if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) { + Map options = this.getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.IGNORE); + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " private interface ReturnBase {\n" + + " }\n" + + "\n" + + " private interface ReturnDerived extends ReturnBase {\n" + + " }\n" + + "\n" + + " private interface ReturnLeaf extends ReturnDerived {\n" + + " }\n" + + "\n" + + " private interface Interface {\n" + + " ReturnBase bar();\n" + + " }\n" + + "\n" + + " private static class Implementation {\n" + + " public final ReturnDerived bar() {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "\n" + + " private static class Child extends Implementation implements Interface {\n" + + " }\n" + + "\n" + + " private static class Grandchild extends Child implements Interface {\n" + + " @Override\n" + + " public ReturnLeaf bar() {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new Grandchild();\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 26)\n" + + " public ReturnLeaf bar() {\n" + + " ^^^^^\n" + + "Cannot override the final method from X.Implementation\n" + + "----------\n", + null, + true, + options + ); + } +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=159973 +public void test103() { + if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) { + Map options = this.getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.IGNORE); + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " private interface ReturnBase {\n" + + " }\n" + + "\n" + + " private interface ReturnDerived extends ReturnBase {\n" + + " }\n" + + "\n" + + " private interface Interface {\n" + + " ReturnBase bar();\n" + + " }\n" + + "\n" + + " private static class Implementation {\n" + + " public final ReturnDerived bar() {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "\n" + + " private static class Grandchild extends Child implements Interface {\n" + + " }\n" + + "\n" + + " private static class Child extends Implementation implements Interface {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new Grandchild();\n" + + " }\n" + + "}" + }, + "", + null, + true, + null, + options, + null + ); + File fileX = new File(OUTPUT_DIR + File.separator +"X$Child.class"); + IClassFileReader reader = ToolFactory.createDefaultClassFileReader(fileX.getAbsolutePath(), IClassFileReader.ALL_BUT_METHOD_BODIES); + IMethodInfo[] methodInfos = reader.getMethodInfos(); + boolean found = false; + for (int i = 0, max = methodInfos.length; i < max; i++) { + if (new String(methodInfos[i].getName()).equals("bar")) { + found = true; + break; + } + } + assertTrue("bar should be there", found); + + fileX = new File(OUTPUT_DIR + File.separator +"X$Grandchild.class"); + reader = ToolFactory.createDefaultClassFileReader(fileX.getAbsolutePath(), IClassFileReader.ALL_BUT_METHOD_BODIES); + methodInfos = reader.getMethodInfos(); + found = false; + for (int i = 0, max = methodInfos.length; i < max; i++) { + if (new String(methodInfos[i].getName()).equals("bar")) { + found = true; + break; + } + } + assertFalse("bar should not be there", found); + } +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=159973 +public void test104() { + if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) { + Map options = this.getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.IGNORE); + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " private interface ReturnBase {\n" + + " }\n" + + "\n" + + " private interface ReturnDerived extends ReturnBase {\n" + + " }\n" + + "\n" + + " private interface Interface {\n" + + " ReturnBase bar();\n" + + " }\n" + + "\n" + + " private static class Implementation {\n" + + " public final ReturnDerived bar() {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "\n" + + " private static class Child extends Implementation implements Interface {\n" + + " }\n" + + "\n" + + " private static class Grandchild extends Child implements Interface {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new Grandchild();\n" + + " }\n" + + "}" + }, + "", + null, + true, + null, + options, + null + ); + File fileX = new File(OUTPUT_DIR + File.separator +"X$Child.class"); + IClassFileReader reader = ToolFactory.createDefaultClassFileReader(fileX.getAbsolutePath(), IClassFileReader.ALL_BUT_METHOD_BODIES); + IMethodInfo[] methodInfos = reader.getMethodInfos(); + boolean found = false; + for (int i = 0, max = methodInfos.length; i < max; i++) { + if (new String(methodInfos[i].getName()).equals("bar")) { + found = true; + break; + } + } + assertTrue("bar should be there", found); + + fileX = new File(OUTPUT_DIR + File.separator +"X$Grandchild.class"); + reader = ToolFactory.createDefaultClassFileReader(fileX.getAbsolutePath(), IClassFileReader.ALL_BUT_METHOD_BODIES); + methodInfos = reader.getMethodInfos(); + found = false; + for (int i = 0, max = methodInfos.length; i < max; i++) { + if (new String(methodInfos[i].getName()).equals("bar")) { + found = true; + break; + } + } + assertFalse("bar should not be there", found); + } +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=159973 +public void test105() { + if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) { + Map options = this.getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.IGNORE); + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " private interface ReturnBase {\n" + + " }\n" + + "\n" + + " private interface ReturnDerived extends ReturnBase {\n" + + " }\n" + + "\n" + + " private class Super {\n" + + " ReturnBase bar() {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "\n" + + " private static class Implementation {\n" + + " public final ReturnDerived bar() {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "\n" + + " private static class Child extends Implementation {\n" + + " }\n" + + "\n" + + " private static class Grandchild extends Child {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new Grandchild();\n" + + " }\n" + + "}" + }, + "", + null, + true, + null, + options, + null + ); + File fileX = new File(OUTPUT_DIR + File.separator +"X$Child.class"); + IClassFileReader reader = ToolFactory.createDefaultClassFileReader(fileX.getAbsolutePath(), IClassFileReader.ALL_BUT_METHOD_BODIES); + IMethodInfo[] methodInfos = reader.getMethodInfos(); + boolean found = false; + for (int i = 0, max = methodInfos.length; i < max; i++) { + if (new String(methodInfos[i].getName()).equals("bar")) { + found = true; + break; + } + } + assertFalse("bar should not be there", found); + + fileX = new File(OUTPUT_DIR + File.separator +"X$Grandchild.class"); + reader = ToolFactory.createDefaultClassFileReader(fileX.getAbsolutePath(), IClassFileReader.ALL_BUT_METHOD_BODIES); + methodInfos = reader.getMethodInfos(); + found = false; + for (int i = 0, max = methodInfos.length; i < max; i++) { + if (new String(methodInfos[i].getName()).equals("bar")) { + found = true; + break; + } + } + assertFalse("bar should not be there", found); + + fileX = new File(OUTPUT_DIR + File.separator +"X$Implementation.class"); + reader = ToolFactory.createDefaultClassFileReader(fileX.getAbsolutePath(), IClassFileReader.ALL_BUT_METHOD_BODIES); + methodInfos = reader.getMethodInfos(); + found = false; + for (int i = 0, max = methodInfos.length; i < max; i++) { + if (new String(methodInfos[i].getName()).equals("bar")) { + found = true; + break; + } + } + assertTrue("bar should be there", found); + } +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=159973 +public void test106() { + if (this.complianceLevel.compareTo(COMPLIANCE_1_5) >= 0) { + Map options = this.getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.IGNORE); + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " private interface ReturnBase {\n" + + " }\n" + + "\n" + + " private interface ReturnDerived extends ReturnBase {\n" + + " }\n" + + "\n" + + " private class Super {\n" + + " ReturnBase bar() {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "\n" + + " private static abstract class Implementation {\n" + + " public final ReturnDerived bar() {\n" + + " return null;\n" + + " }\n" + + " }\n" + + "\n" + + " private static class Child extends Implementation {\n" + + " }\n" + + "\n" + + " private static class Grandchild extends Child {\n" + + " }\n" + + "\n" + + " public static void main(String[] args) {\n" + + " new Grandchild();\n" + + " }\n" + + "}" + }, + "", + null, + true, + null, + options, + null + ); + File fileX = new File(OUTPUT_DIR + File.separator +"X$Child.class"); + IClassFileReader reader = ToolFactory.createDefaultClassFileReader(fileX.getAbsolutePath(), IClassFileReader.ALL_BUT_METHOD_BODIES); + IMethodInfo[] methodInfos = reader.getMethodInfos(); + boolean found = false; + for (int i = 0, max = methodInfos.length; i < max; i++) { + if (new String(methodInfos[i].getName()).equals("bar")) { + found = true; + break; + } + } + assertFalse("bar should not be there", found); + + fileX = new File(OUTPUT_DIR + File.separator +"X$Grandchild.class"); + reader = ToolFactory.createDefaultClassFileReader(fileX.getAbsolutePath(), IClassFileReader.ALL_BUT_METHOD_BODIES); + methodInfos = reader.getMethodInfos(); + found = false; + for (int i = 0, max = methodInfos.length; i < max; i++) { + if (new String(methodInfos[i].getName()).equals("bar")) { + found = true; + break; + } + } + assertFalse("bar should not be there", found); + + fileX = new File(OUTPUT_DIR + File.separator +"X$Implementation.class"); + reader = ToolFactory.createDefaultClassFileReader(fileX.getAbsolutePath(), IClassFileReader.ALL_BUT_METHOD_BODIES); + methodInfos = reader.getMethodInfos(); + found = false; + for (int i = 0, max = methodInfos.length; i < max; i++) { + if (new String(methodInfos[i].getName()).equals("bar")) { + found = true; + break; + } + } + assertTrue("bar should be there", found); + } +} } \ No newline at end of file