Bug 11129 - DOM/AST: Call resolveTypeBinding() on a CastExpression object throws a NullPoitnerException
Summary: DOM/AST: Call resolveTypeBinding() on a CastExpression object throws a NullPo...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-11 16:08 EST by Luc Bourlier CLA
Modified: 2002-03-11 17:40 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luc Bourlier CLA 2002-03-11 16:08:10 EST
In the AST of this code :

class A {
  void test() {
    char x;
    x = (char)3;
  }
}

call resolveTypeBinding() on the CastExpression object throws a
NullPoitnerException :

java.lang.NullPointerException
 at
org.eclipse.jdt.core.dom.DefaultBindingResolver.resolveExpressionType(DefaultBindingResolver.java:318)
 at
org.eclipse.jdt.core.dom.DefaultBindingResolver.resolveExpressionType(DefaultBindingResolver.java:379)
 at org.eclipse.jdt.core.dom.Expression.resolveTypeBinding(Expression.java:75)
I made these changes in my host for fix the problem, but I don't think that is
the right solution (DefaultBindingResolver::resolveExpressionType(Expression
expression)):

  } else if (expression instanceof CastExpression) {
    return ((CastExpression) expression).getType().resolveBinding();
//  org.eclipse.jdt.internal.compiler.ast.CastExpression castExpression =
//(org.eclipse.jdt.internal.compiler.ast.CastExpression).this.newAstToOldAst.get(expression);
//  return this.getTypeBinding(castExpression.castTb);
  } else if (expression instanceof StringLiteral) {
Comment 1 Olivier Thomann CLA 2002-03-11 17:40:29 EST
Your fix is not quite what I did, but it could work too. I missed the record(...) in the 
convert(CastExpression) in the ASTConverter. The get for the hashtable should never return 
null.
Fixed and released in HEAD.