Skip to main content

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

Hi Vitaly,

My quick response to this issue is "yes, that's true". As you may be aware 
the IJavaDebugTarget interface (as well as all the other java debug 
element interfaces/breakpoints) are specified as "not to be implemented by 
clients". That is, they were designed with the intention of having only 
one internal implementation, and are intended for "read only" use by 
clients. Thus the internal implementation casts to internal classes where 
neccessary.

So, this is the first time someone has gone this far down the path of 
providing their own implementation of these interfaces, and run into such 
a problem. I will have to have a more detailed look to see if the 
cast/restriction can be removed.

Darin Wright




"Vitaly Provodin" <vitaly.a.provodin@xxxxxxxxx> 
Sent by: jdt-debug-dev-bounces@xxxxxxxxxxx
08/30/2006 07:39 AM
Please respond to
"Eclipse JDT Debug developers list." <jdt-debug-dev@xxxxxxxxxxx>


To
jdt-debug-dev@xxxxxxxxxxx
cc

Subject
[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
_______________________________________________
jdt-debug-dev mailing list
jdt-debug-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jdt-debug-dev




Back to the top