Bug 96719 - [breakpoints] Support for conditions in Watchpoints and
exception breakpoints - Work In Progress

Change-Id: I858da79f444779947a5fd1b456dc20ad45b31977
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/breakpoints/JavaBreakpointConditionEditor.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/breakpoints/JavaBreakpointConditionEditor.java
index cb8da9e..23a09df 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/breakpoints/JavaBreakpointConditionEditor.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/breakpoints/JavaBreakpointConditionEditor.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 2017 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
@@ -28,6 +28,7 @@
 import org.eclipse.jdt.core.ICompilationUnit;
 import org.eclipse.jdt.core.IType;
 import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
+import org.eclipse.jdt.debug.core.IJavaWatchpoint;
 import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
 import org.eclipse.jdt.internal.debug.ui.JDISourceViewer;
@@ -213,6 +214,8 @@
 			suppressPropertyChanges(true);
 			if (input instanceof IJavaLineBreakpoint) {
 				setBreakpoint((IJavaLineBreakpoint)input);
+			} else if (input instanceof IJavaWatchpoint) {
+				setBreakpoint((IJavaWatchpoint) input);
 			} else {
 				setBreakpoint(null);
 			}
@@ -263,6 +266,8 @@
 		IJavaDebugContentAssistContext context = null;
 		if (type == null || breakpoint == null) {
 			context = new TypeContext(null, -1);
+		} else if (breakpoint instanceof IJavaWatchpoint) {
+			context = new TypeContext(type, 0);
 		} else {
 			String source = null;
 			ICompilationUnit compilationUnit = type.getCompilationUnit();
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/breakpoints/WatchpointDetailPane.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/breakpoints/WatchpointDetailPane.java
index a84eac2..12e1713 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/breakpoints/WatchpointDetailPane.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/breakpoints/WatchpointDetailPane.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- *  Copyright (c) 2009, 2016 IBM Corporation and others.
+ *  Copyright (c) 2009, 2017 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
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.eclipse.jdt.internal.debug.ui.breakpoints;
 
+import org.eclipse.jdt.debug.ui.breakpoints.JavaBreakpointConditionEditor;
 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
 import org.eclipse.swt.widgets.Composite;
 
@@ -32,7 +33,8 @@
 				StandardJavaBreakpointEditor.PROP_SUSPEND_POLICY,
 				StandardJavaBreakpointEditor.PROP_TRIGGER_POINT,
 				WatchpointEditor.PROP_ACCESS,
-				WatchpointEditor.PROP_MODIFICATION
+				WatchpointEditor.PROP_MODIFICATION, JavaBreakpointConditionEditor.PROP_CONDITION_ENABLED,
+				JavaBreakpointConditionEditor.PROP_CONDITION_SUSPEND_POLICY
 		});
 	}
 	
