Bug 341232 - Eclipse is not able to set the simplest of conditional
breakpoints...add more tests
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java
index 1c336f5..122b0a9 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AutomatedSuite.java
@@ -22,7 +22,7 @@
 import org.eclipse.jdt.debug.tests.breakpoints.BreakpointListenerTests;
 import org.eclipse.jdt.debug.tests.breakpoints.BreakpointLocationVerificationTests;
 import org.eclipse.jdt.debug.tests.breakpoints.BreakpointWorkingSetTests;
-import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpoints15Tests;
+import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsWithGenerics;
 import org.eclipse.jdt.debug.tests.breakpoints.ConditionalBreakpointsTests;
 import org.eclipse.jdt.debug.tests.breakpoints.DeferredBreakpointTests;
 import org.eclipse.jdt.debug.tests.breakpoints.ExceptionBreakpointTests;
@@ -183,7 +183,7 @@
 			addTest(new TestSuite(MethodBreakpointTests15.class));
 			addTest(new TestSuite(TestIntegerAccessUnboxing15.class));
 			addTest(new TestSuite(StepIntoSelectionWithGenerics.class));
-			addTest(new TestSuite(ConditionalBreakpoints15Tests.class));
+			addTest(new TestSuite(ConditionalBreakpointsWithGenerics.class));
 		}
 		
 	//Sourcelookup tests
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/breakpoints/ConditionalBreakpoints15Tests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/breakpoints/ConditionalBreakpoints15Tests.java
deleted file mode 100644
index af41b34..0000000
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/breakpoints/ConditionalBreakpoints15Tests.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Jesper Steen Moller 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
- * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors:
- *     Jesper Steen Moller - initial API and implementation, adapted from
- *     Stefan Mandels contribution in bug 341232, and existing debug tests
- *******************************************************************************/
-package org.eclipse.jdt.debug.tests.breakpoints;
-
-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;
-
-/**
- * Tests conditional breakpoints.
- */
-public class ConditionalBreakpoints15Tests extends AbstractDebugTest {
-	
-	/**
-	 * Constructor
-	 * @param name
-	 */
-	public ConditionalBreakpoints15Tests(String name) {
-		super(name);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.jdt.debug.tests.AbstractDebugTest#getProjectContext()
-	 */
-	@Override
-	protected IJavaProject getProjectContext() {
-		return get15Project();
-	}
-
-	/**
-	 * Tests a breakpoint with a simple condition
-	 * @throws Exception
-	 */
-	public void testSimpleConditionalBreakpointOnParameterizedType() throws Exception {
-		String typeName = "a.b.c.ConditionalsNearGenerics";
-		String innerTypeName = "a.b.c.ConditionalsNearGenerics.ItemIterator";
-		IJavaLineBreakpoint bp1 = createConditionalLineBreakpoint(33, typeName, "false", true);
-		IJavaLineBreakpoint bp2 = createConditionalLineBreakpoint(39, typeName, "false", true);
-		IJavaLineBreakpoint bp3 = createConditionalLineBreakpoint(52, innerTypeName, "false", true);
-		IJavaLineBreakpoint bp4 = createConditionalLineBreakpoint(53, innerTypeName, "true", true);
-		
-		IJavaThread thread= null;
-		try {
-			thread= launchToLineBreakpoint(typeName, bp4); // If compiled correctly, this will jump over bp1-bp3 !!
-
-			bp1.delete();
-			bp2.delete();
-			bp3.delete();
-			bp4.delete();
-		} finally {
-			terminateAndRemove(thread);
-			removeAllBreakpoints();
-		}		
-	}
-	
-	}
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/breakpoints/ConditionalBreakpointsWithGenerics.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/breakpoints/ConditionalBreakpointsWithGenerics.java
new file mode 100644
index 0000000..0ce22eb
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/breakpoints/ConditionalBreakpointsWithGenerics.java
@@ -0,0 +1,245 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Jesper Steen Moller 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     Jesper Steen Moller - initial API and implementation, adapted from
+ *     Stefan Mandels contribution in bug 341232, and existing debug tests
+ *     IBM Corporation - addition test for bug 341232
+ *******************************************************************************/
+package org.eclipse.jdt.debug.tests.breakpoints;
+
+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;
+
+/**
+ * Tests conditional breakpoints.
+ */
+public class ConditionalBreakpointsWithGenerics extends AbstractDebugTest {
+	
+	/**
+	 * Constructor
+	 * @param name
+	 */
+	public ConditionalBreakpointsWithGenerics(String name) {
+		super(name);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jdt.debug.tests.AbstractDebugTest#getProjectContext()
+	 */
+	@Override
+	protected IJavaProject getProjectContext() {
+		return get15Project();
+	}
+
+	/**
+	 * Tests a breakpoint with a simple condition does not cause errors
+	 * multiple use of the same generic type 'T'
+	 * 
+	 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=341232
+	 * @throws Exception
+	 */
+	public void testDuplicateGenericTypes() throws Exception {
+		String typeName = "a.b.c.ConditionalsNearGenerics";
+		String innerTypeName = "a.b.c.ConditionalsNearGenerics.ItemIterator";
+		IJavaLineBreakpoint bp1 = createConditionalLineBreakpoint(33, typeName, "false", true);
+		IJavaLineBreakpoint bp2 = createConditionalLineBreakpoint(39, typeName, "false", true);
+		IJavaLineBreakpoint bp3 = createConditionalLineBreakpoint(52, innerTypeName, "false", true);
+		IJavaLineBreakpoint bp4 = createConditionalLineBreakpoint(53, innerTypeName, "true", true);
+		
+		IJavaThread thread= null;
+		try {
+			thread= launchToLineBreakpoint(typeName, bp4); // If compiled correctly, this will jump over bp1-bp3 !!
+
+			bp1.delete();
+			bp2.delete();
+			bp3.delete();
+			bp4.delete();
+		} finally {
+			terminateAndRemove(thread);
+			removeAllBreakpoints();
+		}		
+	}
+	
+	/**
+	 * Tests a breakpoint with a simple condition does not cause errors
+	 * with many inner types with generics
+	 * 
+	 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=341232
+	 * @throws Exception
+	 */
+	public void testNestedTypes1() throws Exception {
+		String type = "a.b.c.StepIntoSelectionWithGenerics";
+		IJavaThread thread = null;
+		try {
+			createConditionalLineBreakpoint(32, type, "true", true);
+			thread = launchToBreakpoint(type);
+			assertNotNull("Breakpoint not hit within timeout period", thread);
+		}
+		finally {
+			terminateAndRemove(thread);
+			removeAllBreakpoints();
+		}
+	}
+	
+	/**
+	 * Tests a breakpoint with a simple condition does not cause errors
+	 * with many inner types with generics
+	 * 
+	 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=341232
+	 * @throws Exception
+	 */
+	public void testNestedTypes2() throws Exception {
+		String type = "a.b.c.StepIntoSelectionWithGenerics";
+		IJavaThread thread = null;
+		try {
+			createConditionalLineBreakpoint(21, type, "true", true);
+			thread = launchToBreakpoint(type);
+			assertNotNull("Breakpoint not hit within timeout period", thread);
+		}
+		finally {
+			terminateAndRemove(thread);
+			removeAllBreakpoints();
+		}
+	}
+	
+	/**
+	 * Tests a breakpoint with a simple condition does not cause errors
+	 * with many inner types with generics
+	 * 
+	 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=341232
+	 * @throws Exception
+	 */
+	public void testNestedTypes3() throws Exception {
+		String type = "a.b.c.StepIntoSelectionWithGenerics";
+		IJavaThread thread = null;
+		try {
+			createConditionalLineBreakpoint(17, type, "true", true);
+			thread = launchToBreakpoint(type);
+			assertNotNull("Breakpoint not hit within timeout period", thread);
+		}
+		finally {
+			terminateAndRemove(thread);
+			removeAllBreakpoints();
+		}
+	}
+	
+	/**
+	 * Tests a breakpoint with a simple condition does not cause errors
+	 * with multiple generic types 'T', 'E', 'K'
+	 * 
+	 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=341232
+	 * @throws Exception
+	 */
+	public void testMultipleGenericTypes1() throws Exception {
+		String type = "a.b.c.MethodBreakpoints";
+		IJavaThread thread = null;
+		try {
+			createConditionalLineBreakpoint(26, type, "true", true);
+			thread = launchToBreakpoint(type);
+			assertNotNull("Breakpoint not hit within timeout period", thread);
+		}
+		finally {
+			terminateAndRemove(thread);
+			removeAllBreakpoints();
+		}
+	}
+	
+	/**
+	 * Tests a breakpoint with a simple condition does not cause errors
+	 * with multiple generic types 'T', 'E', 'K'
+	 * 
+	 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=341232
+	 * @throws Exception
+	 */
+	public void testMultipleGenericTypes2() throws Exception {
+		String type = "a.b.c.MethodBreakpoints";
+		IJavaThread thread = null;
+		try {
+			createConditionalLineBreakpoint(31, type, "true", true);
+			thread = launchToBreakpoint(type);
+			assertNotNull("Breakpoint not hit within timeout period", thread);
+		}
+		finally {
+			terminateAndRemove(thread);
+			removeAllBreakpoints();
+		}
+	}
+	
+	/**
+	 * Tests a breakpoint with a condition that includes generics
+	 * 
+	 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=341232
+	 * @throws Exception
+	 */
+	public void testBreakpointWithGenericsCondition1() throws Exception {
+		String type = "a.b.c.MethodBreakpoints";
+		IJavaThread thread = null;
+		try {
+			String condition = "MethodBreakpoints<Integer> breakpoints = new MethodBreakpoints<Integer>();\n"
+						+ "breakpoints.typeParameter(10);\n"
+						+ "return true;";
+			createConditionalLineBreakpoint(31, type, condition, true);
+			thread = launchToBreakpoint(type);
+			assertNotNull("Breakpoint not hit within timeout period", thread);
+		}
+		finally {
+			terminateAndRemove(thread);
+			removeAllBreakpoints();
+		}
+	}
+	
+	/**
+	 * Tests a breakpoint with a generified condition in a type that includes
+	 * duplicate generic declarations
+	 * 
+	 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=341232
+	 * @throws Exception
+	 */
+	public void testBreakpointWithGenericCondition2() throws Exception {
+		String type = "a.b.c.ConditionalsNearGenerics";
+		IJavaThread thread = null;
+		try {
+			String condition = "Iterator<Integer> i = tokenize(Arrays.asList(1, 2, 3), \"condition\");\n"+
+								"return i.hasNext();";
+			createConditionalLineBreakpoint(34, type, condition, true);
+			thread = launchToBreakpoint(type);
+			assertNotNull("Breakpoint not hit within timeout period", thread);
+		}
+		finally {
+			terminateAndRemove(thread);
+			removeAllBreakpoints();
+		}
+	}
+	
+	/**
+	 * Tests a breakpoint with a condition that includes generics from nested classes
+	 * 
+	 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=341232
+	 * @throws Exception
+	 */
+	public void testBreakpointWithGenericCondition3() throws Exception {
+		String type = "a.b.c.StepIntoSelectionWithGenerics";
+		IJavaThread thread = null;
+		try {
+			String condition = "StepIntoSelectionWithGenerics<String> ssswg = new StepIntoSelectionWithGenerics<String>();\n"
+					+ "InnerCLazz<Integer> ic = new InnerClazz<Integer>();\n"
+					+ "InnerClazz2<Double> ic2 = new InnerClazz2<Double>();\n"
+					+ "ic2.hello();\n"
+					+ "return true;";
+			createConditionalLineBreakpoint(32, type, condition, true);
+			thread = launchToBreakpoint(type);
+			assertNotNull("Breakpoint not hit within timeout period", thread);
+		}
+		finally {
+			terminateAndRemove(thread);
+			removeAllBreakpoints();
+		}
+	}
+}
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/SnippetsWithGenericsEvalTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/SnippetsWithGenericsEvalTests.java
new file mode 100644
index 0000000..87a2bc0
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/SnippetsWithGenericsEvalTests.java
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) Mar 1, 2013 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.debug.tests.eval;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.tests.AbstractDebugTest;
+
+/**
+ * Group of tests that evaluate operations involving generics
+ * 
+ * @since 3.8
+ */
+public class SnippetsWithGenericsEvalTests extends AbstractDebugTest {
+
+	/**
+	 * @param name
+	 */
+	public SnippetsWithGenericsEvalTests(String name) {
+		super(name);
+	}
+
+	@Override
+	protected IJavaProject getProjectContext() {
+		return get15Project();
+	}
+	
+	/**
+	 * Evaluates a generified snippet with a simple single 
+	 * generic statement
+	 * 
+	 * @throws Exception
+	 */
+	public void testEvalGenerics1() throws Exception {
+		IJavaThread thread = null;
+		try {
+			String type = "a.b.c.MethodBreakpoints";
+			createLineBreakpoint(31, type);
+			thread = launchToBreakpoint(type);
+			assertNotNull("The program did not suspend", thread);
+			String snippet = "methodTypeParameter(1);";
+			doEval(thread, snippet);
+		}
+		finally {
+			removeAllBreakpoints();
+			terminateAndRemove(thread);
+		}
+	}
+	
+	/**
+	 * Evaluates a generified snippet with a simple single 
+	 * generic statement
+	 * 
+	 * @throws Exception
+	 */
+	public void testEvalGenerics2() throws Exception {
+		IJavaThread thread = null;
+		try {
+			String type = "a.b.c.MethodBreakpoints";
+			createLineBreakpoint(31, type);
+			thread = launchToBreakpoint(type);
+			assertNotNull("The program did not suspend", thread);
+			String snippet = "new MethodBreakpoints<String>().typeParameter(\"test\")";
+			doEval(thread, snippet);
+		}
+		finally {
+			removeAllBreakpoints();
+			terminateAndRemove(thread);
+		}
+	}
+	
+	/**
+	 * Evaluates a generified snippet with a simple single 
+	 * generic statement
+	 * 
+	 * @throws Exception
+	 */
+	public void testEvalGenerics3() throws Exception {
+		IJavaThread thread = null;
+		try {
+			String type = "a.b.c.MethodBreakpoints";
+			createLineBreakpoint(31, type);
+			thread = launchToBreakpoint(type);
+			assertNotNull("The program did not suspend", thread);
+			String snippet = "MethodBreakpoints.staticTypeParameter(new ArrayList<Long>())";
+			doEval(thread, snippet);
+		}
+		finally {
+			removeAllBreakpoints();
+			terminateAndRemove(thread);
+		}
+	}
+	
+	public void testEvalGenerics4() throws Exception {
+		IJavaThread thread = null;
+		try {
+			String type = "a.b.c.StepIntoSelectionWithGenerics";
+			createLineBreakpoint(21, type);
+			thread = launchToBreakpoint(type);
+			assertNotNull("The program did not suspend", thread);
+			String snippet = "new java.util.ArrayList<String>().isEmpty()";
+			doEval(thread, snippet);
+		}
+		finally {
+			removeAllBreakpoints();
+			terminateAndRemove(thread);
+		}
+	}
+	
+	public void testEvalGenerics5() throws Exception {
+		IJavaThread thread = null;
+		try {
+			String type = "a.b.c.StepIntoSelectionWithGenerics";
+			createLineBreakpoint(17, type);
+			thread = launchToBreakpoint(type);
+			assertNotNull("The program did not suspend", thread);
+			String snippet = "new java.util.ArrayList<String>().isEmpty()";
+			doEval(thread, snippet);
+		}
+		finally {
+			removeAllBreakpoints();
+			terminateAndRemove(thread);
+		}
+	}
+	
+	public void testEvalGenerics6() throws Exception {
+		IJavaThread thread = null;
+		try {
+			String type = "a.b.c.StepIntoSelectionWithGenerics";
+			createLineBreakpoint(32, type);
+			thread = launchToBreakpoint(type);
+			assertNotNull("The program did not suspend", thread);
+			String snippet = "new StepIntoSelectionWithGenerics<String>().hello()";
+			doEval(thread, snippet);
+		}
+		finally {
+			removeAllBreakpoints();
+			terminateAndRemove(thread);
+		}
+	}
+	
+	public void testEvalGenerics7() throws Exception {
+		IJavaThread thread = null;
+		try {
+			String type = "a.b.c.StepIntoSelectionWithGenerics";
+			createLineBreakpoint(32, type);
+			thread = launchToBreakpoint(type);
+			assertNotNull("The program did not suspend", thread);
+			String snippet = "new StepIntoSelectionWithGenerics<String>().new InnerClazz<Integer>().hello()";
+			doEval(thread, snippet);
+		}
+		finally {
+			removeAllBreakpoints();
+			terminateAndRemove(thread);
+		}
+	}
+	
+	public void testEvalGenerics8() throws Exception {
+		IJavaThread thread = null;
+		try {
+			String type = "a.b.c.StepIntoSelectionWithGenerics";
+			createLineBreakpoint(32, type);
+			thread = launchToBreakpoint(type);
+			assertNotNull("The program did not suspend", thread);
+			String snippet = "new StepIntoSelectionWithGenerics<String>().new InnerClazz<Integer>().new InnerClazz2<Double>().hello()";
+			doEval(thread, snippet);
+		}
+		finally {
+			removeAllBreakpoints();
+			terminateAndRemove(thread);
+		}
+	}
+}
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTInstructionCompiler.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTInstructionCompiler.java
index 40c8edd..e155928 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTInstructionCompiler.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTInstructionCompiler.java
@@ -339,16 +339,12 @@
 			}
 			return name.toString();
 		}
-		String typeName = typeBinding.getName();
-		int parameters = typeName.indexOf('<');
-		if (parameters >= 0) {
-			typeName = typeName.substring(0, parameters);
-		}
-		name = new StringBuffer(typeName);
+		//try it the old way
+		name = new StringBuffer(Signature.getTypeErasure(typeBinding.getName()));
 		IPackageBinding packageBinding = typeBinding.getPackage();
 		typeBinding = typeBinding.getDeclaringClass();
 		while (typeBinding != null) {
-			name.insert(0, '$').insert(0, typeBinding.getName());
+			name.insert(0, '$').insert(0, Signature.getTypeErasure(typeBinding.getName()));
 			typeBinding = typeBinding.getDeclaringClass();
 		}
 		if (packageBinding != null && !packageBinding.isUnnamed()) {