Question

I am having a difficulty while attempting to debug some code in grails. It is difficult to put into text, so I have posted a screencast showing exactly what the problem is here. In short, while I am debugging the debugger starts jumping from place to place and not following the program logic I have in place. The only other similar question I have found is a year old, had no solution, and can be found here.

The best guess I have so far is that the debugger is displaying the text I have typed in, but is actually executing an older version of the class file which it has cached somewhere. Therefore, I tried:

  • cleaning the project
  • manually deleting all of the class files from the target folder and from the target-eclipse folder
  • Searching my entire hdd for additional files with similar names
  • removing my project from the workspace and re-adding it
  • closing and reopening the IDE
  • grails refresh-dependencies
  • Importing the project into a new IDE (I was using GGTS, I switched to IntelliJ)

None of those solutions had any effect. I realized that the issue was in a .groovy file, and I was writing almost pure Java, so I deleted the .groovy file, and re-created the class in a .java file. That solved my problem. Unfortunately I am having the problem again, and this time it is in a controller that heavily relies on the grails framework, so that solution is not an option. Other than also being in a .groovy file, another similarity is that the code breaks on an if statement.

My next steps:

  • Verify that the application is not executing the code I see by using print functions to monitor actual execution flow.
  • comment out the entire function and re-add functionality one line at a time to see if I can see what breaks it.
  • Delete the .groovy file, and re-create it as another .groovy file.

Any help is appreciated, and since I can't find any answers online I will continue to update this question as I learn more.

Was it helpful?

Solution

See my comment on the jira issue that you raised. You have found a problem with the groovy compiler and how it calculates line numbers. This is not a problem with executing the wrong class files or using a broken debugger. The debugger is doing exactly what it is expected to do. It is the compiler that is providing erroneous line number information.

The next step, as described in the issue, is to provide a simple project that recreates the bug. I tried to do so myself, but could not. So, please supply something that we can work with. Then we can notify the groovy compiler team.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top