Community
Participate
Working Groups
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) {
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.