Bug 569637 - Import issue with an OSGI jar added to classpath
Summary: Import issue with an OSGI jar added to classpath
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.17   Edit
Hardware: PC Windows 8
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2020-12-10 14:33 EST by Tom Rutchik CLA
Modified: 2023-01-31 15:07 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Rutchik CLA 2020-12-10 14:33:10 EST
-- Configuration Details --
Product: Eclipse IDE 4.17.0.20200910-1200 (org.eclipse.epp.package.jee.product)Installed Features:
 org.eclipse.jdt 3.18.500.v20200902-1800
Versioning Plugin:
 org.eclipse.platform 4.17.0.v20200902-1800

 I have a Java project that uses two external jars: bcpkix-jdk15on-167.jar and bcprov-ext-jdk15to18-1.67.jar.  Both jars can be obtained from the maven repository (search using org.bouncycastle and you'll find them). Neither of the two jars contain a module-info.java declaration.  The bcprov-ext jar is a conventional plain old jar.  The bcpix jar however is packaged as an OSGI bundle thats contains the OSGI header statements Export-Package and Import-Package.  All the packages needed to satisfy the Import-Package requirements can be resolved from the bcprov-ext jar.
 
 If I add the two jars to the projects classpath, I get an error in my project whenever I import a package from either jar.  It makes no difference on their order.  It I instead move the two jars to the modulepath and arrange the order correctly I can get the error on the Import statements that reference packages from that jar to go away. However, I get 2 error on my package statement:
 
 
The project was not built since its build path is incomplete. Cannot find the class file for org.bouncycastle.asn1.x500.X500Name. Fix the build path then try building this project

The type org.bouncycastle.asn1.x500.X500Name cannot be resolved. It is indirectly referenced from required .class files	

Import org.bouncycastle.asn1.x500.X500Name was the first import statement in my project.

I'm pretty sure there's a bug here, but it could also have something to do with my misunderstanding of java's modules.  My understanding is that when I added the jars to the classpath, that allows them to be treated for backward compatibility.  In other words the packages contained in them get added to an unnamed module and will resolve.  What I think is happening is the bcpkix is being treated as a module since it contains OSGI header statements even though it doesn't contain a module-info file. Being treated that why, it not able to resolve it Import-Package requirement because no other module is explicitly exporting those packages.  I could understand that behavior if that jar were put in the modulepath, but I don't think that it's suppose to work that way if it put on the classpath instead.

One more thing, I modified the pcpkix jar and removed the Import-Package statement from the Manifest file and I could get things to work without errors.  Again, I think that's not the behavior that should happen if the jar were added to the classpath
Comment 1 Andrey Loskutov CLA 2020-12-10 14:52:44 EST
Tom, please zip and attach your project. Hard to see where the issue is without it.
Comment 2 Eclipse Genie CLA 2023-01-31 15:07:09 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.