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 82427 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]
Better proposed patch
v02.txt (text/plain), 9.53 KB, created by
Frederic Fusier
on 2007-11-08 07:06:31 EST
(
hide
)
Description:
Better proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2007-11-08 07:06:31 EST
Size:
9.53 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 12:01:08 -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,88 @@ >+/******************************************************************************* >+ * 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"); >+ } >+ } >+} >#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 12:01:15 -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; >@@ -73,6 +75,42 @@ > } > > /* (non-Javadoc) >+ * @see java.lang.Object#equals(java.lang.Object) >+ */ >+ public boolean equals(Object obj) { >+ if (this == obj) return true; // super implementation >+ if (obj instanceof RecoveredTypeBinding) { >+ RecoveredTypeBinding otherTypeBinding = (RecoveredTypeBinding) obj; >+ if (this.innerTypeBinding != null) { >+ return getName().equals(otherTypeBinding.getName()) && this.innerTypeBinding.equals(otherTypeBinding.innerTypeBinding); >+ } >+ if (this.referenceBinding != null && otherTypeBinding.referenceBinding != null) { >+ ReferenceBinding currentReferenceTypeBinding = null; >+ ReferenceBinding otherReferenceTypeBinding = null; >+ if (this.referenceBinding.isArrayType() && otherTypeBinding.referenceBinding.isArrayType()) { >+ ArrayBinding currentArrayBinding = (ArrayBinding) this.referenceBinding; >+ ArrayBinding otherArrayBinding = (ArrayBinding) otherTypeBinding.referenceBinding; >+ if (currentArrayBinding.leafComponentType instanceof ReferenceBinding && >+ otherArrayBinding.leafComponentType instanceof ReferenceBinding) { >+ currentReferenceTypeBinding = (ReferenceBinding) currentArrayBinding.leafComponentType; >+ otherReferenceTypeBinding = (ReferenceBinding) otherArrayBinding.leafComponentType; >+ } >+ } else if (this.referenceBinding instanceof ReferenceBinding && >+ otherTypeBinding.referenceBinding instanceof ReferenceBinding) { >+ currentReferenceTypeBinding = (ReferenceBinding) this.referenceBinding; >+ otherReferenceTypeBinding = (ReferenceBinding) otherTypeBinding.referenceBinding; >+ } >+ if (currentReferenceTypeBinding != null && otherReferenceTypeBinding != null) { >+ return CharOperation.equals(currentReferenceTypeBinding.compoundName, otherReferenceTypeBinding.compoundName); >+ } >+ } else { >+ return getType().toString().equals(otherTypeBinding.toString()); >+ } >+ } >+ return false; >+ } >+ >+ /* (non-Javadoc) > * @see org.eclipse.jdt.core.dom.ITypeBinding#getBinaryName() > */ > public String getBinaryName() { >@@ -206,14 +244,14 @@ > if (this.innerTypeBinding != null) { > return this.innerTypeBinding.getInternalName(); > } else if (this.referenceBinding != null) { >- org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding typeBinding = null; >+ 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; >+ if (arrayBinding.leafComponentType instanceof ReferenceBinding) { >+ typeBinding = (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; >+ } else if (this.referenceBinding instanceof ReferenceBinding) { >+ typeBinding = (ReferenceBinding) this.referenceBinding; > } > if (typeBinding != null) { > return new String(typeBinding.compoundName[typeBinding.compoundName.length - 1]); >@@ -244,7 +282,12 @@ > * @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() > */ > public ITypeBinding getSuperclass() { >- return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ >+ ITypeBinding object = this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ >+ if (equals(object)) { >+ // avoid loop when java.lang.Object is also recovered >+ return null; >+ } >+ return object; > } > > /* (non-Javadoc)
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