Reading Manifest from DLL
Phil Martin <[email protected]> Fri, 6 Oct 2017 16:39:58 -0400
| Newsgroups | gmane.comp.java.ikvm.devel |
|---|---|
| Message-ID | <CAGwGAj8nPGZAq-2PUpQEKzgFPum5T5kqXVHZwxV1kw1DUsghxw@mail.gmail.com> |
--===============8001529885333467199==
Content-Type: multipart/alternative; boundary="94eb2c05afde26088d055ae6d8dc"
--94eb2c05afde26088d055ae6d8dc
Content-Type: text/plain; charset="UTF-8"
I am new to IKVM, and very pleased with it so far.
I am using it to wrap a vendor-supplied Java-only client API. When I run
the delivered JAR and class files using ikvm.exe in place of java.exe, the
client API and supplied sample client application behave exactly as
expected. However, when I use ikvmc to change the client API JAR to a .Net
DLL, I have just one issue.
The client API reads version information from the MANIFEST.MF file in the
JAR to choose the specific version & concrete classes to instantiate at
initialization time. This operation works just fine when running from the
JAR, but fails when using the DLL in the context of my .Net client
application.
For reference, here are the contents of the MANIFEST.MF file. I'm not clear
on how to check to confirm that it has found its way into my new DLL:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.3
Created-By: Apache Maven
Built-By: arao
Package: com.fxall
Build-Jdk: 1.6.0_35
Extension-Name: tcpi
Specification-Title:
Specification-Vendor: FX Alliance, LLC
Implementation-Title: com.fxall
Implementation-Vendor: FX Alliance, LLC
Implementation-Version: 4.0.0.1
Main-Class: com.fxall.tcpi.TCPIVersion
Build-Time: 12/12/2012 06:19 PM
Build-Number: 49
api-version: 3.3
release-version: 4.1.0.1
The log output from the successful run includes this line, which matches up
with the specified value for "release-version:" in MANIFEST.MF:
*****
INFO: FXall TCPI Version: 4.1.0.1
*****
While the log output from the failed run includes the following, which
seems to indicate that it's not finding the MANIFEST.MF file in the
JAR-converted-to-DLL:
*****
java.util.zip.ZipException: error in opening zip file
at
java.util.zip.ZipFile$PartialInputStream.seekEndOfCentralDirectory(ZipFile.java:629)
at java.util.zip.ZipFile.readEntries(ZipFile.java:243)
at java.util.zip.ZipFile.<init>(ZipFile.java:200)
at java.util.zip.ZipFile.<init>(ZipFile.java:163)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:103)
at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
at
sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
at
sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:105)
at
sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
at
sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
at java.net.JarURLConnection.getManifest(JarURLConnection.java:231)
at com.fxall.tcpi.TCPIVersion.<clinit>(TCPIVersion.java:25)
at com.fxall.tcpi.TCPIVersion.getVersion(TCPIVersion.java)
at
com.fxall.provider.CCPInterfaceConnection.<clinit>(CCPInterfaceConnection.java:78)
at
com.fxall.provider.AdvancedInterfaceConnection.<clinit>(AdvancedInterfaceConnection.java:19)
at
com.fxall.provider.AdvancedInterfaceConnection.<init>(AdvancedInterfaceConnection.java)
at cli.TCPI_Sample_Net.Program.Main(Program.cs:41)
at cli.System.AppDomain._nExecuteAssembly(Unknown Source)
at cli.System.AppDomain.ExecuteAssembly(Unknown Source)
at
cli.Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly(Unknown
Source)
JAR URL =
jar:file:/C:/pmart01/TCPI/Workspaces/VisualStudio/TCPI-Sample-Net/TCPI-Sample-Net/bin/Debug/tcpi.DLL!/
Default to Version : 3.3 Build : 3.3.2
INFO: FXall TCPI Version: 3.3.2
*****
I have used JustDecompile by Telerik to validate that the original tcpi.jar
file and its META-INF/MANIFEST.MF file are saved under a folder called
"Resources" in the new tcpi.dll file. Note that I have validated that the
file can be found in the location indicated in the JAR URL output above:
*****
C:\pmart01 >dir
C:\pmart01\TCPI\Workspaces\VisualStudio\TCPI-Sample-Net\TCPI-Sample-Net\bin\Debug\tcpi.DLL
Volume in drive C has no label.
Volume Serial Number is 54EE-057C
Directory of
C:\pmart01\TCPI\Workspaces\VisualStudio\TCPI-Sample-Net\TCPI-Sample-Net\bin\Debug
10/06/2017 11:31 AM 3,654,144 tcpi.dll
1 File(s) 3,654,144 bytes
0 Dir(s) 11,206,111,232 bytes free
*****
This seems like a pretty common use case, so I assume I'm just missing
something simple. Any advice or information would be very much appreciated.
--94eb2c05afde26088d055ae6d8dc
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"auto"><div dir=3D"auto"><br></div><div dir=3D"auto">I am new to=
IKVM, and very pleased with it so far.</div><div dir=3D"auto"><br></div><d=
iv dir=3D"auto">I am using it to wrap a vendor-supplied Java-only client AP=
I. When I run the delivered JAR and class files using ikvm.exe in place of =
java.exe, the client API and supplied sample client application behave exac=
tly as expected. However, when I use ikvmc to change the client API JAR to =
a .Net DLL, I have just one issue.</div><div dir=3D"auto"><br></div><div di=
r=3D"auto">The client API reads version information from the MANIFEST.MF fi=
le in the JAR to choose the specific version & concrete classes to inst=
antiate at initialization time. This operation works just fine when running=
from the JAR, but fails when using the DLL in the context of my .Net clien=
t application.</div><div dir=3D"auto"><br></div><div dir=3D"auto">For refer=
ence, here are the contents of the MANIFEST.MF file. I'm not clear on h=
ow to check to confirm that it has found its way into my new DLL:</div><div=
dir=3D"auto"><br></div><div dir=3D"auto">Manifest-Version: 1.0</div><div d=
ir=3D"auto">Ant-Version: Apache Ant 1.5.3</div><div dir=3D"auto">Created-By=
: Apache Maven</div><div dir=3D"auto">Built-By: arao</div><div dir=3D"auto"=
>Package: com.fxall</div><div dir=3D"auto">Build-Jdk: 1.6.0_35</div><div di=
r=3D"auto">Extension-Name: tcpi</div><div dir=3D"auto">Specification-Title:=
</div><div dir=3D"auto">Specification-Vendor: FX Alliance, LLC</div><div di=
r=3D"auto">Implementation-Title: com.fxall</div><div dir=3D"auto">Implement=
ation-Vendor: FX Alliance, LLC</div><div dir=3D"auto">Implementation-Versio=
n: 4.0.0.1</div><div dir=3D"auto">Main-Class: com.fxall.tcpi.TCPIVersion</d=
iv><div dir=3D"auto">Build-Time: 12/12/2012 06:19 PM</div><div dir=3D"auto"=
>Build-Number: 49</div><div dir=3D"auto">api-version: 3.3</div><div dir=3D"=
auto">release-version: 4.1.0.1</div><div dir=3D"auto"><br></div><div dir=3D=
"auto"><br></div><div dir=3D"auto">The log output from the successful run i=
ncludes this line, which matches up with the specified value for "rele=
ase-version:" in MANIFEST.MF:</div><div dir=3D"auto">*****</div><div d=
ir=3D"auto">INFO: FXall TCPI Version: 4.1.0.1</div><div dir=3D"auto">*****<=
/div><div dir=3D"auto"><br></div><div dir=3D"auto">While the log output fro=
m the failed run includes the following, which seems to indicate that it=
9;s not finding the MANIFEST.MF file in the JAR-converted-to-DLL:</div><div=
dir=3D"auto">*****</div><div dir=3D"auto">java.util.zip.ZipException: erro=
r in opening zip file</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at=
java.util.zip.ZipFile$PartialInputStream.seekEndOfCentralDirectory(ZipFile=
.java:629)</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at java.util.=
zip.ZipFile.readEntries(ZipFile.java:243)</div><div dir=3D"auto">=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 at java.util.zip.ZipFile.<init>(ZipFile.java:200)</=
div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at java.util.zip.ZipFile.=
<init>(ZipFile.java:163)</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 at java.util.jar.JarFile.<init>(JarFile.java:166)</div><div di=
r=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at java.util.jar.JarFile.<init>=
;(JarFile.java:103)</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at s=
un.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)</div><d=
iv dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at sun.net.www.protocol.jar.URL=
JarFile.getJarFile(URLJarFile.java:69)</div><div dir=3D"auto">=C2=A0 =C2=A0=
=C2=A0 =C2=A0 at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactor=
y.java:105)</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at sun.net.w=
ww.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)</div><d=
iv dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at sun.net.www.protocol.jar.Jar=
URLConnection.getJarFile(JarURLConnection.java:89)</div><div dir=3D"auto">=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at java.net.JarURLConnection.getManifest(JarURL=
Connection.java:231)</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at =
com.fxall.tcpi.TCPIVersion.<clinit>(TCPIVersion.java:25)</div><div di=
r=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at com.fxall.tcpi.TCPIVersion.getVer=
sion(TCPIVersion.java)</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 a=
t com.fxall.provider.CCPInterfaceConnection.<clinit>(CCPInterfaceConn=
ection.java:78)</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at com.f=
xall.provider.AdvancedInterfaceConnection.<clinit>(AdvancedInterfaceC=
onnection.java:19)</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at co=
m.fxall.provider.AdvancedInterfaceConnection.<init>(AdvancedInterface=
Connection.java)</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at cli.=
TCPI_Sample_Net.Program.Main(Program.cs:41)</div><div dir=3D"auto">=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 at cli.System.AppDomain._nExecuteAssembly(Unknown Sour=
ce)</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 at cli.System.AppDom=
ain.ExecuteAssembly(Unknown Source)</div><div dir=3D"auto">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 at cli.Microsoft.VisualStudio.HostingProcess.HostProc.RunUser=
sAssembly(Unknown Source)</div><div dir=3D"auto">JAR URL =3D jar:file:/C:/p=
mart01/TCPI/Workspaces/VisualStudio/TCPI-Sample-Net/TCPI-Sample-Net/bin/Deb=
ug/tcpi.DLL!/</div><div dir=3D"auto">Default to Version : 3.3 Build : 3.3.2=
</div><div dir=3D"auto">INFO: FXall TCPI Version: 3.3.2</div><div dir=3D"au=
to">*****</div><div dir=3D"auto"><br></div><div dir=3D"auto"><br></div><div=
dir=3D"auto">I have used JustDecompile by Telerik to validate that the ori=
ginal tcpi.jar file and its META-INF/MANIFEST.MF file are saved under a fol=
der called "Resources" in the new tcpi.dll file. Note that I have=
validated that the file can be found in the location indicated in the JAR =
URL output above:</div><div dir=3D"auto"><br></div><div dir=3D"auto">*****<=
/div><div dir=3D"auto">C:\pmart01 >dir C:\pmart01\TCPI\Workspaces\Visual=
Studio\TCPI-Sample-Net\TCPI-Sample-Net\bin\Debug\tcpi.DLL</div><div dir=3D"=
auto">=C2=A0Volume in drive C has no label.</div><div dir=3D"auto">=C2=A0Vo=
lume Serial Number is 54EE-057C</div><div dir=3D"auto"><br></div><div dir=
=3D"auto">=C2=A0Directory of C:\pmart01\TCPI\Workspaces\VisualStudio\TCPI-S=
ample-Net\TCPI-Sample-Net\bin\Debug</div><div dir=3D"auto"><br></div><div d=
ir=3D"auto">10/06/2017=C2=A0 11:31 AM=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A03,65=
4,144 tcpi.dll</div><div dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A01 File(s)=C2=A0 =C2=A0 =C2=A0 3,654,144 bytes</div><div=
dir=3D"auto">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00 Dir(=
s)=C2=A0 11,206,111,232 bytes free</div><div dir=3D"auto">*****</div><div d=
ir=3D"auto"><br></div><div dir=3D"auto">This seems like a pretty common use=
case, so I assume I'm just missing something simple. Any advice or inf=
ormation would be very much appreciated.</div><div dir=3D"auto"><br></div><=
/div>
--94eb2c05afde26088d055ae6d8dc--
--===============8001529885333467199==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--===============8001529885333467199==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Ikvm-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ikvm-developers
--===============8001529885333467199==--