Bug 235775

Summary: [eval] Code snippet evaluation doesn't work for constructor invocation with type arguments
Product: [Eclipse Project] JDT Reporter: David Audel <david_audel>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: 3.4   
Target Milestone: 3.6 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
DebugEvaluationTest.test065() none

Description David Audel CLA 2008-06-05 04:56:19 EDT
build I20080603-2000

1) add the following method in DebugEvaluationTest.java

public void test065() {
	if (this.complianceLevel < ClassFileConstants.JDK1_5) return;
	try {
		String sourceA65 =
			"public class A65<T> {\n"
				+ "\tprivate int i;\n"
				+ "\tpublic <U>A65() {;\n"
				+ "\t}\n"
				+ "\tprivate <U>A65(int i) {;\n"
				+ "\t\tthis.i = i;\n"
				+ "\t}\n"               
				+ "\tpublic void bar() {\n"
				+ "\t}\n"
				+ "}";
		compileAndDeploy15(sourceA65, "A65");

		String userCode = "new <Object>A65<Object>().bar();";
		JDIStackFrame stackFrame =
			new JDIStackFrame(this.jdiVM, this, userCode, "A65", "bar", -1);

		DebugRequestor requestor = new DebugRequestor();
		char[] snippet = "return new <Object>A65<Object>(3).i;".toCharArray();
		try {
			context.evaluate(
				snippet,
				stackFrame.localVariableTypeNames(),
				stackFrame.localVariableNames(),
				stackFrame.localVariableModifiers(),
				stackFrame.declaringTypeName(),
				stackFrame.isStatic(),
				stackFrame.isConstructorCall(),
				getEnv(),
				getCompilerOptions(),
				requestor,
				getProblemFactory());
		} catch (InstallException e) {
			assertTrue("No targetException " + e.getMessage(), false);
		}
		assertTrue(
			"Should get one result but got " + (requestor.resultIndex + 1),
			requestor.resultIndex == 0);
		EvaluationResult result = requestor.results[0];
		assertTrue("Code snippet should not have problems", !result.hasProblems());
		assertTrue("Result should have a value", result.hasValue());
		assertEquals("Value", "3".toCharArray(), result.getValueDisplayString());
		assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
	} finally {
		removeTempClass("A65");
	}
}

2) run this junit test
The test fails

If '<Object>' is removed from the snippet the test does not fail.
Comment 1 David Audel CLA 2008-06-05 04:56:47 EDT
Created attachment 103709 [details]
DebugEvaluationTest.test065()
Comment 2 Olivier Thomann CLA 2009-12-15 10:57:21 EST
Closing as a duplicate of bug 235783.
235783 is a more generic bug that covers this case.

*** This bug has been marked as a duplicate of bug 235783 ***