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 193439 Details for
Bug 342671
ClassCastException: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ArrayBinding
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
my proposal
Bug_342671_SH1.patch (text/plain), 10.71 KB, created by
Stephan Herrmann
on 2011-04-17 13:31:18 EDT
(
hide
)
Description:
my proposal
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2011-04-17 13:31:18 EDT
Size:
10.71 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java,v >retrieving revision 1.63 >diff -u -r1.63 ParameterizedQualifiedTypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 1 Nov 2010 14:15:46 -0000 1.63 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 17 Apr 2011 17:03:43 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -128,6 +128,11 @@ > } > } > this.bits |= ASTNode.DidResolve; >+ TypeBinding type = internalResolveLeafType(scope, checkBounds); >+ createArrayType(scope); >+ return type == null ? type : this.resolvedType; >+ } >+ private TypeBinding internalResolveLeafType(Scope scope, boolean checkBounds) { > boolean isClassScope = scope.kind == Scope.CLASS_SCOPE; > Binding binding = scope.getPackage(this.tokens); > if (binding != null && !binding.isValidBinding()) { >@@ -236,11 +241,6 @@ > this.resolvedType = (qualifyingType != null && qualifyingType.isParameterizedType()) > ? scope.environment().createParameterizedType(currentOriginal, null, qualifyingType) > : currentType; >- if (this.dimensions > 0) { >- if (this.dimensions > 255) >- scope.problemReporter().tooManyDimensions(this); >- this.resolvedType = scope.createArrayType(this.resolvedType, this.dimensions); >- } > return this.resolvedType; > } else if (argLength != typeVariables.length) { // check arity > scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes, i); >@@ -283,13 +283,14 @@ > reportDeprecatedType(qualifyingType, scope, i); > this.resolvedType = qualifyingType; > } >- // array type ? >+ return this.resolvedType; >+ } >+ public void createArrayType(Scope scope) { > if (this.dimensions > 0) { > if (this.dimensions > 255) > scope.problemReporter().tooManyDimensions(this); > this.resolvedType = scope.createArrayType(this.resolvedType, this.dimensions); > } >- return this.resolvedType; > } > > public StringBuffer printExpression(int indent, StringBuffer output) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java,v >retrieving revision 1.54 >diff -u -r1.54 ParameterizedSingleTypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 1 Nov 2010 14:15:46 -0000 1.54 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 17 Apr 2011 17:03:43 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -105,15 +105,28 @@ > } > } > } >- boolean hasGenericError = false; >- ReferenceBinding currentType; > this.bits |= ASTNode.DidResolve; >+ TypeBinding type = internalResolveLeafType(scope, enclosingType, checkBounds); >+ // handle three different outcomes: >+ if (type == null) { >+ this.resolvedType = createArrayType(scope, this.resolvedType); >+ return null; // no useful type, but still captured dimensions into this.resolvedType >+ } else { >+ type = createArrayType(scope, type); >+ if (!this.resolvedType.isValidBinding()) >+ return type; // found some error, but could recover useful type (like closestMatch) >+ else >+ return this.resolvedType = type; // no complaint, keep fully resolved type (incl. dimensions) >+ } >+ } >+ private TypeBinding internalResolveLeafType(Scope scope, ReferenceBinding enclosingType, boolean checkBounds) { >+ ReferenceBinding currentType; > if (enclosingType == null) { > this.resolvedType = scope.getType(this.token); > if (this.resolvedType.isValidBinding()) { > currentType = (ReferenceBinding) this.resolvedType; > } else { >- hasGenericError = true; >+ > reportInvalidType(scope); > switch (this.resolvedType.problemId()) { > case ProblemReasons.NotFound : >@@ -150,7 +163,6 @@ > } else { // resolving member type (relatively to enclosingType) > this.resolvedType = currentType = scope.getMemberType(this.token, enclosingType); > if (!this.resolvedType.isValidBinding()) { >- hasGenericError = true; > scope.problemReporter().invalidEnclosingType(this, currentType, enclosingType); > return null; > } >@@ -205,16 +217,9 @@ > } > // resilience do not rebuild a parameterized type unless compliance is allowing it > if (!isCompliant15) { >- // array type ? >- TypeBinding type = currentType; >- if (this.dimensions > 0) { >- if (this.dimensions > 255) >- scope.problemReporter().tooManyDimensions(this); >- type = scope.createArrayType(type, this.dimensions); >- } >- if (hasGenericError) >- return type; >- return this.resolvedType = type; >+ if (!this.resolvedType.isValidBinding()) >+ return currentType; >+ return this.resolvedType = currentType; > } > // if missing generic type, and compliance >= 1.5, then will rebuild a parameterized binding > } else if (argLength != typeVariables.length) { // check arity >@@ -238,17 +243,18 @@ > if (isTypeUseDeprecated(parameterizedType, scope)) > reportDeprecatedType(parameterizedType, scope); > >- TypeBinding type = parameterizedType; >- // array type ? >+ if (!this.resolvedType.isValidBinding()) { >+ return parameterizedType; >+ } >+ return this.resolvedType = parameterizedType; >+ } >+ public TypeBinding createArrayType(Scope scope, TypeBinding type) { > if (this.dimensions > 0) { > if (this.dimensions > 255) > scope.problemReporter().tooManyDimensions(this); >- type = scope.createArrayType(type, this.dimensions); >- } >- if (hasGenericError) { >- return type; >+ return scope.createArrayType(type, this.dimensions); > } >- return this.resolvedType = type; >+ return type; > } > > public StringBuffer printExpression(int indent, StringBuffer output){ >Index: dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java,v >retrieving revision 1.173 >diff -u -r1.173 DefaultBindingResolver.java >--- dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 13 Apr 2011 14:10:29 -0000 1.173 >+++ dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 17 Apr 2011 17:03:47 -0000 >@@ -1523,11 +1523,8 @@ > return null; > } > ArrayType arrayType = (ArrayType) type; >- if (typeBinding.isArrayType()) { >- ArrayBinding arrayBinding = (ArrayBinding) typeBinding; >- return getTypeBinding(this.scope.createArrayType(arrayBinding.leafComponentType, arrayType.getDimensions())); >- } >- return getTypeBinding(this.scope.createArrayType(typeBinding, arrayType.getDimensions())); >+ ArrayBinding arrayBinding = (ArrayBinding) typeBinding; >+ return getTypeBinding(this.scope.createArrayType(arrayBinding.leafComponentType, arrayType.getDimensions())); > } > if (typeBinding.isArrayType()) { > typeBinding = ((ArrayBinding) typeBinding).leafComponentType; >@@ -1567,11 +1564,8 @@ > if (this.scope == null) { > return null; > } >- if (binding.isArrayType()) { >- ArrayBinding arrayBinding = (ArrayBinding) binding; >- return getTypeBinding(this.scope.createArrayType(arrayBinding.leafComponentType, arrayType.getDimensions())); >- } >- return getTypeBinding(this.scope.createArrayType(binding, arrayType.getDimensions())); >+ ArrayBinding arrayBinding = (ArrayBinding) binding; >+ return getTypeBinding(this.scope.createArrayType(arrayBinding.leafComponentType, arrayType.getDimensions())); > } else if (binding.isArrayType()) { > ArrayBinding arrayBinding = (ArrayBinding) binding; > return getTypeBinding(arrayBinding.leafComponentType); >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java,v >retrieving revision 1.306 >diff -u -r1.306 ASTConverter15Test.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 13 Apr 2011 14:10:29 -0000 1.306 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 17 Apr 2011 17:04:10 -0000 >@@ -49,7 +49,7 @@ > static { > // TESTS_NUMBERS = new int[] { 351, 352 }; > // TESTS_RANGE = new int[] { 325, -1 }; >-// TESTS_NAMES = new String[] {"test0204"}; >+// TESTS_NAMES = new String[] {"test035"}; > } > public static Test suite() { > return buildModelTestSuite(ASTConverter15Test.class); >@@ -11295,6 +11295,17 @@ > assertEquals("Wrong fully qualified name", "test0351.I1[]", typeBinding.getQualifiedName()); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=342671 >+ public void test0351a() throws JavaModelException { >+ ICompilationUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0351", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ >+ ASTNode result = runJLS3Conversion(sourceUnit, true, true); >+ assertTrue("Not a compilation unit", result.getNodeType() == ASTNode.COMPILATION_UNIT); >+ CompilationUnit unit = (CompilationUnit) result; >+ MethodDeclaration methodDeclaration = (MethodDeclaration) getASTNode(unit, 0, 0); >+ Type componentType = ((ArrayType)methodDeclaration.getReturnType2()).getComponentType(); >+ ITypeBinding typeBinding = componentType.resolveBinding(); >+ assertEquals("Wrong fully qualified name", "test0351.I1", typeBinding.getQualifiedName()); >+ } >+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=342671 > public void test0352() throws JavaModelException { > ICompilationUnit sourceUnit = getCompilationUnit("Converter15" , "src", "test0352", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ > ASTNode result = runJLS3Conversion(sourceUnit, true, true);
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 342671
:
193126
|
193148
|
193157
|
193158
|
193271
|
193272
| 193439