[oe] [meta-java] how to properly handle conflict between openjdk-8-native, fastjar-native and ecj-bootstrap-native

Huang, Jie (Jackie) Jackie.Huang at windriver.com
Mon Dec 21 09:14:28 UTC 2015


Hi,

I found that builds with sstate will fail with:
checking if /build/tmp/sysroots/x86_64-linux/usr/bin/ecj-initial works... configure: error: The Java compiler /build/tmp/sysroots/x86_64-linux/usr/bin/ecj-initial failed (see config.log, check the CLASSPATH?)

That's because the do_install of openjdk-8-native install files directly into staging dirs, so the sstate is empty, I tried to send a patch to fix it:
[meta-java][PATCH v2] openjdk-8-native: fix incorrect do_install

But ends up with conflicting with fastjar-native and ecj-bootstrap-native, further investigation show me that they are not properly handled.

fastjar-native provides virtual/jar-native,
ecj-bootstrap-native provides virtual/javac-native (used to, the PROVIDES was removed recently)

and openjdk-8-native provides both of them.

Usually we use update-alternatives to avoid conflicts but seems like it doesn't work for native package,
But openjdk-8-native is still trying to use it which should be invalid:

$ grep ALTERNATIVE openjdk-8-native_72b05.bb
ALTERNATIVE_${PN} = "java javac jar pack200 unpack200 keytool"
ALTERNATIVE_LINK[java] = "${bindir}/java"
ALTERNATIVE_TARGET[java] = "${JDK_HOME}/bin/java"
ALTERNATIVE_PRIORITY[java] = "100"
ALTERNATIVE_LINK[javac] = "${bindir}/javac"
ALTERNATIVE_TARGET[javac] = "${JDK_HOME}/bin/javac"
ALTERNATIVE_PRIORITY[javac] = "100"
ALTERNATIVE_LINK[jar] = "${bindir}/jar"
ALTERNATIVE_TARGET[jar] = "${JDK_HOME}/bin/jar"
ALTERNATIVE_PRIORITY[jar] = "100"
ALTERNATIVE_LINK[pack200] = "${bindir}/pack200"
ALTERNATIVE_TARGET[pack200] = "${JDK_HOME}/bin/pack200"
ALTERNATIVE_PRIORITY[pack200] = "100"
ALTERNATIVE_LINK[unpack200] = "${bindir}/unpack200"
ALTERNATIVE_TARGET[unpack200] = "${JDK_HOME}/bin/unpack200"
ALTERNATIVE_PRIORITY[unpack200] = "100"
ALTERNATIVE_LINK[keytool] = "${bindir}/keytool"
ALTERNATIVE_TARGET[keytool] = "${JDK_HOME}/bin/keytool"
ALTERNATIVE_PRIORITY[keytool] = "100"

So we should use  the virtual/foo everywhere and set PREFERRRED_PROVIDER for it, but many
recipes is depending on fastjar-native directly:
$ grep -r 'DEPENDS.*fastjar-native' *|wc -l
14

virtual/jar-native is never used in depends.

And many recipe is depending on ecj-bootstrap-native directly through java-bootstrap-components.bbclass:

$ tail -n 2 classes/java-bootstrap-components.bbclass 
DEPENDS_prepend_class-native = " ecj-bootstrap-native "
DEPENDS_prepend_class-target = " virtual/javac-native "

I don't understand the purpose from reading the commit logs there, and it seems not correct to me.
The default for virtual/javac-native is openjdk-8-native, then these conflicted recipes will be built
together, it works without ssate since openjdk-8-native force to remove those files in staging dir
before installing them(which definitely breaks sstate):
# clean up the mess from bootstrap
    for tool in jar java javac keytool pack200 unpack200
    do
        rm -f ${STAGING_BINDIR_NATIVE}/$tool

        ln -sf "../lib/jvm/${JDK_DIR}/bin/$tool" ${STAGING_BINDIR_NATIVE}/$tool
    done

it's assuming that fastjar-native and ecj-bootstrap-native are built before openjdk-8-native,
but its' not always true especially when build with sstate.

I'm going to fix the do_install and remove the useless ALTERNATIVE settings for openjdk-8-native, 
and fix the depends only on virtual/foo then the user needs to set PREFERRED_PROVIDER,
so to avoid these conflicts. Please anyone has a better understanding correct me if this doesn't seem
to work.

Anyone has a better idea? Thanks!

Thanks,
Jackie








More information about the Openembedded-devel mailing list