Bug 427077 - [1.8] Unable to evaluate expressions in the context of an
interface

Change-Id: I31c558a720802827a815ed145a3d2233e16b9558
Signed-off-by: Sarika Sinha <sarika.sinha@in.ibm.com>
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java
index 22e170b..fa27a22 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java
@@ -449,6 +449,7 @@
 	        if (!loaded18) {
 	        	jp = createProject(ONE_EIGHT_PROJECT_NAME, JavaProjectHelper.TEST_1_8_SRC_DIR.toString(), JavaProjectHelper.JAVA_SE_1_8_EE_NAME, false);
 	    		cfgs.add(createLaunchConfiguration(jp, "EvalTest18"));
+	    		cfgs.add(createLaunchConfiguration(jp, "EvalTestIntf18"));
 	    		loaded18 = true;
 	    		waitForBuild();
 	        }
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/Java8Tests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/Java8Tests.java
index 3fd1042..89fa901 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/Java8Tests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/Java8Tests.java
@@ -16,6 +16,7 @@
 package org.eclipse.jdt.debug.tests.eval;
 
 import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
 import org.eclipse.jdt.debug.core.IJavaThread;
 import org.eclipse.jdt.debug.tests.AbstractDebugTest;
 
@@ -60,5 +61,28 @@
 		}
 	}
 	
+	/**
+	 * Evaluates a snippet in the context of  interface method
+	 * generic statement
+	 * 
+	 * @throws Exception
+	 */
+	public void testEvalInterfaceMethod() throws Exception {
+		IJavaThread thread = null;
+		try {
+			String type = "EvalTestIntf18";
+			IJavaLineBreakpoint bp = createLineBreakpoint(23, "", "EvalTestIntf18.java", "Intf18");
+			assertNotNull("should have created breakpoint", bp);
+			thread = launchToBreakpoint(type);
+			assertNotNull("The program did not suspend", thread);
+			String snippet = "a + 2";
+			doEval(thread, snippet);
+		}
+		finally {
+			removeAllBreakpoints();
+			terminateAndRemove(thread);
+		}
+	}
+	
 
 }
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTEvaluationEngine.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTEvaluationEngine.java
index f35e2da..c67ed9e 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTEvaluationEngine.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTEvaluationEngine.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 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
@@ -39,7 +39,6 @@
 import org.eclipse.jdt.debug.core.IJavaArray;
 import org.eclipse.jdt.debug.core.IJavaArrayType;
 import org.eclipse.jdt.debug.core.IJavaDebugTarget;
-import org.eclipse.jdt.debug.core.IJavaInterfaceType;
 import org.eclipse.jdt.debug.core.IJavaObject;
 import org.eclipse.jdt.debug.core.IJavaReferenceType;
 import org.eclipse.jdt.debug.core.IJavaStackFrame;
@@ -47,7 +46,6 @@
 import org.eclipse.jdt.debug.core.IJavaType;
 import org.eclipse.jdt.debug.core.IJavaValue;
 import org.eclipse.jdt.debug.core.IJavaVariable;
-import org.eclipse.jdt.debug.core.JDIDebugModel;
 import org.eclipse.jdt.debug.eval.IAstEvaluationEngine;
 import org.eclipse.jdt.debug.eval.ICompiledExpression;
 import org.eclipse.jdt.debug.eval.IEvaluationListener;
@@ -130,7 +128,6 @@
 			IEvaluationListener listener, int evaluationDetail,
 			boolean hitBreakpoints) throws DebugException {
 		traceCaller(snippet, frame.getThread());
-		checkInterface(frame);
 		ICompiledExpression expression = getCompiledExpression(snippet, frame);
 		evaluateExpression(expression, frame, listener, evaluationDetail,
 				hitBreakpoints);
@@ -182,24 +179,6 @@
 		}
 	}
 
-	/**
-	 * Checks if the stack frame is declared in an interface an aborts if so.
-	 * 
-	 * @param frame
-	 *            stack frame
-	 * @throws DebugException
-	 *             if declaring type is an interface
-	 */
-	private void checkInterface(IJavaStackFrame frame) throws DebugException {
-		if (frame.getReferenceType() instanceof IJavaInterfaceType) {
-			IStatus status = new Status(IStatus.ERROR,
-					JDIDebugModel.getPluginIdentifier(),
-					DebugException.REQUEST_FAILED,
-					EvaluationEngineMessages.ASTEvaluationEngine_0, null);
-			throw new DebugException(status);
-		}
-	}
-
 	/*
 	 * (non-Javadoc)
 	 * 
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.java
index ca6fc97..43a9423 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 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
@@ -61,7 +61,6 @@
 		NLS.initializeMessages(BUNDLE_NAME, EvaluationEngineMessages.class);
 	}
 
-	public static String ASTEvaluationEngine_0;
 	public static String ASTEvaluationEngine_1;
 	public static String ArrayRuntimeContext_0;
 }
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.properties b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.properties
index e3cfb4b..d406204 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.properties
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationEngineMessages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2000, 2013 IBM Corporation and others.
+# Copyright (c) 2000, 2014 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
@@ -49,6 +49,5 @@
 ASTInstructionCompiler_2=Unable to resolve type binding of declaring type of: {0}
 ASTInstructionCompiler_4=The ASTInstruction compiler failed to store instruction at counter: {0}
 ASTInstructionCompiler_5=Unable to resolve binding for: {0}
-ASTEvaluationEngine_0=Unable to evaluate expressions in the context of an interface
 ASTEvaluationEngine_1=Unable to retrieve type for java.lang.Object
 ArrayRuntimeContext_0=Unable to retrieve type for java.lang.Object