Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-debug-dev] narrowing conversion from IJavaDebugTarget to JDIDebugTarget

Hi,

I am working on a class implementing the IJavaDebugTarget interface
which is not
JDIDebugTarget, it works via some debugging interface - MyDI (not JDI). Also I
have own implementations of other debug elements but it does not matter.
Listening notifications from the breakpoint manager I am able to reuse existing
JDT's breakpoints and create MyDI requests. On this way JDT does not react
on breakpoints and JDI requests are not created. This approach successfully
works if do not change breakpoints (that cause ClassCastException).

In the _recreate_ method of the JavaBreakpoint class (the package
org.eclipse.jdt.internal.debug.core.breakpoints) there is a narrowing reference
conversion from IJavaDebugTarget to JDIDebugTarget:
   IJavaDebugTarget jdiTarget =
(IJavaDebugTarget)target.getAdapter(IJavaDebugTarget.class);
   if (jdiTarget != null) {
       try {
           recreate((JDIDebugTarget)jdiTarget);
       } catch (CoreException e) {
           multiStatus.add(e.getStatus());
       }
   }
This conversion is not tested whether the actual reference value is
legitimate value
of the JDIDebugTarget type. It is a cause of ClassCastException. Any breakpoint
changes would happen smoothly if the conversion would be tested as it
is done for
example in the _removeThreadFilter_ method.
So, is it possible to resolve this problem?

I scanned sources for narrowing conversion to JDIDebugTarget and found that the
same problem may arise in the following methods:
   JavaBreakpoint.setThreadFilter
   JavaBreakpoint.cleanupForThreadTermination
   JavaLineBreakpoint.getEvaluationEngine
   JavaTargetPatternBreakpoint.setPattern

Thanks in advance

--
Vitaly Provodin,
Intel Middleware Products Division


Back to the top