And on a second thought... You need also add the gcj USE flag to gcc,
reemerge gcc, then at the end remove the gcj USE flag from gcc and
reemerge gcc.
So it is much more complex.
So basically, provided that >=gcc-4.3 is stable, this is the outline
of what I thought, you can make it more efficient if you check for
other valid jdks and not force only gcj...
if installed icedtea6; then
exit 0
fi
if ! has_use gcc gcj; then
should_remove_gcj_use_from_gcc=1
USE="gcj" emerge --oneshot gcc || die
fi
if ! installed gcj-jdk; then
should_remove_gcj_jdk=1
emerge --oneshot gcj-jdk || die
fi
old_java=$(java-config -f)
java-config -S gcj-jdk || die
emerge icedtea6 || die
if [ ${old_java}" = "gcj-jdk" -a -n "${should_remove_gcj_jdk}" ]; then
java-config -S icedtea6 || die
else
java-config -S $(old_java) || die
fi
[ -n "${should_remove_gcj_jdk}" ] && emerge --unmerge gcj-jdk
[ -n "${should_remove_gcj_use_from_gcc}" ] && emerge --oneshot gcc
exit 0