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 39518 Details for
Bug 136095
Type Hierarchy incomplete with illegally parameterized superinterfaces
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Improved patch and regression tests
136095.txt (text/plain), 11.60 KB, created by
Jerome Lanneluc
on 2006-04-26 09:08:09 EDT
(
hide
)
Description:
Improved patch and regression tests
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2006-04-26 09:08:09 EDT
Size:
11.60 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java,v >retrieving revision 1.53 >diff -u -r1.53 TypeHierarchyTests.java >--- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 17 Apr 2006 19:43:00 -0000 1.53 >+++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 26 Apr 2006 12:54:41 -0000 >@@ -1000,7 +1000,7 @@ > /* > * Ensures that a hierarchy on a generic type can be opened > */ >-public void testGeneric1() throws JavaModelException { >+public void testGeneric01() throws JavaModelException { > IType type = getCompilationUnit("/TypeHierarchy15/src/X.java").getType("X"); > ITypeHierarchy hierarchy = type.newTypeHierarchy(null); > assertHierarchyEquals( >@@ -1018,7 +1018,7 @@ > /* > * Ensures that a hierarchy on a generic type can be opened > */ >-public void testGeneric2() throws JavaModelException { >+public void testGeneric02() throws JavaModelException { > IType type = getPackageFragmentRoot("/TypeHierarchy15/lib15.jar").getPackageFragment("util").getClassFile("ArrayList.class").getType(); > ITypeHierarchy hierarchy = type.newTypeHierarchy(null); > assertHierarchyEquals( >@@ -1036,7 +1036,7 @@ > /* > * Ensures that a hierarchy on a generic type can be opened > */ >-public void testGeneric3() throws JavaModelException { >+public void testGeneric03() throws JavaModelException { > IType type = getCompilationUnit("/TypeHierarchy15/src/Y.java").getType("Y"); > ITypeHierarchy hierarchy = type.newTypeHierarchy(null); > assertHierarchyEquals( >@@ -1055,7 +1055,7 @@ > * Ensures that a super type hierarchy on a generic type can be opened > * (regression test for bug 72348 [1.5][Type Hierarchy] Super type hierarchy of class extending generic type is empty) > */ >-public void testGeneric4() throws JavaModelException { >+public void testGeneric04() throws JavaModelException { > IType type = getCompilationUnit("/TypeHierarchy15/src/X.java").getType("X"); > ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null); > assertHierarchyEquals( >@@ -1075,7 +1075,7 @@ > * Ensures that a hierarchy on a generic interface can be opened > * (regression test for bug 82004 [model][5.0] 3.1M4 type hierarchy for generic interface) > */ >-public void testGeneric5() throws JavaModelException { >+public void testGeneric05() throws JavaModelException { > IType type = getCompilationUnit("/TypeHierarchy15/src/I.java").getType("I"); > ITypeHierarchy hierarchy = type.newTypeHierarchy(null); > assertHierarchyEquals( >@@ -1090,7 +1090,7 @@ > * Ensure that the key of a binary type in a hierarchy is correct when this type is not part of the Java model cache. > * (regression test for bug 93854 IAE in Util.scanTypeSignature when scanning a signature retrieved from a binding key) > */ >-public void testGeneric6() throws CoreException { >+public void testGeneric06() throws CoreException { > getJavaProject("TypeHierarcht15").close(); > IType type = getClassFile("TypeHierarchy15","lib15.jar", "util", "AbstractList.class").getType(); > ITypeHierarchy hierarchy = type.newTypeHierarchy(null); >@@ -1101,7 +1101,7 @@ > * Ensures that a hierarchy on a generic type that is extended using a member as a type parameter can be opened > * (regression test for bug 99606 Subtype not found if parameterized on inner class) > */ >-public void testGeneric7() throws JavaModelException { >+public void testGeneric07() throws JavaModelException { > IType type = getCompilationUnit("/TypeHierarchy15/src/Y99606.java").getType("Y99606"); > ITypeHierarchy hierarchy = type.newTypeHierarchy(null); > assertHierarchyEquals( >@@ -1114,7 +1114,7 @@ > ); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=108740 >-public void testGeneric8() throws JavaModelException { >+public void testGeneric08() throws JavaModelException { > IType type = getCompilationUnit("/TypeHierarchy15/src/D108740.java").getType("D108740"); > ITypeHierarchy hierarchy = type.newTypeHierarchy(null); > assertHierarchyEquals( >@@ -1127,6 +1127,45 @@ > hierarchy > ); > } >+/* >+ * Ensures that a hierarchy is where a type inherits conflicting paratemerized types is still correctly reported >+ * (regression test for bug 136095 Type Hierarchy incomplete with illegally parameterized superinterfaces) >+ */ >+public void testGeneric09() throws CoreException { >+ try { >+ createFile( >+ "/TypeHierarchy15/src/I1_136095.java", >+ "public interface I1_136095<E> {\n" + >+ "}" >+ ); >+ createFile( >+ "/TypeHierarchy15/src/I2_136095.java", >+ "public interface I2_136095 extends I1_136095<String>{\n" + >+ "}" >+ ); >+ createFile( >+ "/TypeHierarchy15/src/X_136095.java", >+ "public abstract class X_136095 implements I1_136095<Integer>, I2_136095 {\n" + >+ "}" >+ ); >+ IType type = getCompilationUnit("/TypeHierarchy15/src/X_136095.java").getType("X_136095"); >+ ITypeHierarchy hierarchy = type.newTypeHierarchy(null); >+ assertHierarchyEquals( >+ "Focus: X_136095 [in X_136095.java [in <default> [in src [in TypeHierarchy15]]]]\n" + >+ "Super types:\n" + >+ " I1_136095 [in I1_136095.java [in <default> [in src [in TypeHierarchy15]]]]\n" + >+ " I2_136095 [in I2_136095.java [in <default> [in src [in TypeHierarchy15]]]]\n" + >+ " I1_136095 [in I1_136095.java [in <default> [in src [in TypeHierarchy15]]]]\n" + >+ " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString("1.5") + " [in TypeHierarchy15]]]]\n" + >+ "Sub types:\n", >+ hierarchy >+ ); >+ } finally { >+ deleteFile("/TypeHierarchy15/src/I1_136095.java"); >+ deleteFile("/TypeHierarchy15/src/I2_136095.java"); >+ deleteFile("/TypeHierarchy15/src/X_136095.java"); >+ } >+} > /** > * Ensures the correctness of all classes in a type hierarchy based on a region. > */ >@@ -1522,4 +1561,34 @@ > project.setRawClasspath(originalClasspath, null); > } > } >+/* >+ * Ensures that a hierarchy where the super type is not visible can still be constructed. >+ */ >+public void testVisibility1() throws JavaModelException { >+ IType type = getCompilationUnit("/TypeHierarchy/src/q6/Y.java").getType("Y"); >+ ITypeHierarchy hierarchy = type.newTypeHierarchy(null); >+ assertHierarchyEquals( >+ "Focus: Y [in Y.java [in q6 [in src [in TypeHierarchy]]]]\n" + >+ "Super types:\n" + >+ " NonVisibleClass [in X.java [in q5 [in src [in TypeHierarchy]]]]\n" + >+ " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + " [in TypeHierarchy]]]]\n" + >+ "Sub types:\n", >+ hierarchy >+ ); >+} >+/* >+ * Ensures that a hierarchy where the super interface is not visible can still be constructed. >+ */ >+public void testVisibility2() throws JavaModelException { >+ IType type = getCompilationUnit("/TypeHierarchy/src/q6/Z.java").getType("Z"); >+ ITypeHierarchy hierarchy = type.newTypeHierarchy(null); >+ assertHierarchyEquals( >+ "Focus: Z [in Z.java [in q6 [in src [in TypeHierarchy]]]]\n" + >+ "Super types:\n" + >+ " NonVisibleInterface [in X.java [in q5 [in src [in TypeHierarchy]]]]\n" + >+ " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + " [in TypeHierarchy]]]]\n" + >+ "Sub types:\n", >+ hierarchy >+ ); >+} > } >Index: workspace/TypeHierarchy/src/q6/Y.java >=================================================================== >RCS file: workspace/TypeHierarchy/src/q6/Y.java >diff -N workspace/TypeHierarchy/src/q6/Y.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/TypeHierarchy/src/q6/Y.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,3 @@ >+package q6; >+public class Y extends q5.NonVisibleClass { >+} >Index: workspace/TypeHierarchy/src/q6/Z.java >=================================================================== >RCS file: workspace/TypeHierarchy/src/q6/Z.java >diff -N workspace/TypeHierarchy/src/q6/Z.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/TypeHierarchy/src/q6/Z.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,3 @@ >+package q6; >+public class Z implements q5.NonVisibleInterface { >+} >Index: workspace/TypeHierarchy/src/q5/X.java >=================================================================== >RCS file: workspace/TypeHierarchy/src/q5/X.java >diff -N workspace/TypeHierarchy/src/q5/X.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/TypeHierarchy/src/q5/X.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+package q5; >+public class X { >+} >+class NonVisibleClass { >+} >+interface NonVisibleInterface { >+} >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java,v >retrieving revision 1.64 >diff -u -r1.64 HierarchyResolver.java >--- model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 29 Mar 2006 03:14:01 -0000 1.64 >+++ model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 26 Apr 2006 12:54:43 -0000 >@@ -155,6 +155,20 @@ > */ > private IType findSuperClass(IGenericType type, ReferenceBinding typeBinding) { > ReferenceBinding superBinding = typeBinding.superclass(); >+ >+ // check if the super binding was replaced with the java.lang.Object binding (because of a visibility problem for example) >+ ClassScope scope; >+ if (typeBinding instanceof SourceTypeBinding && (scope = ((SourceTypeBinding) typeBinding).scope) != null) { >+ TypeDeclaration typeDeclaration = scope.referenceContext; >+ TypeReference superclassRef = typeDeclaration == null ? null : typeDeclaration.superclass; >+ TypeBinding superclass = superclassRef == null ? null : superclassRef.resolvedType; >+ if (superclass instanceof ProblemReferenceBinding) { >+ superclass = ((ProblemReferenceBinding) superclass).closestMatch; >+ if (superclass != null) >+ ((SourceTypeBinding) typeBinding).superclass = superBinding = (ReferenceBinding) superclass; >+ } >+ } >+ > if (superBinding != null) { > superBinding = (ReferenceBinding) superBinding.erasure(); > if (superBinding.id == TypeIds.T_JavaLangObject && typeBinding.isHierarchyInconsistent()) { >@@ -233,6 +247,30 @@ > } > > ReferenceBinding[] interfaceBindings = typeBinding.superInterfaces(); >+ >+ // check if bindings were removed while resolving (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=136095) >+ ClassScope scope; >+ if (typeBinding instanceof SourceTypeBinding && (scope = ((SourceTypeBinding) typeBinding).scope) != null) { >+ TypeDeclaration typeDeclaration = scope.referenceContext; >+ TypeReference[] superInterfaces = typeDeclaration == null ? null : typeDeclaration.superInterfaces; >+ int length; >+ if (superInterfaces != null && (length = superInterfaces.length) > interfaceBindings.length) { >+ >+ interfaceBindings = new ReferenceBinding[length]; >+ int index = 0; >+ for (int i = 0; i < length; i++) { >+ ReferenceBinding superInterface = (ReferenceBinding) superInterfaces[i].resolvedType; >+ if (superInterface instanceof ProblemReferenceBinding) >+ superInterface = ((ProblemReferenceBinding) superInterface).closestMatch; >+ if (superInterface != null) >+ interfaceBindings[index++] = superInterface; >+ } >+ if (index < length) >+ System.arraycopy(interfaceBindings, 0, interfaceBindings = new ReferenceBinding[index], 0 , index); >+ ((SourceTypeBinding) typeBinding).superInterfaces = interfaceBindings; >+ } >+ } >+ > int bindingIndex = 0; > int bindingLength = interfaceBindings == null ? 0 : interfaceBindings.length; > int length = superInterfaceNames == null ? 0 : superInterfaceNames.length;
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 Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 136095
:
38408
| 39518