jeudi 25 avril 2019

Can IntelliJ be configured to hit a breakpoint in a Java class that is loaded at runtime through reflection?

I have a Java class that is being loaded at runtime through reflection for a Kafka Streams application, configured with passing the name of the class as a String, like this:

streamsConfig.put(StreamsConfig.DEFAULT_TIMESTAMP_EXTRACTOR_CLASS_CONFIG,
    "com.company.data.kstreams.Processor.MediaTimestampExtractor");

Then, at runtime, I have validated that it is properly loading and running the specified class. So, that part is working fine.

However, when I put a breakpoint in IntelliJ inside that custom MediaTimestampExtractor class, the debugger never hits it. I can see in the output that it's executing the code in the class, but for some reason, IntelliJ doesn't "know" that the class is being executed. In fact, the class itself shows a warning of:

Class 'MediaTimestampExtractor' is never used

Is there an option in IntelliJ to enable hitting breakpoints in code dynamically loaded by reflection, or a way to configure the breakpoint so that it hits, even if IntelliJ doesn't believe the class is being used?





Aucun commentaire:

Enregistrer un commentaire