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 82455 Details for
Bug 186410
[dom] StackOverflowError due to endless superclass bindings hierarchy
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New proposed patch
v03.txt (text/plain), 15.06 KB, created by
Frederic Fusier
on 2007-11-08 11:02:37 EST
(
hide
)
Description:
New proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-11-08 11:02:37 EST
Size:
15.06 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/RunConverterTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/RunConverterTests.java,v >retrieving revision 1.19 >diff -u -r1.19 RunConverterTests.java >--- src/org/eclipse/jdt/core/tests/dom/RunConverterTests.java 14 Sep 2007 19:37:24 -0000 1.19 >+++ src/org/eclipse/jdt/core/tests/dom/RunConverterTests.java 8 Nov 2007 15:54:07 -0000 >@@ -27,6 +27,7 @@ > return new Class[] { > ASTConverterTest.class, > ASTConverterTest2.class, >+ ASTConverterBugsTest.class, > ASTConverterJavadocTest.class, > ASTConverter15Test.class, > ASTConverter16Test.class, >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java >=================================================================== >RCS file: src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java >diff -N src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,131 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.tests.dom; >+ >+import java.io.IOException; >+ >+import junit.framework.Test; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.dom.AST; >+import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+import org.eclipse.jdt.core.dom.FieldDeclaration; >+import org.eclipse.jdt.core.dom.ITypeBinding; >+import org.eclipse.jdt.core.dom.Type; >+ >+public class ASTConverterBugsTest extends ConverterTestSetup { >+ >+ public void setUpSuite() throws Exception { >+ PROJECT_SETUP = true; // do not copy Converter* directories >+ super.setUpSuite(); >+ waitUntilIndexesReady(); >+ } >+ >+ public ASTConverterBugsTest(String name) { >+ super(name); >+ } >+ >+ public static Test suite() { >+ return buildModelTestSuite(ASTConverterBugsTest.class); >+ } >+ >+ /** >+ * @bug 186410: [dom] StackOverflowError due to endless superclass bindings hierarchy >+ * @test Ensures that the superclass of "java.lang.Object" class is null even when it's a recovered binding >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=186410" >+ */ >+ public void testBug186410() throws CoreException, IOException { >+ try { >+ createJavaProject("P", new String[] {""}, new String[0], ""); >+ createFile("P/A.java", >+ "public class A {\n" + >+ " void method(){}\n" + >+ "}" >+ ); >+ ICompilationUnit cuA = getCompilationUnit("P/A.java"); >+ CompilationUnit unitA = (CompilationUnit) runConversion(AST.JLS3, cuA, true, false, true); >+ AbstractTypeDeclaration typeA = (AbstractTypeDeclaration)unitA.types().get(0); >+ ITypeBinding objectType = typeA.resolveBinding().getSuperclass(); >+ assertEquals("Unexpected superclass", "Object", objectType .getName()); >+ ITypeBinding objectSuperclass = objectType.getSuperclass(); >+ assertNull("java.lang.Object should not have any superclass", objectSuperclass); >+ } finally { >+ deleteProject("P"); >+ } >+ } >+ public void testBug186410b() throws CoreException, IOException { >+ try { >+ createJavaProject("P", new String[] {""}, new String[0], ""); >+ createFile("P/A.java", >+ "public class A {\n" + >+ " Object field;\n" + >+ "}" >+ ); >+ ICompilationUnit cuA = getCompilationUnit("P/A.java"); >+ CompilationUnit unitA = (CompilationUnit) runConversion(AST.JLS3, cuA, true, false, true); >+ AbstractTypeDeclaration type = (AbstractTypeDeclaration)unitA.types().get(0); >+ FieldDeclaration field = (FieldDeclaration) type.bodyDeclarations().get(0); >+ Type fieldType = field.getType(); >+ ITypeBinding typeBinding = fieldType.resolveBinding(); >+ ITypeBinding objectType = typeBinding.createArrayType(2).getElementType(); >+ assertEquals("Unexpected superclass", "Object", objectType.getName()); >+ ITypeBinding objectSuperclass = objectType.getSuperclass(); >+ assertNull("java.lang.Object should not have any superclass", objectSuperclass); >+ } finally { >+ deleteProject("P"); >+ } >+ } >+ >+ /** >+ * @bug 209510: [dom] Recovered type binding for "java.lang.Object" information are not complete >+ * @test Ensures that getPackage() and getQualifiedName() works properly for the "java.lang.Object" recovered binding >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=209510" >+ */ >+ public void testBug209510a() throws CoreException, IOException { >+ try { >+ createJavaProject("P", new String[] {""}, new String[0], ""); >+ createFile("P/A.java", >+ "public class A {\n" + >+ " void method(){}\n" + >+ "}" >+ ); >+ ICompilationUnit cuA = getCompilationUnit("P/A.java"); >+ CompilationUnit unitA = (CompilationUnit) runConversion(AST.JLS3, cuA, true, false, true); >+ AbstractTypeDeclaration typeA = (AbstractTypeDeclaration)unitA.types().get(0); >+ ITypeBinding objectType = typeA.resolveBinding().getSuperclass(); >+ assertTrue("'java.lang.Object' should be recovered!", objectType.isRecovered()); >+ assertEquals("Unexpected package for recovered 'java.lang.Object'", "java.lang", objectType .getPackage().getName()); >+ } finally { >+ deleteProject("P"); >+ } >+ } >+ public void testBug209510b() throws CoreException, IOException { >+ try { >+ createJavaProject("P", new String[] {""}, new String[0], ""); >+ createFile("P/A.java", >+ "public class A {\n" + >+ " void method(){}\n" + >+ "}" >+ ); >+ ICompilationUnit cuA = getCompilationUnit("P/A.java"); >+ CompilationUnit unitA = (CompilationUnit) runConversion(AST.JLS3, cuA, true, false, true); >+ AbstractTypeDeclaration typeA = (AbstractTypeDeclaration)unitA.types().get(0); >+ ITypeBinding objectType = typeA.resolveBinding().getSuperclass(); >+ assertTrue("'java.lang.Object' should be recovered!", objectType.isRecovered()); >+ assertEquals("Unexpected qualified name for recovered 'java.lang.Object'", "java.lang.Object", objectType .getQualifiedName()); >+ } finally { >+ deleteProject("P"); >+ } >+ } >+ >+} >#P org.eclipse.jdt.core >Index: dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java,v >retrieving revision 1.7 >diff -u -r1.7 RecoveredTypeBinding.java >--- dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java 24 Aug 2007 17:17:34 -0000 1.7 >+++ dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java 8 Nov 2007 15:54:09 -0000 >@@ -15,8 +15,10 @@ > > import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; > import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; >+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; > import org.eclipse.jdt.internal.compiler.util.Util; > import org.eclipse.jdt.internal.core.CompilationUnit; > import org.eclipse.jdt.internal.core.PackageFragment; >@@ -32,7 +34,7 @@ > private int dimensions; > private RecoveredTypeBinding innerTypeBinding; > private ITypeBinding[] typeArguments; >- private org.eclipse.jdt.internal.compiler.lookup.TypeBinding referenceBinding; >+ private org.eclipse.jdt.internal.compiler.lookup.TypeBinding typeBinding; > > RecoveredTypeBinding(BindingResolver resolver, VariableDeclaration variableDeclaration) { > this.variableDeclaration = variableDeclaration; >@@ -44,10 +46,10 @@ > } > } > >- RecoveredTypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding referenceBinding) { >+ RecoveredTypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding typeBinding) { > this.resolver = resolver; >- this.dimensions = referenceBinding.dimensions(); >- this.referenceBinding = referenceBinding; >+ this.dimensions = typeBinding.dimensions(); >+ this.typeBinding = typeBinding; > } > > RecoveredTypeBinding(BindingResolver resolver, Type type) { >@@ -147,12 +149,12 @@ > * @see org.eclipse.jdt.core.dom.ITypeBinding#getElementType() > */ > public ITypeBinding getElementType() { >- if (this.referenceBinding != null) { >- if (this.referenceBinding.isArrayType()) { >- ArrayBinding arrayBinding = (ArrayBinding) this.referenceBinding; >+ if (this.typeBinding != null) { >+ if (this.typeBinding.isArrayType()) { >+ ArrayBinding arrayBinding = (ArrayBinding) this.typeBinding; > return new RecoveredTypeBinding(this.resolver, arrayBinding.leafComponentType); > } else { >- return new RecoveredTypeBinding(this.resolver, this.referenceBinding); >+ return new RecoveredTypeBinding(this.resolver, this.typeBinding); > } > } > if (this.innerTypeBinding != null) { >@@ -205,19 +207,10 @@ > private String getInternalName() { > if (this.innerTypeBinding != null) { > return this.innerTypeBinding.getInternalName(); >- } else if (this.referenceBinding != null) { >- org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding typeBinding = null; >- if (this.referenceBinding.isArrayType()) { >- ArrayBinding arrayBinding = (ArrayBinding) this.referenceBinding; >- if (arrayBinding.leafComponentType instanceof org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) { >- typeBinding = (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) arrayBinding.leafComponentType; >- } >- } else if (this.referenceBinding instanceof org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) { >- typeBinding = (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) this.referenceBinding; >- } >- if (typeBinding != null) { >- return new String(typeBinding.compoundName[typeBinding.compoundName.length - 1]); >- } >+ } >+ ReferenceBinding referenceBinding = getReferenceBinding(); >+ if (referenceBinding != null) { >+ return new String(referenceBinding.compoundName[referenceBinding.compoundName.length - 1]); > } > return this.getTypeNameFrom(getType()); > } >@@ -226,6 +219,11 @@ > * @see org.eclipse.jdt.core.dom.ITypeBinding#getPackage() > */ > public IPackageBinding getPackage() { >+ ReferenceBinding referenceBinding = getReferenceBinding(); >+ if (referenceBinding != null) { >+ IPackageBinding packageBinding = this.resolver.getPackageBinding(referenceBinding.fPackage); >+ if (packageBinding != null) return packageBinding; >+ } > CompilationUnitScope scope = this.resolver.scope(); > if (scope != null) { > return this.resolver.getPackageBinding(scope.getCurrentPackage()); >@@ -237,13 +235,34 @@ > * @see org.eclipse.jdt.core.dom.ITypeBinding#getQualifiedName() > */ > public String getQualifiedName() { >- return this.getName(); >+ ReferenceBinding referenceBinding = getReferenceBinding(); >+ if (referenceBinding != null) { >+ return CharOperation.toString(referenceBinding.compoundName); >+ } >+ return getName(); >+ } >+ >+ private ReferenceBinding getReferenceBinding() { >+ if (this.typeBinding != null) { >+ if (this.typeBinding.isArrayType()) { >+ ArrayBinding arrayBinding = (ArrayBinding) this.typeBinding; >+ if (arrayBinding.leafComponentType instanceof ReferenceBinding) { >+ return (ReferenceBinding) arrayBinding.leafComponentType; >+ } >+ } else if (this.typeBinding instanceof ReferenceBinding) { >+ return (ReferenceBinding) this.typeBinding; >+ } >+ } >+ return null; > } > > /* (non-Javadoc) > * @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() > */ > public ITypeBinding getSuperclass() { >+ if (getQualifiedName().equals("java.lang.Object")) { //$NON-NLS-1$ >+ return null; >+ } > return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ > } > >@@ -251,7 +270,7 @@ > * @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() > */ > public ITypeBinding[] getTypeArguments() { >- if (this.referenceBinding != null) { >+ if (this.typeBinding != null) { > return this.typeArguments = TypeBinding.NO_TYPE_BINDINGS; > } > if (this.typeArguments != null) { >@@ -331,12 +350,12 @@ > /* (non-Javadoc) > * @see org.eclipse.jdt.core.dom.ITypeBinding#isAssignmentCompatible(org.eclipse.jdt.core.dom.ITypeBinding) > */ >- public boolean isAssignmentCompatible(ITypeBinding typeBinding) { >- if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ >+ public boolean isAssignmentCompatible(ITypeBinding binding) { >+ if ("java.lang.Object".equals(binding.getQualifiedName())) { //$NON-NLS-1$ > return true; > } > // since recovered binding are not unique isEqualTo is required >- return this.isEqualTo(typeBinding); >+ return this.isEqualTo(binding); > } > > /* (non-Javadoc) >@@ -349,12 +368,12 @@ > /* (non-Javadoc) > * @see org.eclipse.jdt.core.dom.ITypeBinding#isCastCompatible(org.eclipse.jdt.core.dom.ITypeBinding) > */ >- public boolean isCastCompatible(ITypeBinding typeBinding) { >- if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ >+ public boolean isCastCompatible(ITypeBinding binding) { >+ if ("java.lang.Object".equals(binding.getQualifiedName())) { //$NON-NLS-1$ > return true; > } > // since recovered binding are not unique isEqualTo is required >- return this.isEqualTo(typeBinding); >+ return this.isEqualTo(binding); > } > > /* (non-Javadoc) >@@ -450,12 +469,12 @@ > /* (non-Javadoc) > * @see org.eclipse.jdt.core.dom.ITypeBinding#isSubTypeCompatible(org.eclipse.jdt.core.dom.ITypeBinding) > */ >- public boolean isSubTypeCompatible(ITypeBinding typeBinding) { >- if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ >+ public boolean isSubTypeCompatible(ITypeBinding binding) { >+ if ("java.lang.Object".equals(binding.getQualifiedName())) { //$NON-NLS-1$ > return true; > } > // since recovered binding are not unique isEqualTo is required >- return this.isEqualTo(typeBinding); >+ return this.isEqualTo(binding); > } > > /* (non-Javadoc) >@@ -523,9 +542,9 @@ > } else if (this.currentType != null) { > buffer.append("currentType") //$NON-NLS-1$ > .append(this.currentType.toString()); >- } else if (this.referenceBinding != null) { >- buffer.append("referenceBinding") //$NON-NLS-1$ >- .append(this.referenceBinding.computeUniqueKey()); >+ } else if (this.typeBinding != null) { >+ buffer.append("typeBinding") //$NON-NLS-1$ >+ .append(this.typeBinding.computeUniqueKey()); > } else if (variableDeclaration != null) { > buffer > .append("variableDeclaration") //$NON-NLS-1$
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 186410
:
82336
|
82427
|
82455
|
82466
|
82472
|
82754