OpenPDF
OpenPDF copied to clipboard
OSGi MANIFEST.MF Requires sun.misc which is not available in newer Java versions
Describe the bug I imported openpdf into my osgi project and get an Error: "Missing Constraint: Import-Package: sun.misc"
To Reproduce
- Setup an Eclipse Target Platform and add OpenPDF via Maven coordinates to the target platform (this is possible in newer Eclipse Releases)
- Open the "Target Platform State" View and look for the Bundle "com.github.librepdf.openpdf"
- You see the above error message
Expected behavior All dependencies are resolved
Screenshots
System (please complete the following information):
- I'm running on Java 11
Additional context As far as i can tell this API has been removed in newer Java Versions (i think Java9?). The only code i found using the class sun.misc.Unsafe seems to be MappedRandomAccessFile.java
It seems to me like the MANIFEST.MF get's generated by bndtolls. So either this code should be removed or changed or Import-Package should be optional.
Thanks for looking at the issue. Bye Peter
@albfernandez Can you please help at this? https://github.com/LibrePDF/OpenPDF/blob/bff6520a368fe0a35b443740a36cba108f4ed1a4/openpdf/src/main/java/com/lowagie/text/pdf/MappedRandomAccessFile.java#L220
Hi, I have same problem here. I build a project via maven. It has BIRT which depends on com.github.librepdf.openpdf
that imports the package sun.misc
which is unresolved by org.eclipse.tycho:tycho-compiler-plugin:2.7.3:validate-classpath
The package is exported by a bundle that I provided in the target. But, the package is not found. I am wondering how BIRT achieved that in their build https://ci.eclipse.org/birt/job/birt_4.9.0_maven/23/
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:2.7.3:validate-classpath (default-validate-classpath) on project com.xxxxx.common.service: Execution default-validate-classpath of goal org.eclipse.tycho:tycho-compiler-plugin:2.7.3:validate-classpath failed: org.osgi.framework.BundleException: Bundle com.xxxxx.common.service cannot be resolved:com.xxxxx.common.service [153]
[ERROR] Unresolved requirement: Require-Bundle: com.xxxxx.reports.printService; bundle-version="1.0.0"
[ERROR] -> Bundle-SymbolicName: com.xxxxx.reports.printService; bundle-version="1.3.0.202205172234"; singleton:="true"
[ERROR] com.xxxxx.reports.printService [44]
[ERROR] Unresolved requirement: Require-Bundle: org.eclipse.birt.report.engine.emitter.pdf; bundle-version="4.9.0"
[ERROR] -> Bundle-SymbolicName: org.eclipse.birt.report.engine.emitter.pdf; bundle-version="4.9.0.v202203150031"; singleton:="true"
[ERROR] org.eclipse.birt.report.engine.emitter.pdf [52]
[ERROR] Unresolved requirement: Require-Bundle: com.github.librepdf.openpdf; bundle-version="[1.3.0,3.0.0)"
[ERROR] -> Bundle-SymbolicName: com.github.librepdf.openpdf; bundle-version="1.3.26"
[ERROR] com.github.librepdf.openpdf [58]
[ERROR] Unresolved requirement: Import-Package: org.bouncycastle.asn1.cmp; version="[1.68.0,2.0.0)"; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.bouncycastle.asn1.cms; version="[1.68.0,2.0.0)"; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.bouncycastle.asn1.tsp; version="[1.68.0,2.0.0)"; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.bouncycastle.cert; version="[1.68.0,2.0.0)"; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.bouncycastle.cert.jcajce; version="[1.68.0,2.0.0)"; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.bouncycastle.cert.ocsp; version="[1.68.0,2.0.0)"; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.bouncycastle.cms; version="[1.68.0,2.0.0)"; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.bouncycastle.cms.jcajce; version="[1.68.0,2.0.0)"; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.bouncycastle.operator; version="[1.68.0,2.0.0)"; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.bouncycastle.operator.jcajce; version="[1.68.0,2.0.0)"; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.bouncycastle.tsp; version="[1.68.0,2.0.0)"; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.apache.fop.complexscripts.fonts; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.apache.fop.complexscripts.util; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.apache.fop.fonts.apps; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: org.apache.fop.fonts.truetype; resolution:="optional"
[ERROR] Unresolved requirement: Import-Package: sun.misc
I am using Java11 from justj. The product starts in eclipse actually and everything is fine but the maven build is not working because of this. I am even almost sure that no where in the source code is using a class from the sun.misc
.
Disclaimer: I'm really not an expert in this topic. I think that sun.misc.Unsafe::invokeCleaner was added to the JDK again, if I understand https://bugs.openjdk.org/browse/JDK-8171377 correctly.
So wouldn't it be possible to just drop the explicit sun.misc requirement dependency and just assume that the one method we need is available?