Bug 91700 - combineAccessRules semantics
Summary: combineAccessRules semantics
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-17 19:30 EDT by Wassim Melhem CLA
Modified: 2005-04-25 13:01 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wassim Melhem CLA 2005-04-17 19:30:49 EDT
The current semantics of combineAccessRules should change, as they currently 
make one scenario impossible to accomplish.

Scenario:

Using I-20040413 + latest pde.core and pde.ui from HEAD:
1. Import org.eclipse.core.runtime and org.eclipse.osgi as source via the 
plugin import wizard.  Project core.runtime depends on and reexports 
org.eclipse.osgi.

2. Bring up the new plugin project wizard.  Name the plugin com.example.xyz on 
the first page.

3. On the second page of the wizard, in the "Plug-in Class section', uncheck 
the 'This plugin will make contributions to the UI" button.  Press Finish.

This will create a plugin with a single Java class.
The plugin will have the org.eclipse.core.runtime project on its classpath 
(and gets the reexported org.eclipse.osgi for free).  So everything will 
compile.  All good!

4. Now open the manifest for com.example.xyz in the plugin editor and go to 
the Dependencies page.  In the left viewer, delete the dependency on the 
org.eclipse.core.runtime plugin.  In the right viewer, add a dependency on 
package 'org.eclipse.core.runtime'.  Save.

Expected behavior: Only package 'org.eclipse.core.runtime' from the 
project 'org.eclipse.core.runtime' should be accessible to plugin 
com.example.xyz.  Everything else coming from core.runtime INCLUDING all 
classes reexported from org.eclipse.osgi must be inaccessible to 
com.example.xyz and I should see compiler errors.  But that doesn't happen.

Observed behavior: my plugin still compiles fine.

Even though I am passing combineAccessRules to be true, a **/* inaccessible 
access rule on the project entry still doesn't block classes reexported by 
org.eclipse.osgi.

Looking at the javadoc, the compiler behavior is the expected one, but it 
makes my scenario impossible to accomplish.  I need to be able to block the 
org.eclipse.osgi classes that are reexported by org.eclipse.core.runtime.
Comment 1 Philipe Mulet CLA 2005-04-18 07:42:41 EDT
What change in semantics are you suggesting ? What exactly are the access rules
you did set during your scenario ?
Comment 2 Wassim Melhem CLA 2005-04-18 09:07:06 EDT
In this scenario, I set two access rules on the project entry referencing 
org.eclipse.core.runtime:

K_ACCESSIBLE: org/eclipse/core/runtime/*
K_NON_ACCESSIBLE: **/*

what I want is for the classes coming from org.eclipse.osgi that are 
reexported by core.runtime to become inaccessible to my plugin, because they 
don't match the first rule, but they do match the second rule.
Comment 3 Wassim Melhem CLA 2005-04-18 14:01:50 EDT
Let us ignore the 'combineAccessRules' arg for a minute, as I think JDT uses 
it in a way that is different than what I thought.

Here are the two (and only) scenarios that PDE needs to be able to support 
when it comes to project classpath entries.

1. I need to be able to set access rules on a project classpath entry (eg. 
core runtime project) and have it applied to that project alone, and NOT to 
any libraries/projects reexported by core.runtime via its pde container.  This 
is currently possible.

