graal icon indicating copy to clipboard operation
graal copied to clipboard

[native-image] Building a native image for the Apache Felix framework jar fails with multiple DeletedElementException instances

Open rombert opened this issue 6 years ago β€’ 5 comments

Using

openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-20191008104205.buildslave.jdk8u-src-tar--b07)
OpenJDK 64-Bit GraalVM CE 19.2.1 (build 25.232-b07-jvmci-19.2-b03, mixed mode)

I am trying to build a native image of the Apache Felix Framework jar. Felix is an OSGi framework implementation and does a lot of work with custom classloaders. Building an image of the framework is not expected to do anything meaningful since it would require additional jars, but the first step is to validate that building an image for the framework works.

Steps to reproduce:

  1. Download the Felix Framework distribution archive from http://felix.apache.org/downloads.cgi#framework ( right now the latest is 6.0.3 )
  2. Extract the archive
  3. Go to felix-framework-6.0.3/bin and run $ native-image -jar felix.jar

I've attached the output as a log file - native-image-build.log .

rombert avatar Nov 06 '19 19:11 rombert

As the error message suggests you can use --report-unsupported-elements-at-runtime to push those errors to run time. This should allow you to build a native image, but that may not get you too far if those unimplemented methods are actually on the execution path. We are currently working on a re-implementation of our ClassLoader support, so I'll get back to this issue once that is done. However, be warned that if the framework does need to load bytecodes at run time native-image doesn't support that use case.

cstancu avatar Nov 06 '19 20:11 cstancu

Hi, there is another project called Atomos which implements a first draft of Connected OSGi within Equinox, a different OSGi Framework. There is a Build instruction for Substrate which utilizes native-image to bundle a single application from multiple OSGi bundles. Maybe it’s a good starting point bringing AOT towards the OSGi ecosystem. https://github.com/tjwatson/atomos

gurkerl83 avatar Nov 06 '19 21:11 gurkerl83

@cstancu - unimplemented methods are used at runtime, yes, as that's when OSGI frameworks do most of the class loading.

I was wondering whether conceptually there is an option to accommodate such behaviour, e.g. by making the dynamic class loading work only on a subset of existing classes that are defined at build time.

@gurkerl83 - thanks for the hint, I'll make sure to watch that.

rombert avatar Nov 11 '19 09:11 rombert

@rombert

  • The binaries inside the link are invalid. Could you update the link to the specific survey version?

linghengqian avatar Sep 09 '22 17:09 linghengqian

@linghengqian - hm, not sure why that link broke, a working one is https://felix.apache.org/documentation/downloads.html#_felix_framework_distribution .

That will point you to the latest version, the 6.0.3 version I referenced can be downloaded from https://archive.apache.org/dist/felix/org.apache.felix.main.distribution-6.0.3.zip .

rombert avatar Sep 13 '22 09:09 rombert