Bug 105238 - [osgi] ContextFinder stops too soon when security manager installed
Summary: [osgi] ContextFinder stops too soon when security manager installed
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: platform-runtime-inbox CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
: 117088 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-07-26 18:43 EDT by Gordon Hirsch CLA Friend
Modified: 2005-11-18 12:19 EST (History)
2 users (show)

See Also:


Attachments
Test case (6.62 KB, application/zip)
2005-07-26 18:45 EDT, Gordon Hirsch CLA Friend
no flags Details
Proposed Patch (1.66 KB, patch)
2005-07-26 18:46 EDT, Gordon Hirsch CLA Friend
no flags Details | Diff
Improvement from previous patch (1.29 KB, patch)
2005-08-02 10:40 EDT, Thomas Watson CLA Friend
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gordon Hirsch CLA Friend 2005-07-26 18:43:46 EDT
If my plugin attempts to load a class through the context class loader
(ContextFinder) when a security manager is installed, the load fails with
ClassNotFoundException. If I remove the security manager, the class load succeeds.

The problem is due to the way ContextFinder checks the call stack. It is looking
for the first class on the stack that is not the context finder itself and not
loaded by the boot class loader. In the case of a security manager, however, I
think there is another class that should be skipped: the (currently anonymous)
inner class that performs the doPrivileged() operation. 

I will attach a test project that reproduces the problem. It works fine when run
normally, but it fails if the following VM options are added to the launch config:

-Djava.security.manager -Djava.security.policy=<policy-file>

(Of course, the policy file should grant all permissions, else there are lots of
other problems :-). The attached project includes such a file.)

I'm also going to attach a patch that worked for me... but perhaps there is a
cleaner solution.
Comment 1 Gordon Hirsch CLA Friend 2005-07-26 18:45:43 EDT
Created attachment 25333 [details]
Test case

See description for how to run
Comment 2 Gordon Hirsch CLA Friend 2005-07-26 18:46:31 EDT
Created attachment 25334 [details]
Proposed Patch
Comment 3 Pascal Rapicault CLA Friend 2005-07-27 05:53:50 EDT
Need to investigate for 3.1.1.
Comment 4 Thomas Watson CLA Friend 2005-07-27 09:25:13 EDT
+1

We must fix this for 3.1.1.
Comment 5 Thomas Watson CLA Friend 2005-08-02 10:40:33 EDT
Created attachment 25558 [details]
Improvement from previous patch

This patch avoids the creation of a new inner class by having ContextFinder
implement PrivilegedAction itself.
Comment 6 Pascal Rapicault CLA Friend 2005-08-02 18:11:04 EDT
New patch reviewed. Good to go.
Comment 7 Thomas Watson CLA Friend 2005-08-03 11:11:12 EDT
Fixed in R3_1_maintenance branch and HEAD (3.2)
Comment 8 Thomas Watson CLA Friend 2005-11-18 12:19:07 EST
*** Bug 117088 has been marked as a duplicate of this bug. ***