Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 285292 - Trace fails to determine class/method/line number when using a tracing class
Summary: Trace fails to determine class/method/line number when using a tracing class
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5.1   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 290229 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-07-31 11:18 EDT by Troy Bishop CLA
Modified: 2009-09-23 09:34 EDT (History)
3 users (show)

See Also:
john.arthorne: review+


Attachments
possible solution (1008 bytes, patch)
2009-07-31 11:19 EDT, Troy Bishop CLA
tjwatson: iplog+
Details | Diff
test patch (3.57 KB, patch)
2009-07-31 13:51 EDT, Troy Bishop CLA
tjwatson: iplog+
Details | Diff
updated tests (4.96 KB, patch)
2009-07-31 14:59 EDT, Thomas Watson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Troy Bishop CLA 2009-07-31 11:18:26 EDT
Build ID: 3.5

Steps To Reproduce:

I'm not sure why I didn't see this earlier, but if you register a tracing class via the DebugOptions#newDebugTrace(String, Class) API then the logic in the org.eclipse.osgi.framework.debug.FrameworkDebugTraceEntry class to dynamically find the caller of the tracing class will fail (the class and method will be 'null' while the line number will be 0).  I will attach a patch that will correct this problem.

More information:

Please consider this patch for the 3.5.1 release of Eclipse.
Comment 1 Troy Bishop CLA 2009-07-31 11:19:00 EDT
Created attachment 143149 [details]
possible solution
Comment 2 Thomas Watson CLA 2009-07-31 11:41:08 EDT
(In reply to comment #0)
> I'm not sure why I didn't see this earlier

I'm sure this is because of a lack of tests.  We need to add more tests to /org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/debugoptions/DebugOptionsTestCase.java

Troy, could you provide a testcase that reproduces this issue?
Comment 3 Troy Bishop CLA 2009-07-31 13:50:23 EDT
(In reply to comment #2)
> (In reply to comment #0)
> > I'm not sure why I didn't see this earlier
> 
> I'm sure this is because of a lack of tests.  We need to add more tests to
> /org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/debugoptions/DebugOptionsTestCase.java
> 
> Troy, could you provide a testcase that reproduces this issue?
> 

Yep, I agree... which is disappointing for me as I do remember running manual tests on it.  Obviously I missed this scenario.

I created two additional tests to make sure this doesn't happen in the future and will attach it.

The 'testTracingEntry01' test will make sure that the correct class and method are determined by mimicking the trace API by assuming that org.eclipse.osgi.tests.debugoptions.DebugOptionsTestCase#testTracingEntry01() is the caller to the trace API.

The 'testTracingEntry02' test will make sure that the correct class and method are determined by mimicking the trace API by assuming that org.eclipse.osgi.tests.debugoptions.DebugOptionsTestCase is the trace class and that sun.reflect.NativeMethodAccessorImpl#invoke0() is the caller to the trace API.

I could not think of better testcases considering that I'm not able to access the StackTraceElements that are created from the Exception in FrameworkDebugTraceEntry to verify that the right information is returned via FrameworkDebugTraceEntry#getClassName() and FrameworkDebugTraceEntry#getMethodName()

(unless another Exception is created and we look at its results and compare?)
Comment 4 Troy Bishop CLA 2009-07-31 13:51:35 EDT
Created attachment 143168 [details]
test patch
Comment 5 Thomas Watson CLA 2009-07-31 14:59:44 EDT
Created attachment 143182 [details]
updated tests

Your tests assume a Sun VM I think.  Here is an updated test that inserts more classes on the stack so we can test against them instead of sun.* classes.
Comment 6 Thomas Watson CLA 2009-07-31 15:19:49 EDT
I released the fix and tests to HEAD for 3.6.  John, could you review for 3.5.1?
Comment 7 John Arthorne CLA 2009-08-05 17:09:22 EDT
Looks good to me. I stepped through the test cases and verified that the fix does the right thing.
Comment 8 Thomas Watson CLA 2009-08-05 17:18:41 EDT
Patch (fix and test) released to 3.5.1.
Comment 9 Thomas Watson CLA 2009-09-23 09:34:01 EDT
*** Bug 290229 has been marked as a duplicate of this bug. ***