Search code examples
javaregexjdijpda

JDI apply class filters for multiple classes


I am creating a MethodEntryRequest, and I want to apply this request to only methods of two class patterns for ex:- "java.*" and "sun.*". For that I had written following code.

MethodEntryRequest menr = mgr.createMethodEntryRequest();
menr.setSuspendPolicy(EventRequest.SUSPEND_ALL);
menr.addClassFilter("java.*|sun.*");

The problem with above code is it disables all method events. But if I apply only one class pattern method it is working fine. I tried escaping "|" with "\\\\|" but it did not work. So I want to know how to apply class filter for more than one class pattern ?


Solution

  • Looks like there is something wrong and normal java regex are not working. So I solved my problem by making two MethodEntryRequests one for "sun." and one for "java.". But this is not the best answer as for each class pattern there would be one MethodEntryRequest.