Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 341930

Summary: BinaryTypeBinding cannot be cast to SourceTypeBinding while debugging
Product: [Eclipse Project] JDT Reporter: Mauro Molinari <mauromol>
Component: DebugAssignee: JDT-Debug-Inbox <jdt-debug-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: major    
Priority: P3 CC: Michael_Rennie
Version: 3.6.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mauro Molinari CLA 2011-04-05 11:16:16 EDT
I often get the following problem while debugging (and clicking on a variable in the Variables view):

'JDI thread evaluations' has encountered a problem.
Exception processing async thread queue.

Stack trace:
java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding
at org.eclipse.jdt.internal.compiler.lookup.TypeBinding.isProvablyDistinct(TypeBinding.java:633)
at org.eclipse.jdt.internal.compiler.ast.Expression.checkUnsafeCast(Expression.java:526)
at org.eclipse.jdt.internal.compiler.ast.Expression.checkCastTypesCompatibility(Expression.java:486)
at org.eclipse.jdt.core.dom.TypeBinding.isCastCompatible(TypeBinding.java:1014)
at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTInstructionCompiler.getEnclosingLevel(ASTInstructionCompiler.java:406)
at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTInstructionCompiler.visit(ASTInstructionCompiler.java:2757)
at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:237)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTInstructionCompiler.visit(ASTInstructionCompiler.java:2141)
at org.eclipse.jdt.core.dom.EnhancedForStatement.accept0(EnhancedForStatement.java:184)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2551)
at org.eclipse.jdt.core.dom.Block.accept0(Block.java:136)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2528)
at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:504)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2551)
at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:484)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2551)
at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:219)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2480)
at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.createExpressionFromAST(ASTEvaluationEngine.java:414)
at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.getCompiledExpression(ASTEvaluationEngine.java:361)
at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine.getCompiledExpression(ASTEvaluationEngine.java:331)
at org.eclipse.jdt.internal.debug.ui.JavaDetailFormattersManager.getCompiledExpression(JavaDetailFormattersManager.java:395)
at org.eclipse.jdt.internal.debug.ui.JavaDetailFormattersManager.resolveFormatter(JavaDetailFormattersManager.java:158)
at org.eclipse.jdt.internal.debug.ui.JavaDetailFormattersManager.access$1(JavaDetailFormattersManager.java:143)
at org.eclipse.jdt.internal.debug.ui.JavaDetailFormattersManager$2.run(JavaDetailFormattersManager.java:138)
at org.eclipse.jdt.internal.debug.core.model.JDIThread$ThreadJob.run(JDIThread.java:2756)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Unfortunately I was not able to reproduce with a simple test case, but I can reproduce consistently with the project I'm working on now.

This problem doesn't let me inspect variables values in the Variables view. Moreover, if I try to inspect the selected code in the editor (through Ctrl+Shift+I) I get the following:
Evaluations must contain either an expression or a blockof well-formed statements.
Comment 1 Mauro Molinari CLA 2011-04-05 11:21:19 EDT
I just found out the following. The error shows up on a java.util.Properties instance and it disappears if I disable a detail formatter I have for java.util.Map variables. The formatter code snippet is the following:

String result = "";
for(final Object o : keySet())
{
  Object value = get(o);
	result = result + String.valueOf(o) + " = " + 
	  String.valueOf(value) + "\n";
}
return result;
Comment 2 Michael Rennie CLA 2011-04-05 12:12:43 EDT

*** This bug has been marked as a duplicate of bug 317046 ***
Comment 3 Mauro Molinari CLA 2011-04-05 12:16:29 EDT
Thank you Michael and sorry for the duplication, I did a couple of searches for BinaryTypeBinding/cast/etc. but couldn't find anything.