Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set conditional debug breakpoint or evaluate expressions in external maven sources (like Spring) #152

Closed
phillipuniverse opened this issue Nov 29, 2018 · 3 comments

Comments

@phillipuniverse
Copy link

phillipuniverse commented Nov 29, 2018

Final output:

screen shot 2018-11-29 at 9 15 34 am

Conditional Breakpoint has Compilation error(s).

Reason:
Unable to compile conditional breakpoint - missing Java project context.

Reproduction steps:

  1. Download the latest STS from https://spring.io/tools (I got 4-4.0.1.RELEASE-e4.9.0-macosx.cocoa.x86_64.dmg)
  2. I added the Lombok jar and -javaagent to the .app folder in order to use Lombok annotations
  3. Went to File -> New Project -> Spring Starter Project and hit next until the project was created (just accepted all the defaults)
  4. In the generated pom.xml, I changed it around to add spring-boot-starter-web and JUnit Jupiter
  5. Changed the DemoApplicationTests to look like this:
    @ExtendWith(SpringExtension.class)
    @SpringBootTest
    public class DemoApplicationTests {
    
        @Configuration
        static class Config {
    	
        }
    
        @Component
        static class BeanFromTest {
    
        }
    
        @Autowired
        ApplicationContext ctx;
    
        @Test
        public void containsBean() {
            assertNotNull(ctx.getBean(BeanFromTest.class));
        }
    
     }
  6. CMD + Shift + T to open DefaultListableBeanFactory, set a breakpoint in registerBeanDefinition() to hit when the BeanFromTest is registered
  7. Hit 'Debug as Junit Test' to debug the test

The breakpoint hits on every single invocation because of the "Unable to compile conditional breakpoint - Missing Java Project Context". Also if you look in the screenshot, you'll see that 2 instances of DefaultListableBeanFactory are opened: 1 that has the little Java bytecode argument (which is where I originally set the breakpoint) and one that just has a J, which was opened when the breakpoint hit. The J icon usually means that the project is not a Java project.

Also might be interesting is that before running the JUnit test at all, I had previously downloaded the sources for spring-context so that was already in my ~/.m2/repository. It did not need to download it on-demand.

I also cannot do things I normally can in Java debugging, like right-click and "Inspect" with 'Unable to evaluate the selected expression' (even though hovering works):

screen recording 2018-11-29 at 09 29 am

@phillipuniverse
Copy link
Author

Exact project ready to import: failing-conditional-breakpoint.zip

@phillipuniverse
Copy link
Author

Bummer, this also happens in core Eclipse. Opened issue at https://bugs.eclipse.org/bugs/show_bug.cgi?id=542089, I'll close this one.

@martinlippert
Copy link
Member

Thanks for double checking with a vanilla Eclipse and reporting over there. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants