Community
Participate
Working Groups
Created attachment 287375 [details] example project When evaluating a conditional breakpoint that involves an object that itself uses recursive generics, eclipse cannot evaluate the breakpoint and reports that the condition has compilation errors. Here is an example code (a project is attached): public class Main { public static void main(String[] args) { MyClass<?> cls = new MyClass<>(); System.out.println("x"); // add conditional breakpoint here (e.g. "cls.getBoolean()") } private static class MyClass<T extends MyClass<T>> { public boolean getBoolean() { return false; } } } Notice the recursive generic parameter of class MyClass. A conditional breakpoint like the one stated in the comment fails during debugging with the following error message: "Conditional breakpoint has compilation error(s). Reason: Evaluations must contain either an expression or a block of well-formed statements" The error log further contains the following warning: "Compile error during code evaluation: Bound mismatch: The type Object is not a valid substitute for the bounded parameter <T extends Main.MyClass<T>> of the type Main.MyClass<T>" No stack trace is available. Conditional breakpoints worked in situations like above at least until eclipse 4.15.
Thanks Katrin for reporting. @Gayan, Can you look at this as this looks like a regression from the fix of Bug 572782.
Sure i can have a look for M3. Is that ok ?
(In reply to Gayan Perera from comment #2) > Sure i can have a look for M3. Is that ok ? Yes! Thanks.
Its not really same as previous bug, not sure if it was cause by that given the changes, the problem seems to be the parameters on the eval method doesn't carry the correct generic signature. The variable type in CU is MyClass<?>, but the variable type extracted from the Debug Frame is MyClass<Object>. I have a solution to replace the correct this variable types while traversing the CU on snippet source generator. I need to test more for different scenarios where we could find shadowing variables and how that will effect the logic. Will try to push the patch by end of this week.
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/187132
Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/187132 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=39150a4dc8af145c12f350efbcca07eb6a391d51
Thanks Gayan for quickly fixing this.
Does the solution work for more than one type parameter? static class MyClass<C1 extends MyClass<C1, C2>, C2 extends MyClass<C1, C2>> {} MyClass<?, ?> cls = new MyClass<>(); Or with doubly-nested recursive type args class MyClass<C extends MyClass<? extends MyClass<C>>> {}
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/187240
Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/187240 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=69fbe862f7587afdffe0bca9204ccb1fbc1b5f8b
I20211109-1800