2. I need to be able to set access rules on a project classpath entry (eg. 
core.runtime project) and have it applied to said project AND all 
libraries/projects it reexports.  This is currently not possible, as far as I 
can see.  That is why the org.eclipse.osgi classes that are reexported via 
core.runtime are still getting through and not being filtered out by the **/* 
exclusion access rule.
Comment 4 Jerome Lanneluc CLA 2005-04-22 10:41:36 EDT
So that we understand each other, can we agree on the following notation ?
  1. +p/* is a K_ACCESSIBLE access rule for p/*,
  2. -**/* is a K_NON_ACCESSIBLE access rule for **/*,
  3. projectEntry(P1, +p1/*|-**/*, not exported, combined) is 
       a project classpath entry for project P1, 
       with 2 access rules (+p1/* and -**/*),
       it is not exported,
       and it combines access rules (as it is defined in I2005042).
  4. libraryEntry(lib.jar, +p2/*, exported) is 
     a library classpath entry for library lib.jar,
     with 1 access rule (+p2/*),
     and it is exported
  
Can you please describe your 2 scenarii with this notation? 
E.g.
org.eclipse.osgi
  libraryEntry(osgi.jar, +osgi/*, exported)
org.eclipse.core.runtime
  libraryEntry(runtime.jar, +runtime/*, exported)
  projectEntry(org.eclipse.osgi, +osgi/*|-**/*, not exported, not combined)

Then tell us what works and what doesn't work.

Thanks in advance for your effort.
Comment 5 Wassim Melhem CLA 2005-04-23 18:46:21 EDT
Scenario 1:  This one works

Project #1: the org.eclipse.osgi plugin imported as source.

Project #2: the org.eclipse.core.runtime plugin imported as source.

Project #3: a test plugin (com.example.xyz) to be created as follows:
    1. Bring up the new plugin project wizard.  Name the plugin 
com.example.xyz on the first page.
    2. On the second page of the wizard, in the "Plug-in Class section', 
uncheck the 'This plugin will make contributions to the UI" button.  Press 
Finish.


Project org.eclipse.osgi:  PDE container is empty.

Project org.eclipse.core.runtime: PDE container resolves to the following 
entry only:
  projectEntry(org.eclipse.osgi, +p1/*|...|+p39/*|-**/*, exported, not 
combined)

Project com.example.xyz: PDE container resolves the following entry:
  projectEntry(org.eclipse.core.runtime, +p1/*|...|+p12|-**/*, not exported, 
not combined)

Expectation: everything would compile fine.
Observed: same as expected.



Scenario 2: 

Project #1: the org.eclipse.osgi plugin imported as source.

Project #2: the org.eclipse.core.runtime plugin imported as source.

Project #3: a test plugin (com.example.xyz) to be created as follows:
    1. Bring up the new plugin project wizard.  Name the plugin 
com.example.xyz on the first page.
    2. On the second page of the wizard, in the "Plug-in Class section', 
uncheck the 'This plugin will make contributions to the UI" button.  Press 
Finish.
    3. Go to the runtime page of the plugin editor.  From the left viewer, 
remove the org.eclipse.core.runtime plugin.  In the right viewer, add a 
dependency on the org.eclipse.core.runtime package.  Save

Project org.eclipse.osgi:  PDE container is empty.

Project org.eclipse.core.runtime: PDE container resolves to the following 
entry only:
  projectEntry(org.eclipse.osgi, +p1/*|...|+p39/*|-**/*, exported, not 
combined)

Project com.example.xyz: PDE container resolves the following entry:
  projectEntry(org.eclipse.core.runtime, +org/eclipse/core/runtime/*|-**/*, 
not exported, combined)


Expected: Project com.example.xyz should have compiler errors about the type 
BundleContext from osgi being inaccessible.
Observed: same as expected using the latest jdt.core from HEAD.  Great.  This 
is the scenario that did not work before.
Comment 6 Jerome Lanneluc CLA 2005-04-25 11:46:05 EDT
(In reply to comment #5)
> Scenario 2: 
[...]
> Project #3: a test plugin (com.example.xyz) to be created as follows:
[...]
>     3. Go to the runtime page of the plugin editor. 
This should read: 3. Go to the Dependencies page of the plugin editor.
Comment 7 Jerome Lanneluc CLA 2005-04-25 13:01:31 EDT
Confirmed than scenario #2 works as expected both with org.eclipse.jdt.core HEAD
and v_550 (i.e. JDT Core from I-20050413) on top of I20050420.

Closing as works for me as no action was taken from JDT Core's standpoint.