Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an Android regression test #1152

Open
gbrail opened this issue Jan 7, 2022 · 8 comments
Open

Create an Android regression test #1152

gbrail opened this issue Jan 7, 2022 · 8 comments
Labels
Android Issues related to running Rhino on Android

Comments

@gbrail
Copy link
Collaborator

gbrail commented Jan 7, 2022

Many people use Rhino in Android (in interpreted mode, as Android has a different bytecode format than other JVMs). However we don't know if Rhino is compatible with Android until an Android developer tells us.

We need an automated regression test for Android compatibility, that runs against some reasonable target version of Android.

I researched this a bit in the hopes that we could use a simple linting tool, but the standard Android "lint" looks pretty difficult to integrate with our build without causing many other problems.

A better way to solve this problem might be to create a separate repository that has an Android project in it and then set up a CI job to run that test regularly. I might have time to spend on this later this month but it'd be better to find a volunteer who is more familiar with Android.

@gbrail
Copy link
Collaborator Author

gbrail commented Jan 7, 2022

Update: Perhaps ErrorProne can help.

@b3nn0
Copy link

b3nn0 commented Jan 7, 2022

Another possibility: the Android SDK ships with a regular jar file for each API version, containing all the class files that are available - see screenshot for what it looks like.
Maybe it would be possible to use regular java to compile Rhino, but use this jar as library search path and exclude the standard JVM library or something? I'm not JDK-guru enough to judge the viability though.

Also, I'm not sure under what conditions this android.jar file can be redistributed or potentially automatically be downloaded from some source when running tests or something.
See also: https://stackoverflow.com/questions/50283073/what-is-android-jar-what-does-it-include

EDIT: just tested it:
Created a simple test file a.java:

import java.lang.String;
//import javax.lang.model.SourceVersion;
import android.accounts.Account;
public class a {
    public static void main(String[] args) {

    }
}

And compiled with android.jar from the SDK:
javac -source 1.8 -target 1.8 -bootclasspath android.jar /tmp/a.java
Which succeeded (uses android.accounts.Account), but failed when I commented in the javax.lang.model.SourceVersion import.

image

@p-bakker p-bakker added the Android Issues related to running Rhino on Android label Jan 12, 2022
@p-bakker
Copy link
Collaborator

Taggin @F43nd1r here as he created a related case to this in the past: #282

@F43nd1r
Copy link

F43nd1r commented Jan 20, 2022

I previously started work on getting the full rhino test suite to run on android, but quickly gave up due to missing knowledge of rhinos internal structure.

I'm not really active in this topic anymore, so I probably won't be of much help.

@p-bakker
Copy link
Collaborator

@F43nd1r what we're looking for is help on the Android-specific stuff, see issue #1149 and particularly comments #1149 (comment) and #1149 (comment)

@rbri
Copy link
Collaborator

rbri commented Oct 6, 2024

Have the same need for HtmlUnit (https://github.com/HtmlUnit/htmlunit-android) but no good solution so far....

@rPraml
Copy link
Contributor

rPraml commented Oct 11, 2024

For now, I've built a very simple (!) and also my first android app, that integrates the rhino.jar in a small showcase: https://github.com/rPraml/rhino-on-android - it's far away from running a test suite.

@821938089
Copy link

Run the Android emulator in GitHub Action:
https://github.com/ReactiveCircus/android-emulator-runner

The last part of the README lists the projects that use this Android emulator, and you can refer to how they write tests and run them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues related to running Rhino on Android
Projects
None yet
Development

No branches or pull requests

7 participants