Kotlin illegal reflection when building AOSP

204 views
Skip to first unread message

Steve

unread,
Apr 5, 2020, 11:27:36 AM4/5/20
to Android Building
Trying to build a standard AOSP on Ubuntu 14.04, target aosp_arm-eng.
The build works fine until the metalava and the use of kotlin, when it fails with:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreApplicationEnvironment (file:/aosp/soong/host/linux-x86/framework/metalava.jar) to field java.lang.reflect.Field.modifiers
WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreApplicationEnvironment
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.base/java.util.LinkedHashMap$LinkedKeySet.iterator(LinkedHashMap.java:543)
    at java.base/java.util.HashSet.iterator(HashSet.java:173)
    at kotlin.collections.CollectionsKt___CollectionsKt.toList(_Collections.kt:1220)
    at kotlin.collections.ArraysKt___ArraysKt.distinct(_Arrays.kt:9836)
    at com.android.tools.metalava.model.psi.PsiModifierItem$Companion.create(PsiModifierItem.kt:188)
    at com.android.tools.metalava.model.psi.PsiModifierItem$Companion.create(PsiModifierItem.kt:58)
    at com.android.tools.metalava.model.psi.PsiItem$Companion.modifiers(PsiItem.kt:264)
    at com.android.tools.metalava.model.psi.PsiMethodItem$Companion.create(PsiMethodItem.kt:355)
    at com.android.tools.metalava.model.psi.PsiClassItem$Companion.create(PsiClassItem.kt:466)
    at com.android.tools.metalava.model.psi.PsiBasedCodebase.createClass(PsiBasedCodebase.kt:441)
    at com.android.tools.metalava.model.psi.PsiBasedCodebase.findOrCreateClass(PsiBasedCodebase.kt:559)
    at com.android.tools.metalava.model.psi.PsiClassItem$Companion$create$result$1.invoke(PsiClassItem.kt:534)
    at com.android.tools.metalava.model.psi.PsiClassItem$Companion$create$result$1.invoke(PsiClassItem.kt:391)
    at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:172)
    at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:716)
    at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(_Sequences.kt:746)
    at com.android.tools.metalava.model.psi.PsiClassItem$Companion.create(PsiClassItem.kt:538)
    at com.android.tools.metalava.model.psi.PsiBasedCodebase.createClass(PsiBasedCodebase.kt:441)
    at com.android.tools.metalava.model.psi.PsiBasedCodebase.initialize(PsiBasedCodebase.kt:180)
    at com.android.tools.metalava.Driver.parseSources(Driver.kt:876)
    at com.android.tools.metalava.Driver.parseSources$default(Driver.kt:847)
    at com.android.tools.metalava.Driver.loadFromSources(Driver.kt:773)
    at com.android.tools.metalava.Driver.processFlags(Driver.kt:182)
    at com.android.tools.metalava.Driver.run(Driver.kt:115)
    at com.android.tools.metalava.Driver.run$default(Driver.kt:98)
    at com.android.tools.metalava.Driver.main(Driver.kt:86)
12:35:03 ninja failed with: exit status 1


Following the AOSP environment instructions and build instructions, and have re-installed everything several times.  Same problem with the latest version of Ubuntu and the LTS 14.04 version.   Also with the aosp_arm64-eng target as well.

Any suggestions?

  Steve

Dan Willemsen

unread,
Apr 6, 2020, 1:35:21 PM4/6/20
to Android Building
The problem isn't the kolin warning, but java.lang.OutOfMemoryError -- your machine ran out of ram. How much ram is available/free before the build starts?

Are you using AOSP master, or some other branch/tag? We've made some attempts to help with this on master (running fewer "highmem" actions concurrently), but that may still need tweaking.

- Dan

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/f7bd0bc0-b3b3-4c04-bb6f-2f2fb4e96a52%40googlegroups.com.

Steve

unread,
Apr 6, 2020, 4:11:54 PM4/6/20
to Android Building
The machine has only 8Gb and 5580Mb are available when the build starts for 'm api-stubs-docs'.  Running a single job does not help.
This happens on the master branch.

It is not a virtual machine, the available swap is 7300Mb which is the default for Ubuntu installation.

Too small?

 -Steve

Dan Willemsen

unread,
Apr 6, 2020, 4:20:23 PM4/6/20
to Android Building
Yeah, our minimum requirement is 16GB (ignore the comment about virtual machines there -- the point is that we expect 16GB available for the OS+Build). Even on 16GB we've been seeing some number of issues (hence the workarounds I mentioned earlier).

You can try setting NINJA_HIGHMEM_NUM_JOBS=1 in your environment, you may also need to start lowering your `m -j#` value -- this defaults to a number related to your cpu cores, but that always doesn't work well on machines with low ram. (Anything we'd be doing to help the low ram cases would be adjusting these defaults based on what we detect we're running on)

- Dan

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.

Steve

unread,
Apr 7, 2020, 3:28:02 PM4/7/20
to Android Building
Thanks for the help!  Setting NINJA_HIGHMEM_NUM_JOBS=1 doesn't help.   I will upgrade to 16GB.
Any chance of fixing the Build Requirements Page to keep anybody else from landing in the same situation?

/Steve

For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages