summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorStephan Herrmann2012-09-16 17:43:37 (EDT)
committer Jayaprakash Arthanareeswaran2012-10-19 00:49:03 (EDT)
commitce3b124b619fc5d547dab1f64c28160ffb2016f6 (patch)
treecb954244072e850138061858102346ec58a1f112
parente1812b866d1aaf7628da21a301ca4fda773a9ad2 (diff)
downloadeclipse.jdt.core-ce3b124b619fc5d547dab1f64c28160ffb2016f6.zip
eclipse.jdt.core-ce3b124b619fc5d547dab1f64c28160ffb2016f6.tar.gz
eclipse.jdt.core-ce3b124b619fc5d547dab1f64c28160ffb2016f6.tar.bz2
Bug 388137 - MethodBinding.getJavaElement() returns non-existing method
- add cleanup to avoid failures in subsequent tests.
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS3.java84
1 files changed, 44 insertions, 40 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS3.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS3.java
index ae25676..1ff029d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS3.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS3.java
@@ -1059,45 +1059,49 @@ public void testBug130778x() throws JavaModelException {
public void testbug388137() throws Exception {
this.workingCopies = new ICompilationUnit[1];
IJavaProject project = createJavaProject("P1", new String[] {""}, new String[] {"CONVERTER_JCL15_LIB"}, "", "1.5");
- String contents = "package p;\n" +
- "import java.util.List;\n" +
- "public class X {\n" +
- " public X(List list) {}\n" +
- " public static class ListHandler implements Handler {\n" +
- " List list = null;\n" +
- " public ListHandler(List list) {\n" +
- " this.list = list;\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "interface Handler {}\n";
- addLibrary(project, "lib.jar", "src.zip", new String[] {"/P1/p/X.java", contents}, "1.5");
-
- this.workingCopies[0] = getWorkingCopy("/P1/q/Y.java", true);
- contents =
- "package q;\n" +
- "import p.X.ListHandler;\n" +
- "public class Y {\n" +
- " public Object foo() {\n" +
- " ListHandler sortHandler = new ListHandler(null);\n" +
- " return sortHandler;" +
- " }\n" +
- "}\n";
- ASTNode node = buildAST(contents, this.workingCopies[0], true);
-
- assertTrue("Should be a compilation unit", node instanceof CompilationUnit);
- CompilationUnit unit = (CompilationUnit) node;
- node = getASTNode(unit, 0, 0, 0);
- assertEquals("Not an expression statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType());
- VariableDeclarationStatement statement = (VariableDeclarationStatement) node;
- List fragments = statement.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment fragment= (VariableDeclarationFragment) fragments.get(0);
- Expression expression = fragment.getInitializer();
- assertEquals("Not a constructor invocation", ASTNode.CLASS_INSTANCE_CREATION, expression.getNodeType());
- ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
- IMethodBinding binding = classInstanceCreation.resolveConstructorBinding();
- JavaElement element = (JavaElement)binding.getJavaElement();
- assertNotNull("Null Element info", element.getElementInfo());
+ try {
+ String contents = "package p;\n" +
+ "import java.util.List;\n" +
+ "public class X {\n" +
+ " public X(List list) {}\n" +
+ " public static class ListHandler implements Handler {\n" +
+ " List list = null;\n" +
+ " public ListHandler(List list) {\n" +
+ " this.list = list;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "interface Handler {}\n";
+ addLibrary(project, "lib.jar", "src.zip", new String[] {"/P1/p/X.java", contents}, "1.5");
+
+ this.workingCopies[0] = getWorkingCopy("/P1/q/Y.java", true);
+ contents =
+ "package q;\n" +
+ "import p.X.ListHandler;\n" +
+ "public class Y {\n" +
+ " public Object foo() {\n" +
+ " ListHandler sortHandler = new ListHandler(null);\n" +
+ " return sortHandler;" +
+ " }\n" +
+ "}\n";
+ ASTNode node = buildAST(contents, this.workingCopies[0], true);
+
+ assertTrue("Should be a compilation unit", node instanceof CompilationUnit);
+ CompilationUnit unit = (CompilationUnit) node;
+ node = getASTNode(unit, 0, 0, 0);
+ assertEquals("Not an expression statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType());
+ VariableDeclarationStatement statement = (VariableDeclarationStatement) node;
+ List fragments = statement.fragments();
+ assertEquals("Wrong size", 1, fragments.size());
+ VariableDeclarationFragment fragment= (VariableDeclarationFragment) fragments.get(0);
+ Expression expression = fragment.getInitializer();
+ assertEquals("Not a constructor invocation", ASTNode.CLASS_INSTANCE_CREATION, expression.getNodeType());
+ ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
+ IMethodBinding binding = classInstanceCreation.resolveConstructorBinding();
+ JavaElement element = (JavaElement)binding.getJavaElement();
+ assertNotNull("Null Element info", element.getElementInfo());
+ } finally {
+ deleteProject(project);
+ }
}
}