eclipse-archived / ceylon

The Ceylon compiler, language module, and command line tools
http://ceylon-lang.org
Apache License 2.0
399 stars 62 forks source link

Android: support alternate JDK provider #5883

Closed FroMage closed 8 years ago

FroMage commented 8 years ago

Android comes with its own JDK which contains the following packages:

android
android.accessibilityservice
android.accounts
android.animation
android.annotation
android.app
android.app.admin
android.app.assist
android.app.backup
android.app.job
android.app.usage
android.appwidget
android.bluetooth
android.bluetooth.le
android.content
android.content.pm
android.content.res
android.database
android.database.sqlite
android.drm
android.gesture
android.graphics
android.graphics.drawable
android.graphics.drawable.shapes
android.graphics.pdf
android.hardware
android.hardware.camera2
android.hardware.camera2.params
android.hardware.display
android.hardware.fingerprint
android.hardware.input
android.hardware.usb
android.inputmethodservice
android.location
android.media
android.media.audiofx
android.media.browse
android.media.effect
android.media.midi
android.media.projection
android.media.session
android.media.tv
android.mtp
android.net
android.net.http
android.net.nsd
android.net.rtp
android.net.sip
android.net.wifi
android.net.wifi.p2p
android.net.wifi.p2p.nsd
android.nfc
android.nfc.cardemulation
android.nfc.tech
android.opengl
android.os
android.os.storage
android.preference
android.print
android.print.pdf
android.printservice
android.provider
android.renderscript
android.sax
android.security
android.security.keystore
android.service.carrier
android.service.chooser
android.service.dreams
android.service.media
android.service.notification
android.service.restrictions
android.service.textservice
android.service.voice
android.service.wallpaper
android.speech
android.speech.tts
android.system
android.telecom
android.telephony
android.telephony.cdma
android.telephony.gsm
android.test
android.test.mock
android.test.suitebuilder
android.test.suitebuilder.annotation
android.text
android.text.format
android.text.method
android.text.style
android.text.util
android.transition
android.util
android.view
android.view.accessibility
android.view.animation
android.view.inputmethod
android.view.textservice
android.webkit
android.widget
com.android.internal.util
dalvik.annotation
dalvik.bytecode
dalvik.system
java.awt.font
java.beans
java.io
java.lang
java.lang.annotation
java.lang.ref
java.lang.reflect
java.math
java.net
java.nio
java.nio.channels
java.nio.channels.spi
java.nio.charset
java.nio.charset.spi
java.security
java.security.acl
java.security.cert
java.security.interfaces
java.security.spec
java.sql
java.text
java.util
java.util.concurrent
java.util.concurrent.atomic
java.util.concurrent.locks
java.util.jar
java.util.logging
java.util.prefs
java.util.regex
java.util.zip
javax.crypto
javax.crypto.interfaces
javax.crypto.spec
javax.microedition.khronos.egl
javax.microedition.khronos.opengles
javax.net
javax.net.ssl
javax.security.auth
javax.security.auth.callback
javax.security.auth.login
javax.security.auth.x500
javax.security.cert
javax.sql
javax.xml
javax.xml.datatype
javax.xml.namespace
javax.xml.parsers
javax.xml.transform
javax.xml.transform.dom
javax.xml.transform.sax
javax.xml.transform.stream
javax.xml.validation
javax.xml.xpath
junit.framework
junit.runner
org.apache.http.conn
org.apache.http.conn.scheme
org.apache.http.conn.ssl
org.apache.http.params
org.json
org.w3c.dom
org.w3c.dom.ls
org.xmlpull.v1
org.xmlpull.v1.sax2
org.xml.sax
org.xml.sax.ext
org.xml.sax.helpers
FroMage commented 8 years ago

So it has parts of:

And the base Android stuff.

lucaswerkmeister commented 8 years ago

So this would be one module that you import instead of java.base etc., and which contains all those packages?

FroMage commented 8 years ago

It's not entirely clear yet. For one thing it does not actually contain these modules entirely, just parts of them. It's also unclear what version of the last three it provides, and I strongly suspect it depends on the Android version.

I suppose we could make the Android jar "provide" all these modules, like the JDK provides modules out of the bootclasspath. This way, users of those modules would not need to import the autonomous modules.

FroMage commented 8 years ago

OTOH https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html suggests that the HttpClient on Android is outdated, so perhaps we should hide it?

FroMage commented 8 years ago

And http://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client claims it was removed (though I still see it in the jar).

quintesse commented 8 years ago

Would we need extra "JigSaw" module/package lists? And would we then select the active one depending on the runtime? Because it seems that an import of "java.base" would mean something different from one case to another. There might be extra modules and others might be missing. Also the compiler should be able to warn when you try to import a module that's part of the JDK and not Android, etc etc. No?

FroMage commented 8 years ago

ATM we do JDK module detection based on the running JVM. We can't detect Android since it's not a VM. I think we should add a new flag like --java-language-provider android/23.1.1 which would require that module to be in the module repo and treat it as the source of all JDK modules that exist in there. It would also reject imports of non-existent modules such as java.rmi, and hopefully also consider that java.desktop only contains a single package.

That flag would apply to (at least) the JVM compiler and tools like import-jar.

I think we should still require explicit module imports for the JDK modules and junit/httpclient even though they're in that Android jar.

FroMage commented 8 years ago

OTOH this may very well also impact the runtime via the metamodel and so there should also be a way to configure this flag via an API in Main or other that we can call from the running Android program.

FroMage commented 8 years ago

Related #1542

FroMage commented 8 years ago

Done.