Bug 235775 - [eval] Code snippet evaluation doesn't work for constructor invocation with type arguments
Summary: [eval] Code snippet evaluation doesn't work for constructor invocation with t...
Status: CLOSED DUPLICATE of bug 235783
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-05 04:56 EDT by David Audel CLA
Modified: 2009-12-15 10:57 EST (History)
1 user (show)

See Also:


Attachments
DebugEvaluationTest.test065() (2.39 KB, patch)
2008-06-05 04:56 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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 ***