Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 116082 Details for
Bug 250975
[1.5][compiler] Stack overflow on static import.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Proposed patch
250975.txt (text/plain), 13.14 KB, created by
Philipe Mulet
on 2008-10-24 13:52:42 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2008-10-24 13:52:42 EDT
Size:
13.14 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java,v >retrieving revision 1.78 >diff -u -r1.78 LookupTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 14 Aug 2008 17:34:25 -0000 1.78 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 24 Oct 2008 17:50:09 -0000 >@@ -2985,6 +2985,100 @@ > "----------\n" > ); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=250211 - variation >+public void test091() { >+ this.runNegativeTest( >+ new String[] { >+ "foo/Test.java",//------------------------------ >+ "package foo;\n" + >+ "public class Test {\n" + >+ " public class M1 {\n" + >+ " public class M2 {}\n" + >+ " }\n" + >+ "}\n", >+ "bar/Test2.java",//------------------------------ >+ "package bar;\n" + >+ "import foo.Test;\n" + >+ "import Test.M1.M2;\n" + >+ "public class Test2 {\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in bar\\Test2.java (at line 3)\n" + >+ " import Test.M1.M2;\n" + >+ " ^^^^\n" + >+ "The import Test cannot be resolved\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=250211 - variation >+public void test092() { >+ this.runNegativeTest( >+ new String[] { >+ "foo/Test.java",//------------------------------ >+ "package foo;\n" + >+ "public class Test {\n" + >+ " public class M1 {\n" + >+ " public class M2 {}\n" + >+ " }\n" + >+ "}\n", >+ "bar/Test2.java",//------------------------------ >+ "package bar;\n" + >+ "import foo.*;\n" + >+ "import Test.M1.M2;\n" + >+ "public class Test2 {\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in bar\\Test2.java (at line 3)\n" + >+ " import Test.M1.M2;\n" + >+ " ^^^^\n" + >+ "The import Test cannot be resolved\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=250211 - variation >+public void test093() { >+ this.runNegativeTest( >+ new String[] { >+ "foo/Test.java",//------------------------------ >+ "package foo;\n" + >+ "public class Test {\n" + >+ " public class M1 {\n" + >+ " public class foo {}\n" + >+ " }\n" + >+ "}\n", >+ "bar/Test2.java",//------------------------------ >+ "package bar;\n" + >+ "import foo.Test;\n" + >+ "import Test.M1.foo;\n" + >+ "public class Test2 {\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in bar\\Test2.java (at line 3)\n" + >+ " import Test.M1.foo;\n" + >+ " ^^^^\n" + >+ "The import Test cannot be resolved\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=250211 - variation >+public void test094() { >+ this.runConformTest( >+ new String[] { >+ "foo/Test.java",//------------------------------ >+ "package foo;\n" + >+ "public class Test {\n" + >+ " public class M1 {\n" + >+ " public class foo {}\n" + >+ " }\n" + >+ "}\n", >+ "bar/Test2.java",//------------------------------ >+ "package bar;\n" + >+ "import foo.Test.M1.foo;\n" + >+ "public class Test2 {\n" + >+ "}\n", >+ }, >+ ""); >+} > public static Class testClass() { return LookupTest.class; > } > } >Index: src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java,v >retrieving revision 1.70 >diff -u -r1.70 StaticImportTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 27 Jun 2008 16:04:45 -0000 1.70 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java 24 Oct 2008 17:50:13 -0000 >@@ -2404,5 +2404,90 @@ > }, > ""); > } >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=250211 >+ public void test070() { >+ this.runConformTest( >+ new String[] { >+ "node/Test.java",//------------------------------ >+ "package node;\n" + >+ "public class Test {\n" + >+ " public static void node() {}\n" + >+ "}\n", >+ "node2/Test2.java",//------------------------------ >+ "package node2;\n" + >+ "import static node.Test.node;\n" + >+ "public class Test2 {\n" + >+ "}\n", >+ }, >+ ""); >+ } >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=250211 - variation >+ public void test071() { >+ this.runNegativeTest( >+ new String[] { >+ "node/Test/node.java",//------------------------------ >+ "package node.Test;\n" + >+ "public class node {\n" + >+ "}\n", >+ "node/Test.java",//------------------------------ >+ "package node;\n" + >+ "public class Test {\n" + >+ " public static void node() {}\n" + >+ "}\n", >+ "node2/Test2.java",//------------------------------ >+ "package node2;\n" + >+ "import node.Test;\n" + >+ "import static Test.node;\n" + >+ "public class Test2 {\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in node\\Test.java (at line 2)\n" + >+ " public class Test {\n" + >+ " ^^^^\n" + >+ "The type Test collides with a package\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in node2\\Test2.java (at line 3)\n" + >+ " import static Test.node;\n" + >+ " ^^^^\n" + >+ "The import Test cannot be resolved\n" + >+ "----------\n"); >+ } >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=93913 - variation >+ public void test072() { >+ this.runNegativeTest( >+ new String[] { >+ "p1/A.java", >+ "package p1;\n" + >+ "import static p2.C.B;\n" + >+ "public class A extends B {\n" + >+ " void test() {" + >+ " int i = B;\n" + >+ " B b = null;\n" + >+ " int v1 = b.fooB;\n" + >+ " int v2 = b.fooC;\n" + >+ " int v3 = fooC;\n" + >+ " }\n" + >+ "}\n", >+ "p1/B.java", >+ "package p1;\n" + >+ "public class B {\n" + >+ " public int fooB;\n" + >+ "}\n", >+ "p2/C.java", >+ "package p2;\n" + >+ "public class C {\n" + >+ " public static class B { public int fooC; }\n" + >+ " public static int B;\n" + >+ "}\n", >+ }, >+ "----------\n" + >+ "1. ERROR in p1\\A.java (at line 7)\n" + >+ " int v2 = b.fooC;\n" + >+ " ^^^^^^\n" + >+ "b.fooC cannot be resolved or is not a field\n" + >+ "----------\n"); >+ } > } > >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java,v >retrieving revision 1.120 >diff -u -r1.120 CompilationUnitScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 17 Sep 2008 09:08:39 -0000 1.120 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java 24 Oct 2008 17:50:20 -0000 >@@ -36,7 +36,7 @@ > > HashtableOfType constantPoolNameUsage; > private int captureID = 1; >- >+ > public CompilationUnitScope(CompilationUnitDeclaration unit, LookupEnvironment environment) { > super(COMPILATION_UNIT_SCOPE, null); > this.environment = environment; >@@ -356,7 +356,7 @@ > } > resolvedImports[index++] = new ImportBinding(compoundName, true, importBinding, importReference); > } else { >- Binding importBinding = findSingleImport(compoundName, importReference.isStatic()); >+ Binding importBinding = findSingleImport(compoundName, Binding.TYPE | Binding.FIELD | Binding.METHOD, importReference.isStatic()); > if (!importBinding.isValidBinding()) { > if (importBinding.problemId() == ProblemReasons.Ambiguous) { > // keep it unless a duplicate can be found below >@@ -442,7 +442,7 @@ > if(onDemand) { > return findImport(compoundName, compoundName.length); > } else { >- return findSingleImport(compoundName, findStaticImports); >+ return findSingleImport(compoundName, Binding.TYPE | Binding.FIELD | Binding.METHOD, findStaticImports); > } > } > private Binding findImport(char[][] compoundName, int length) { >@@ -493,7 +493,7 @@ > return new ProblemReferenceBinding(compoundName, type, ProblemReasons.NotVisible); > return type; > } >-private Binding findSingleImport(char[][] compoundName, boolean findStaticImports) { >+private Binding findSingleImport(char[][] compoundName, int mask, boolean findStaticImports) { > if (compoundName.length == 1) { > // findType records the reference > // the name cannot be a package >@@ -506,10 +506,10 @@ > } > > if (findStaticImports) >- return findSingleStaticImport(compoundName); >+ return findSingleStaticImport(compoundName, mask); > return findImport(compoundName, compoundName.length); > } >-private Binding findSingleStaticImport(char[][] compoundName) { >+private Binding findSingleStaticImport(char[][] compoundName, int mask) { > Binding binding = findImport(compoundName, compoundName.length - 1); > if (!binding.isValidBinding()) return binding; > >@@ -523,7 +523,7 @@ > > // look to see if its a static field first > ReferenceBinding type = (ReferenceBinding) binding; >- FieldBinding field = findField(type, name, null, true); >+ FieldBinding field = (mask & Binding.FIELD) != 0 ? findField(type, name, null, true) : null; > if (field != null) { > if (field.problemId() == ProblemReasons.Ambiguous && ((ProblemFieldBinding) field).closestMatch.isStatic()) > return field; // keep the ambiguous field instead of a possible method match >@@ -532,7 +532,7 @@ > } > > // look to see if there is a static method with the same selector >- MethodBinding method = findStaticMethod(type, name); >+ MethodBinding method = (mask & Binding.METHOD) != 0 ? findStaticMethod(type, name) : null; > if (method != null) return method; > > type = findMemberType(name, type); >@@ -589,7 +589,7 @@ > public final Binding getImport(char[][] compoundName, boolean onDemand, boolean isStaticImport) { > if (onDemand) > return findImport(compoundName, compoundName.length); >- return findSingleImport(compoundName, isStaticImport); >+ return findSingleImport(compoundName, Binding.TYPE | Binding.FIELD | Binding.METHOD, isStaticImport); > } > > public int nextCaptureID() { >@@ -708,9 +708,9 @@ > this.referencedTypes.add(actualType); > } > } >-Binding resolveSingleImport(ImportBinding importBinding) { >+Binding resolveSingleImport(ImportBinding importBinding, int mask) { > if (importBinding.resolvedImport == null) { >- importBinding.resolvedImport = findSingleImport(importBinding.compoundName, importBinding.isStatic()); >+ importBinding.resolvedImport = findSingleImport(importBinding.compoundName, mask, importBinding.isStatic()); > if (!importBinding.resolvedImport.isValidBinding() || importBinding.resolvedImport instanceof PackageBinding) { > if (importBinding.resolvedImport.problemId() == ProblemReasons.Ambiguous) > return importBinding.resolvedImport; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v >retrieving revision 1.341 >diff -u -r1.341 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 17 Sep 2008 09:08:39 -0000 1.341 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 24 Oct 2008 17:50:27 -0000 >@@ -1569,7 +1569,7 @@ > ImportBinding importBinding = imports[i]; > if (importBinding.isStatic() && !importBinding.onDemand) { > if (CharOperation.equals(importBinding.compoundName[importBinding.compoundName.length - 1], name)) { >- if (unitScope.resolveSingleImport(importBinding) != null && importBinding.resolvedImport instanceof FieldBinding) { >+ if (unitScope.resolveSingleImport(importBinding, Binding.TYPE | Binding.FIELD | Binding.METHOD) != null && importBinding.resolvedImport instanceof FieldBinding) { > foundField = (FieldBinding) importBinding.resolvedImport; > ImportReference importReference = importBinding.reference; > if (importReference != null && needResolve) { >@@ -2438,12 +2438,8 @@ > ImportBinding importBinding = imports[i]; > if (!importBinding.onDemand) { > if (CharOperation.equals(importBinding.compoundName[importBinding.compoundName.length - 1], name)) { >- Binding resolvedImport = unitScope.resolveSingleImport(importBinding); >+ Binding resolvedImport = unitScope.resolveSingleImport(importBinding, Binding.TYPE); > if (resolvedImport == null) continue nextImport; >- if (resolvedImport instanceof MethodBinding) { >- resolvedImport = getType(importBinding.compoundName, importBinding.compoundName.length); >- if (!resolvedImport.isValidBinding()) continue nextImport; >- } > if (resolvedImport instanceof TypeBinding) { > ImportReference importReference = importBinding.reference; > if (importReference != null)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 250975
:
115167
| 116082 |
116109