| Summary: | Lambda evaluations test fails in Java8Tests test class | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Gayan Perera <gayanper> |
| Component: | Debug | Assignee: | Gayan Perera <gayanper> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | loskutov, manoj.palat, sarika.sinha, Vikas.Chandra |
| Version: | 4.19 | ||
| Target Milestone: | 4.21 M1 | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| See Also: |
https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/176748 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=63e0f757b2acc1528310b44b3463bd2bd4858310 https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/182821 https://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=4cb87a554926ffffff65f4d6c9e38453c31f6777 |
||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 574681 | ||
|
Description
Gayan Perera
The problem seems to be related to how the code is generated at org.eclipse.jdt.internal.eval.CodeSnippetMessageSend.generateCode(BlockScope, CodeStream, boolean) The root cause is for this.publicMethod() it delegate the code generation to receiver which fails with synthetics lookup. @Sarika what is the meaning of IsCapturedOuterLocal and DepthMASK ? @Sarika and @Aundrey i need some help on the following test in CodeSnippetTest
public void testBug571310_ThisReciever() {
if (this.complianceLevel < ClassFileConstants.JDK1_8) {
return;
}
this.context.setImports(new char[][] {"java.util.function.*".toCharArray()});
evaluateWithExpectedDisplayString(buildCharArray(new String[] {
"class Outer {",
" public int outerFoo() {",
" return 10;",
" }",
" public int boo() {",
" Function<Integer,Integer> f = i -> this.outerFoo() + i;",
" return f.apply(5);",
" }",
"};",
"(new Outer()).outerFoo();"}),
"15".toCharArray());
}
The strange thing is when i write this code as a scrapbook page and it runs fine. The problem seems to be related with the lambda in the test. When i remove the lambda line it work.
(In reply to Gayan Perera from comment #2) > @Sarika what is the meaning of IsCapturedOuterLocal and DepthMASK ? I don't have exact answer to this. @Manoj, Will you be able to help with this and CodeSnippetTest? @Sarika @Manoj after 2 days of vigorous debugging i found the problem. may be i spend to much time digging into compiler code, but it was fun :). The problem is that when we have lambdas, the resulting inner class has some changes compared to a normal inner class. This cause the index issue in org.eclipse.jdt.core.tests.eval.target.CodeSnippetRunner classname resolution. This is not a issue in LocalEvaluationEngine because it actually gets the class file names from caller. So for tests either we can fix the org.eclipse.jdt.core.tests.eval.target.CodeSnippetRunner class name resolution when synthetic methods are added. But i'm not sure if its only when synthetic methods or if the problem is with all kind of synthetic attributes. Another solution is we pass in the class names from the tests into this remote evaluator so that don't need to play around with class bytes. I feel that second option is better since we don't need to keep on updating this when ever the class format changes. WDYT ? Sorry, Forgot to add Manoj :)
>>Another solution is we pass in the class names from the tests into this remote >>evaluator so that don't need to play around with class bytes.
For tests, this should be fine.
(In reply to Sarika Sinha from comment #6) > Sorry, Forgot to add Manoj :) > Thanks @Sarika! > >>Another solution is we pass in the class names from the tests into this remote >>evaluator so that don't need to play around with class bytes. > > For tests, this should be fine. @Gayan: I need to candidly admit that I am not familiar with the eval part of the code and hence cannot provide you with an answer that has some value at this point in time. However, if the issue is not yet resolved until after Java 16, I will try to spend some time on this. @Manoj sure i will create a patch and add you as an reviewer. I found this snippet test problem when i try to fix and run tests the original bug this issue is reported for. So until we get codesnippet tests running its hard to give a proper fix for snippet compiler. @Manoj i fix the code runner, i feel that adding class names was kind of a bigger change. So i added the remaining constant pool constants into the code. Now the CodeSnippetRunner should be capable of reading class file name up to java 15. Now i will focus in fixing the regression issue i found and lets see if it will be good to include in this release if i can finish it soon. New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/176748 Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/176748 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=63e0f757b2acc1528310b44b3463bd2bd4858310 @Gayan, Please mark the bug as resolved after releasing the changes. @Gayan, Can we add a Debug test case for the fixed case : assertFunctionalExpression(obj -> this.publicMethod() + 8, this, 13) Sure @Sarika, is it ok i add it tomorrow as a different gerrit ? (In reply to Gayan Perera from comment #15) > Sure @Sarika, is it ok i add it tomorrow as a different gerrit ? Yes, perfect. New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/182821 Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/182821 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=4cb87a554926ffffff65f4d6c9e38453c31f6777 |