@@ -41,7 +43,7 @@
 	 */
 	@Override
 	protected AbstractJavaBreakpointEditor createEditor(Composite parent) {
-		return new WatchpointEditor();
+		return new CompositeBreakpointEditor(new AbstractJavaBreakpointEditor[] { new WatchpointEditor(), new JavaBreakpointConditionEditor(null) });
 	}
 
 }
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/propertypages/JavaBreakpointPage.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/propertypages/JavaBreakpointPage.java
index 6942df7..7cb94d6 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/propertypages/JavaBreakpointPage.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/propertypages/JavaBreakpointPage.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -333,7 +333,8 @@
 			fEditor = new ExceptionBreakpointEditor();
 		} else if (JavaWatchpoint.JAVA_WATCHPOINT.equals(type)) {
 			setTitle(PropertyPageMessages.JavaLineBreakpointPage_19);
-			fEditor = new WatchpointEditor();
+				fEditor = new CompositeBreakpointEditor(new AbstractJavaBreakpointEditor[] { new WatchpointEditor(),
+						new JavaBreakpointConditionEditor(null) });
 		} else if (JavaMethodBreakpoint.JAVA_METHOD_BREAKPOINT.equals(type)) {
 			setTitle(PropertyPageMessages.JavaLineBreakpointPage_20);
 			fEditor = new CompositeBreakpointEditor(new AbstractJavaBreakpointEditor[] 
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayAccess.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayAccess.java
index b27cb48..7e78e6b 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayAccess.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayAccess.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -62,7 +62,13 @@
 	 *             if not available
 	 */
 	protected IJavaArray popArray() throws CoreException {
-		IJavaValue value = popValue();
+		Object popValue = popValue();
+		if (! (popValue instanceof IJavaValue)) {
+			throw new CoreException(new Status(IStatus.ERROR,
+					JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK,
+					"Internal error: attempt to access non-java object", null)); //$NON-NLS-1$
+		}
+		IJavaValue value = (IJavaValue) popValue;
 		if (value instanceof IJavaArray) {
 			return (IJavaArray) value;
 		} else if (value.isNull()) {
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayInitializerInstruction.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayInitializerInstruction.java
index 95aff73..e812e51 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayInitializerInstruction.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ArrayInitializerInstruction.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -13,6 +13,7 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jdt.debug.core.IJavaArray;
 import org.eclipse.jdt.debug.core.IJavaArrayType;
+import org.eclipse.jdt.debug.core.IJavaValue;
 
 public class ArrayInitializerInstruction extends ArrayInstruction {
 
@@ -46,7 +47,10 @@
 		IJavaArray array = arrayType.newInstance(fLength);
 
 		for (int i = fLength - 1; i >= 0; i--) {
-			array.setValue(i, popValue());
+			Object popValue = popValue();
+			if (popValue instanceof IJavaValue) {
+				array.setValue(i, (IJavaValue) popValue);
+			}
 		}
 
 		push(array);
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/AssignmentOperator.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/AssignmentOperator.java
index 1a31a57..9b7f06e 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/AssignmentOperator.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/AssignmentOperator.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -31,7 +31,10 @@
 	 */
 	@Override
 	public void execute() throws CoreException {
-		IJavaValue value = popValue();
+		Object popValue = popValue();
+		if (!(popValue instanceof IJavaValue))
+			return;
+		IJavaValue value = (IJavaValue) popValue;
 		IJavaVariable variable = (IJavaVariable) pop();
 
 		if (value instanceof IJavaPrimitiveValue) {
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/BinaryOperator.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/BinaryOperator.java
index 1e70cee..70151a6 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/BinaryOperator.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/BinaryOperator.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -42,7 +42,10 @@
 	}
 
 	private void executeAssignment() throws CoreException {
-		IJavaValue value = popValue();
+		Object popValue = popValue();
+		if (!(popValue instanceof IJavaValue))
+			return;
+		IJavaValue value = (IJavaValue) popValue;
 		IJavaVariable variable = (IJavaVariable) pop();
 		IJavaValue variableValue = (IJavaValue) variable.getValue();
 
@@ -80,8 +83,11 @@
 	}
 
 	private void executeBinary() throws CoreException {
-		IJavaValue right = popValue();
-		IJavaValue left = popValue();
+		Object popValue = popValue();
+		if (!(popValue instanceof IJavaValue))
+			return;
+		IJavaValue right = (IJavaValue) popValue;
+		IJavaValue left = (IJavaValue) popValue();
 
 		switch (fResultTypeId) {
 		case T_String:
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Cast.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Cast.java
index c3193df..3007ad7 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Cast.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Cast.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -56,7 +56,10 @@
 	 */
 	@Override
 	public void execute() throws CoreException {
-		IJavaValue value = popValue();
+		Object popValue = popValue();
+		if (!(popValue instanceof IJavaValue))
+			return;
+		IJavaValue value = (IJavaValue) popValue;
 
 		if (value instanceof IJavaPrimitiveValue) {
 			IJavaPrimitiveValue primitiveValue = (IJavaPrimitiveValue) value;
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ConditionalJump.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ConditionalJump.java
index 5bca4ff..c28b839 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ConditionalJump.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/ConditionalJump.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -28,7 +28,10 @@
 	 */
 	@Override
 	public void execute() throws CoreException {
-		IJavaValue conditionValue = popValue();
+		Object popValue = popValue();
+		if (!(popValue instanceof IJavaValue))
+			return;
+		IJavaValue conditionValue = (IJavaValue) popValue;
 		IJavaPrimitiveValue condition = null;
 		if (conditionValue instanceof IJavaPrimitiveValue) {
 			condition = (IJavaPrimitiveValue) conditionValue;
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Constructor.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Constructor.java
index 92a07d3..72f4911 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Constructor.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Constructor.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -34,7 +34,10 @@
 		IJavaValue[] args = new IJavaValue[fArgCount];
 		// args are in reverse order
 		for (int i = fArgCount - 1; i >= 0; i--) {
-			args[i] = popValue();
+			Object popValue = popValue();
+			if (popValue instanceof IJavaValue) {
+				args[i] = (IJavaValue) popValue;
+			}
 		}
 		IJavaClassType clazz = (IJavaClassType) pop();
 		IJavaValue result = clazz.newInstance(fSignature, args, getContext()
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/InstanceOfOperator.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/InstanceOfOperator.java
index 4697334..f4f04b4 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/InstanceOfOperator.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/InstanceOfOperator.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -34,7 +34,10 @@
 	@Override
 	public void execute() throws CoreException {
 		IJavaType type = (IJavaType) pop();
-		IJavaValue value = popValue();
+		Object popValue = popValue();
+		if (!(popValue instanceof IJavaValue))
+			return;
+		IJavaValue value = (IJavaValue) popValue;
 		if (value instanceof JDINullValue) {
 			pushNewValue(false);
 			return;
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Instruction.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Instruction.java
index 3b48d11..9a9011c 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Instruction.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/Instruction.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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,12 +105,12 @@
 		return fInterpreter.pop();
 	}
 
-	protected IJavaValue popValue() throws CoreException {
+	protected Object popValue() throws CoreException {
 		Object element = fInterpreter.pop();
 		if (element instanceof IJavaVariable) {
-			return (IJavaValue) ((IJavaVariable) element).getValue();
+			return ((IJavaVariable) element).getValue();
 		}
-		return (IJavaValue) element;
+		return  element;
 	}
 
 	protected void pushNewValue(boolean value) {
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/LocalVariableCreation.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/LocalVariableCreation.java
index 04249e1..14fc9a5 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/LocalVariableCreation.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/LocalVariableCreation.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -103,7 +103,9 @@
 		}
 		IVariable var = createInternalVariable(fName, type);
 		if (fHasInitializer) {
-			var.setValue(popValue());
+			Object value = popValue();
+			if (value instanceof String)
+				var.setValue((String) value);
 		}
 	}
 
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/PushFieldVariable.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/PushFieldVariable.java
index 2053618..ea7764f 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/PushFieldVariable.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/PushFieldVariable.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -17,6 +17,7 @@
 import org.eclipse.jdt.debug.core.IJavaObject;
 import org.eclipse.jdt.debug.core.IJavaVariable;
 import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin;
+import org.eclipse.jdt.internal.debug.core.model.JDIClassType;
 import org.eclipse.jdt.internal.debug.core.model.JDINullValue;
 import org.eclipse.jdt.internal.debug.core.model.JDIObjectValue;
 import org.eclipse.jdt.internal.debug.eval.ast.engine.IRuntimeContext;
@@ -55,15 +56,17 @@
 					JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK,
 					InstructionsEvaluationMessages.PushFieldVariable_0, null));
 		}
-		IJavaObject receiver = (IJavaObject) value;
-
 		IJavaVariable field = null;
-
-		if (fDeclaringTypeSignature == null) {
-			field = ((JDIObjectValue) receiver).getField(fName,
-					fSuperClassLevel);
-		} else {
-			field = receiver.getField(fName, fDeclaringTypeSignature);
+		if (value instanceof JDIClassType ) {
+			field = ((JDIClassType) value).getField(fName);
+		} else if (value instanceof IJavaObject){
+			IJavaObject receiver = (IJavaObject) value;
+			if (fDeclaringTypeSignature == null) {
+				field = ((JDIObjectValue) receiver).getField(fName,
+						fSuperClassLevel);
+			} else {
+				field = receiver.getField(fName, fDeclaringTypeSignature);
+			}
 		}
 
 		if (field == null) {
@@ -88,7 +91,7 @@
 							IStatus.OK,
 							NLS.bind(InstructionsEvaluationMessages.PushFieldVariable_Cannot_find_the_field__0__for_the_object__1__1,
 											new String[] { fName,
-													receiver.toString() }),
+													value.toString() }),
 							null)); //
 		}
 		push(field);
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendMessage.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendMessage.java
index 02811f9..cbcd065 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendMessage.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendMessage.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -44,7 +44,9 @@
 		IJavaValue[] args = new IJavaValue[fArgCount];
 		// args are in reverse order
 		for (int i = fArgCount - 1; i >= 0; i--) {
-			args[i] = popValue();
+			Object popValue = popValue();
+			if ((popValue instanceof IJavaValue))
+				args[i] = (IJavaValue) popValue;
 		}
 		Object receiver = pop();
 		IJavaValue result = null;
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendStaticMessage.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendStaticMessage.java
index 75925f7..a26c735 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendStaticMessage.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/instructions/SendStaticMessage.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -46,7 +46,9 @@
 		IJavaValue[] args = new IJavaValue[fArgCount];
 		// args are in reverse order
 		for (int i = fArgCount - 1; i >= 0; i--) {
-			args[i] = popValue();
+			Object popValue = popValue();
+			if ((popValue instanceof IJavaValue))
+				args[i] = (IJavaValue) popValue;
 		}
 
 		IJavaType receiver = getType(fTypeName);
diff --git a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/breakpoints/JavaWatchpoint.java b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/breakpoints/JavaWatchpoint.java
index f30dc80..56bc2bd 100644
--- a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/breakpoints/JavaWatchpoint.java
+++ b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/breakpoints/JavaWatchpoint.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -529,7 +529,7 @@
 	 */
 	@Override
 	public boolean supportsCondition() {
-		return false;
+		return true;
 	}
 
 	/**